Skip to content

Commit 7b818a8

Browse files
author
devgioele
committed
explain usage in further detail
1 parent 1e7caca commit 7b818a8

1 file changed

Lines changed: 63 additions & 11 deletions

File tree

readme.md

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,40 @@ Install the package:
2525
npm i -D @aboutbits/eslint-config
2626
```
2727

28+
We recommend linting by running `eslint` without `--ext` option. What files are to be linted should be specified inside the ESLint config and the TypeScript config.
29+
All files included (or not ignored) by the ESLint config (`.eslintrc.json`) must be included by the TypeScript config (`tsconfig.json`).
30+
For example, if this is your `.eslintrc.json`:
31+
32+
```json
33+
{
34+
// ...remaining config
35+
"ignorePatterns": ["node_modules", "dist"]
36+
}
37+
```
38+
39+
You may include the following files inside your `tsconfig.json`:
40+
41+
```json
42+
{
43+
// ...remaining config
44+
"exclude": ["node_modules", "dist"],
45+
"include": ["**/*.ts", "**/*.tsx"]
46+
}
47+
```
48+
49+
Should you have files that you want to be linted, but not inside your `tsconfig.json`, you can create a `tsconfig.eslint.json` file.
50+
Then change `.eslintrc.json` to be:
51+
52+
```json
53+
{
54+
// ...omitted
55+
"parserOptions": {
56+
"project": "./tsconfig.eslint.json"
57+
}
58+
// ...omitted
59+
}
60+
```
61+
2862
### TypeScript
2963

3064
Install the required packages:
@@ -33,11 +67,14 @@ Install the required packages:
3367
npm i -D eslint prettier @typescript-eslint/eslint-plugin eslint-plugin-prettier eslint-plugin-import
3468
```
3569

36-
`.eslintrc`
70+
`.eslintrc.json`
3771

3872
```json
3973
{
40-
"extends": "@aboutbits/eslint-config/ts"
74+
"extends": "@aboutbits/eslint-config/ts",
75+
"parserOptions": {
76+
"project": true
77+
}
4178
}
4279
```
4380

@@ -49,11 +86,14 @@ Install the required packages:
4986
npm i -D eslint prettier @typescript-eslint/eslint-plugin eslint-plugin-prettier eslint-plugin-import eslint-plugin-react eslint-plugin-react-hooks
5087
```
5188

52-
`.eslintrc`
89+
`.eslintrc.json`
5390

5491
```json
5592
{
56-
"extends": "@aboutbits/eslint-config/ts-react"
93+
"extends": "@aboutbits/eslint-config/ts-react",
94+
"parserOptions": {
95+
"project": true
96+
}
5797
}
5898
```
5999

@@ -65,11 +105,14 @@ Install the required packages:
65105
npm i -D eslint prettier @typescript-eslint/eslint-plugin eslint-plugin-prettier eslint-plugin-import eslint-plugin-react eslint-plugin-react-hooks @next/eslint-plugin-next
66106
```
67107

68-
`.eslintrc`
108+
`.eslintrc.json`
69109

70110
```json
71111
{
72-
"extends": "@aboutbits/eslint-config/ts-next"
112+
"extends": "@aboutbits/eslint-config/ts-next",
113+
"parserOptions": {
114+
"project": true
115+
}
73116
}
74117
```
75118

@@ -81,11 +124,14 @@ Install the required packages:
81124
npm i -D eslint eslint-plugin-formatjs
82125
```
83126

84-
`.eslintrc`
127+
`.eslintrc.json`
85128

86129
```json
87130
{
88-
"extends": "@aboutbits/eslint-config/formatjs"
131+
"extends": "@aboutbits/eslint-config/formatjs",
132+
"parserOptions": {
133+
"project": true
134+
}
89135
}
90136
```
91137

@@ -101,24 +147,30 @@ Install the required packages:
101147
npm i -D eslint prettier @typescript-eslint/eslint-plugin eslint-plugin-prettier eslint-plugin-import eslint-plugin-react eslint-plugin-react-hooks @next/eslint-plugin-next eslint-plugin-formatjs
102148
```
103149

104-
`.eslintrc`
150+
`.eslintrc.json`
105151

106152
```json
107153
{
108154
"extends": [
109155
"@aboutbits/eslint-config/ts-next",
110156
"@aboutbits/eslint-config/formatjs"
111-
]
157+
],
158+
"parserOptions": {
159+
"project": true
160+
}
112161
}
113162
```
114163

115164
### Overriding rules
116165

117-
`.eslintrc`
166+
`.eslintrc.json`
118167

119168
```json
120169
{
121170
"extends": "@aboutbits/eslint-config/ts",
171+
"parserOptions": {
172+
"project": true
173+
},
122174
"rules": {
123175
// your rules...
124176
}

0 commit comments

Comments
 (0)