UNPKG

3.05 kBMarkdownView Raw
1# CAR FOR YOU Eslint config
2
3[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
4
5## Usage
6
7```
8npm install @carforyou/eslint-config
9```
10
11Add a `lint` script to `package.json`:
12
13```
14 "lint": "eslint --ext ts,js,tsx,jsx,json ."
15```
16
17Add a `format` script to `package.json` to be able to use auto fix:
18
19```
20 "format": "npm run lint -- --fix",
21```
22
23### ESLint configuration
24
25Create `.eslintrc.js` in the root of the project:
26
27```
28 module.exports = {
29 extends: ["@carforyou/eslint-config"],
30 }
31```
32
33This package provides multiple eslint configurations. They build on top of one another so there's no need to include multiple ones.
34
35- If you're working on plain typescript project use the default:
36 ```
37 @carforyou/eslint-config
38 ```
39- If you're working on react project use:
40 ```
41 @carforyou/eslint-config/react
42 ```
43- For nextjs applications use:
44 ```
45 @carforyou/eslint-config/next
46 ```
47
48### Prettier configuration
49
50Create `.prettierrc.js` in the root of the project:
51
52```
53module.exports = {
54 ...require("@carforyou/eslint-config/prettier"),
55}
56```
57
58## VSCode integration
59
60### ESlint
61
62There's an [official eslint plugin](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) available to get notifications about linter errors.
63
64#### Auto-fixing problems on save
65
66You can add:
67
68```
69"editor.codeActionsOnSave": {
70 "source.fixAll.eslint": true
71}
72```
73
74to your `settings.json` to fix fixable eslint errors on file save. This will only fix things that can be auto-fixed. It also might take some time.
75
76### Prettier
77
78There is a [pretty good prettier formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) available. This will add `prettier` as an option to format document via command palette.
79
80You can also set prettier as default formatter for javascript, typescript and react files. Just add:
81
82```
83"[typescript]": {
84 "editor.defaultFormatter": "esbenp.prettier-vscode"
85},
86"[javascript]": {
87 "editor.defaultFormatter": "esbenp.prettier-vscode"
88},
89"[javascriptreact]": {
90 "editor.defaultFormatter": "esbenp.prettier-vscode"
91},
92"[typescriptreact]": {
93 "editor.defaultFormatter": "esbenp.prettier-vscode"
94}
95```
96
97to your `settings.json`.
98
99#### Auto-formatting on save
100
101You can enable formatting on save under `Settings` -> `Text Editor` -> `Formatting`.
102
103## Development
104
105```
106npm run build
107```
108
109You can link your local npm package to integrate it with any local project:
110
111```
112cd carforyou-eslint-config
113npm run build
114
115cd carforyou-listings-web
116npm link ../carforyou-eslint-config/pkg
117```
118
119## Release a new version
120
121New versions are released on the ci using semantic-release as soon as you merge into master. Please
122make sure your merge commit message adheres to the corresponding conventions.
123
124## Circle CI
125
126You will need to enable the repository in circle CI ui to be able to build it.
127
128For slack notifications to work you will need to provide the token in circle settings.
129
\No newline at end of file