@viclafouch/eslint-config-viclafouch 4.22.0 → 4.22.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -65
- package/base.mjs +36 -0
- package/eslint.config.mjs +1 -2
- package/index.d.ts +9 -0
- package/index.mjs +7 -36
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -39,29 +39,32 @@ These are the ESLint and Prettier settings for a Next.js project ⚡️
|
|
|
39
39
|
npm i -D @viclafouch/eslint-config-viclafouch
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
2. Extends your config with the minimal base of @viclafouch config :
|
|
42
|
+
3. Make sure your `package.json` has `"type": "module"`:
|
|
45
43
|
|
|
46
44
|
```json
|
|
47
45
|
{
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
"name": "your-project",
|
|
47
|
+
"type": "module",
|
|
48
|
+
...
|
|
51
49
|
}
|
|
52
50
|
```
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
4. Create a `eslint.config.js` file in the root of your project's directory (it should live where package.json does).
|
|
53
|
+
|
|
54
|
+
5. Extends your config with the minimal base of @viclafouch config :
|
|
55
55
|
|
|
56
56
|
```js
|
|
57
|
+
import { baseConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
58
|
+
|
|
57
59
|
/**
|
|
58
60
|
* @type {import("eslint").Linter.Config}
|
|
59
61
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
62
|
+
export default [
|
|
63
|
+
...baseConfig,
|
|
64
|
+
{
|
|
65
|
+
ignores: ['**/node_modules/**']
|
|
66
|
+
}
|
|
67
|
+
]
|
|
65
68
|
```
|
|
66
69
|
|
|
67
70
|
### Scripts
|
|
@@ -71,7 +74,7 @@ You can add two scripts to your package.json to lint and/or fix your code:
|
|
|
71
74
|
```json
|
|
72
75
|
{
|
|
73
76
|
"scripts": {
|
|
74
|
-
"lint": "eslint
|
|
77
|
+
"lint": "eslint",
|
|
75
78
|
"lint:fix": "npm run lint -- --fix",
|
|
76
79
|
}
|
|
77
80
|
}
|
|
@@ -94,31 +97,18 @@ First, extend your current config file `tsconfig.json` with this following snipp
|
|
|
94
97
|
Then, add the TypeScript Eslint rules to your `.eslintrc` file:
|
|
95
98
|
|
|
96
99
|
```js
|
|
97
|
-
{
|
|
98
|
-
"extends": [
|
|
99
|
-
"@viclafouch/eslint-config-viclafouch",
|
|
100
|
-
"@viclafouch/eslint-config-viclafouch/typescript"
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
```
|
|
100
|
+
import { baseConfig, typescriptConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
104
101
|
|
|
105
|
-
or js version for `.eslintrc.js` file:
|
|
106
|
-
|
|
107
|
-
```js
|
|
108
102
|
/**
|
|
109
103
|
* @type {import("eslint").Linter.Config}
|
|
110
104
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
tsconfigRootDir: __dirname
|
|
119
|
-
},
|
|
120
|
-
root: true
|
|
121
|
-
}
|
|
105
|
+
export default [
|
|
106
|
+
...baseConfig,
|
|
107
|
+
...typescriptConfig,
|
|
108
|
+
{
|
|
109
|
+
ignores: ['**/node_modules/**']
|
|
110
|
+
}
|
|
111
|
+
]
|
|
122
112
|
```
|
|
123
113
|
|
|
124
114
|
### Better typing
|
|
@@ -141,7 +131,7 @@ You can add two scripts to your package.json to lint and/or fix your code:
|
|
|
141
131
|
```json
|
|
142
132
|
{
|
|
143
133
|
"scripts": {
|
|
144
|
-
"lint": "tsc --noEmit && eslint
|
|
134
|
+
"lint": "tsc --noEmit && eslint",
|
|
145
135
|
"lint:fix": "npm run lint -- --fix",
|
|
146
136
|
},
|
|
147
137
|
}
|
|
@@ -152,25 +142,37 @@ You can add two scripts to your package.json to lint and/or fix your code:
|
|
|
152
142
|
If you want to sort your imports using your alias at the same time from your `jsonfig.json` or `tsconfig.json` file.
|
|
153
143
|
|
|
154
144
|
```js
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
import { baseConfig, importsConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @type {import("eslint").Linter.Config}
|
|
149
|
+
*/
|
|
150
|
+
export default [
|
|
151
|
+
...baseConfig,
|
|
152
|
+
...importsConfig,
|
|
153
|
+
{
|
|
154
|
+
ignores: ['**/node_modules/**']
|
|
155
|
+
}
|
|
156
|
+
]
|
|
161
157
|
```
|
|
162
158
|
|
|
163
159
|
## If you use Next.js
|
|
164
160
|
|
|
165
|
-
You can also add additional rules for Next.js. It includes the following configurations :
|
|
161
|
+
You can also add additional rules for Next.js. It includes the following configurations : `reactConfig`, `hooksConfig` and Next.js specific rules.
|
|
166
162
|
|
|
167
163
|
```js
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
164
|
+
import { baseConfig, nextConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @type {import("eslint").Linter.Config}
|
|
168
|
+
*/
|
|
169
|
+
export default [
|
|
170
|
+
...baseConfig,
|
|
171
|
+
...nextConfig,
|
|
172
|
+
{
|
|
173
|
+
ignores: ['**/node_modules/**', '**/dist/**', '**/.next/**']
|
|
174
|
+
}
|
|
175
|
+
]
|
|
174
176
|
```
|
|
175
177
|
|
|
176
178
|
## If you use React.js
|
|
@@ -178,30 +180,50 @@ You can also add additional rules for Next.js. It includes the following configu
|
|
|
178
180
|
You can also add additional rules for only React.js ecosystem (without Next.js).
|
|
179
181
|
|
|
180
182
|
```js
|
|
181
|
-
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
import { baseConfig, hooksConfig, reactConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @type {import("eslint").Linter.Config}
|
|
187
|
+
*/
|
|
188
|
+
export default [
|
|
189
|
+
...baseConfig,
|
|
190
|
+
...hooksConfig,
|
|
191
|
+
...reactConfig,
|
|
192
|
+
{
|
|
193
|
+
ignores: ['**/node_modules/**']
|
|
194
|
+
}
|
|
195
|
+
]
|
|
188
196
|
```
|
|
189
197
|
|
|
190
198
|
|
|
191
199
|
## If you want to use Prettier
|
|
192
200
|
|
|
193
|
-
Be sure
|
|
201
|
+
Be sure for the prettier config to be the last one.
|
|
194
202
|
|
|
195
203
|
```js
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
import {
|
|
205
|
+
baseConfig,
|
|
206
|
+
hooksConfig,
|
|
207
|
+
importsConfig,
|
|
208
|
+
prettierConfig,
|
|
209
|
+
reactConfig,
|
|
210
|
+
typescriptConfig
|
|
211
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @type {import("eslint").Linter.Config}
|
|
215
|
+
*/
|
|
216
|
+
export default [
|
|
217
|
+
...baseConfig,
|
|
218
|
+
...reactConfig,
|
|
219
|
+
...hooksConfig,
|
|
220
|
+
...importsConfig,
|
|
221
|
+
...typescriptConfig,
|
|
222
|
+
...prettierConfig,
|
|
223
|
+
{
|
|
224
|
+
ignores: ['**/node_modules/**', '**/dist/**']
|
|
225
|
+
}
|
|
226
|
+
]
|
|
205
227
|
```
|
|
206
228
|
|
|
207
229
|
## If you use VS Code
|
package/base.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import bestPracticesConfig from './rules/best-practices.mjs'
|
|
4
|
+
import errorConfig from './rules/errors.mjs'
|
|
5
|
+
import es6Config from './rules/es6.mjs'
|
|
6
|
+
import importsConfig from './rules/imports.mjs'
|
|
7
|
+
import nodeConfig from './rules/node.mjs'
|
|
8
|
+
import styleConfig from './rules/style.mjs'
|
|
9
|
+
import variablesConfig from './rules/variables.mjs'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type {import("eslint").Linter.Config}
|
|
13
|
+
*/
|
|
14
|
+
export default [
|
|
15
|
+
{
|
|
16
|
+
files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
|
|
17
|
+
linterOptions: {
|
|
18
|
+
reportUnusedDisableDirectives: 'error'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
languageOptions: {
|
|
23
|
+
globals: globals.builtin
|
|
24
|
+
},
|
|
25
|
+
plugins: {
|
|
26
|
+
unicorn: eslintPluginUnicorn
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
bestPracticesConfig,
|
|
30
|
+
nodeConfig,
|
|
31
|
+
errorConfig,
|
|
32
|
+
importsConfig,
|
|
33
|
+
styleConfig,
|
|
34
|
+
variablesConfig,
|
|
35
|
+
es6Config
|
|
36
|
+
]
|
package/eslint.config.mjs
CHANGED
package/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Linter } from 'eslint'
|
|
2
|
+
|
|
3
|
+
export declare const baseConfig: Linter.Config[]
|
|
4
|
+
export declare const typescriptConfig: Linter.Config[]
|
|
5
|
+
export declare const reactConfig: Linter.Config[]
|
|
6
|
+
export declare const nextConfig: Linter.Config[]
|
|
7
|
+
export declare const prettierConfig: Linter.Config[]
|
|
8
|
+
export declare const hooksConfig: Linter.Config[]
|
|
9
|
+
export declare const importsConfig: Linter.Config[]
|
package/index.mjs
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import styleConfig from './rules/style.mjs'
|
|
9
|
-
import variablesConfig from './rules/variables.mjs'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @type {import("eslint").Linter.Config}
|
|
13
|
-
*/
|
|
14
|
-
export default [
|
|
15
|
-
{
|
|
16
|
-
files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
|
|
17
|
-
linterOptions: {
|
|
18
|
-
reportUnusedDisableDirectives: 'error'
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
languageOptions: {
|
|
23
|
-
globals: globals.builtin
|
|
24
|
-
},
|
|
25
|
-
plugins: {
|
|
26
|
-
unicorn: eslintPluginUnicorn
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
bestPracticesConfig,
|
|
30
|
-
nodeConfig,
|
|
31
|
-
errorConfig,
|
|
32
|
-
importsConfig,
|
|
33
|
-
styleConfig,
|
|
34
|
-
variablesConfig,
|
|
35
|
-
es6Config
|
|
36
|
-
]
|
|
1
|
+
export { default as baseConfig } from './base.mjs'
|
|
2
|
+
export { default as typescriptConfig } from './typescript.mjs'
|
|
3
|
+
export { default as reactConfig } from './react.mjs'
|
|
4
|
+
export { default as nextConfig } from './next.mjs'
|
|
5
|
+
export { default as prettierConfig } from './prettier.mjs'
|
|
6
|
+
export { default as hooksConfig } from './hooks.mjs'
|
|
7
|
+
export { default as importsConfig } from './imports.mjs'
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viclafouch/eslint-config-viclafouch",
|
|
3
|
-
"version": "4.22.0",
|
|
3
|
+
"version": "4.22.1-beta.0",
|
|
4
4
|
"description": "ESLint and Prettier Config from Victor de la Fouchardiere",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.mjs",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"import": "./index.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
6
14
|
"keywords": [
|
|
7
15
|
"javascript",
|
|
8
16
|
"ecmascript",
|