@viclafouch/eslint-config-viclafouch 4.22.0 → 4.22.1-beta.1
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 +109 -66
- package/base.mjs +36 -0
- package/better-tailwindcss.mjs +32 -0
- package/eslint.config.mjs +1 -2
- package/index.d.ts +18 -0
- package/index.mjs +8 -36
- package/package.json +14 -5
package/README.md
CHANGED
|
@@ -18,13 +18,14 @@ These are the ESLint and Prettier settings for a Next.js project ⚡️
|
|
|
18
18
|
- [If you want to enable imports sorting](#if-you-want-to-enable-imports-sorting)
|
|
19
19
|
- [If you use Next.js](#if-you-use-nextjs)
|
|
20
20
|
- [If you use React.js](#if-you-use-reactjs)
|
|
21
|
+
- [If you use Tailwind CSS v4](#if-you-use-tailwind-css-v4)
|
|
21
22
|
- [If you want to use Prettier](#if-you-want-to-use-prettier)
|
|
22
23
|
- [If you use VS Code](#if-you-use-vs-code)
|
|
23
24
|
|
|
24
25
|
## What it does
|
|
25
26
|
|
|
26
27
|
* Lints JavaScript / TypeScript based on the latest standards
|
|
27
|
-
* Multiple configs `react` `hooks` `next`..
|
|
28
|
+
* Multiple configs `react` `hooks` `next` `tailwindcss`..
|
|
28
29
|
* Shared `tsconfig.json`
|
|
29
30
|
* Fixes issues and formatting errors with Prettier
|
|
30
31
|
* Check for accessibility rules on JSX elements.
|
|
@@ -39,29 +40,32 @@ These are the ESLint and Prettier settings for a Next.js project ⚡️
|
|
|
39
40
|
npm i -D @viclafouch/eslint-config-viclafouch
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
2. Extends your config with the minimal base of @viclafouch config :
|
|
43
|
+
3. Make sure your `package.json` has `"type": "module"`:
|
|
45
44
|
|
|
46
45
|
```json
|
|
47
46
|
{
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
"name": "your-project",
|
|
48
|
+
"type": "module",
|
|
49
|
+
...
|
|
51
50
|
}
|
|
52
51
|
```
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
4. Create a `eslint.config.js` file in the root of your project's directory (it should live where package.json does).
|
|
54
|
+
|
|
55
|
+
5. Extends your config with the minimal base of @viclafouch config :
|
|
55
56
|
|
|
56
57
|
```js
|
|
58
|
+
import { baseConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
59
|
+
|
|
57
60
|
/**
|
|
58
61
|
* @type {import("eslint").Linter.Config}
|
|
59
62
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
63
|
+
export default [
|
|
64
|
+
...baseConfig,
|
|
65
|
+
{
|
|
66
|
+
ignores: ['**/node_modules/**']
|
|
67
|
+
}
|
|
68
|
+
]
|
|
65
69
|
```
|
|
66
70
|
|
|
67
71
|
### Scripts
|
|
@@ -71,7 +75,7 @@ You can add two scripts to your package.json to lint and/or fix your code:
|
|
|
71
75
|
```json
|
|
72
76
|
{
|
|
73
77
|
"scripts": {
|
|
74
|
-
"lint": "eslint
|
|
78
|
+
"lint": "eslint",
|
|
75
79
|
"lint:fix": "npm run lint -- --fix",
|
|
76
80
|
}
|
|
77
81
|
}
|
|
@@ -94,31 +98,18 @@ First, extend your current config file `tsconfig.json` with this following snipp
|
|
|
94
98
|
Then, add the TypeScript Eslint rules to your `.eslintrc` file:
|
|
95
99
|
|
|
96
100
|
```js
|
|
97
|
-
{
|
|
98
|
-
"extends": [
|
|
99
|
-
"@viclafouch/eslint-config-viclafouch",
|
|
100
|
-
"@viclafouch/eslint-config-viclafouch/typescript"
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
or js version for `.eslintrc.js` file:
|
|
101
|
+
import { baseConfig, typescriptConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
106
102
|
|
|
107
|
-
```js
|
|
108
103
|
/**
|
|
109
104
|
* @type {import("eslint").Linter.Config}
|
|
110
105
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
tsconfigRootDir: __dirname
|
|
119
|
-
},
|
|
120
|
-
root: true
|
|
121
|
-
}
|
|
106
|
+
export default [
|
|
107
|
+
...baseConfig,
|
|
108
|
+
...typescriptConfig,
|
|
109
|
+
{
|
|
110
|
+
ignores: ['**/node_modules/**']
|
|
111
|
+
}
|
|
112
|
+
]
|
|
122
113
|
```
|
|
123
114
|
|
|
124
115
|
### Better typing
|
|
@@ -141,7 +132,7 @@ You can add two scripts to your package.json to lint and/or fix your code:
|
|
|
141
132
|
```json
|
|
142
133
|
{
|
|
143
134
|
"scripts": {
|
|
144
|
-
"lint": "tsc --noEmit && eslint
|
|
135
|
+
"lint": "tsc --noEmit && eslint",
|
|
145
136
|
"lint:fix": "npm run lint -- --fix",
|
|
146
137
|
},
|
|
147
138
|
}
|
|
@@ -152,25 +143,37 @@ You can add two scripts to your package.json to lint and/or fix your code:
|
|
|
152
143
|
If you want to sort your imports using your alias at the same time from your `jsonfig.json` or `tsconfig.json` file.
|
|
153
144
|
|
|
154
145
|
```js
|
|
155
|
-
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
146
|
+
import { baseConfig, importsConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @type {import("eslint").Linter.Config}
|
|
150
|
+
*/
|
|
151
|
+
export default [
|
|
152
|
+
...baseConfig,
|
|
153
|
+
...importsConfig,
|
|
154
|
+
{
|
|
155
|
+
ignores: ['**/node_modules/**']
|
|
156
|
+
}
|
|
157
|
+
]
|
|
161
158
|
```
|
|
162
159
|
|
|
163
160
|
## If you use Next.js
|
|
164
161
|
|
|
165
|
-
You can also add additional rules for Next.js. It includes the following configurations :
|
|
162
|
+
You can also add additional rules for Next.js. It includes the following configurations : `reactConfig`, `hooksConfig` and Next.js specific rules.
|
|
166
163
|
|
|
167
164
|
```js
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
import { baseConfig, nextConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @type {import("eslint").Linter.Config}
|
|
169
|
+
*/
|
|
170
|
+
export default [
|
|
171
|
+
...baseConfig,
|
|
172
|
+
...nextConfig,
|
|
173
|
+
{
|
|
174
|
+
ignores: ['**/node_modules/**', '**/dist/**', '**/.next/**']
|
|
175
|
+
}
|
|
176
|
+
]
|
|
174
177
|
```
|
|
175
178
|
|
|
176
179
|
## If you use React.js
|
|
@@ -178,30 +181,70 @@ You can also add additional rules for Next.js. It includes the following configu
|
|
|
178
181
|
You can also add additional rules for only React.js ecosystem (without Next.js).
|
|
179
182
|
|
|
180
183
|
```js
|
|
181
|
-
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
import { baseConfig, hooksConfig, reactConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @type {import("eslint").Linter.Config}
|
|
188
|
+
*/
|
|
189
|
+
export default [
|
|
190
|
+
...baseConfig,
|
|
191
|
+
...hooksConfig,
|
|
192
|
+
...reactConfig,
|
|
193
|
+
{
|
|
194
|
+
ignores: ['**/node_modules/**']
|
|
195
|
+
}
|
|
196
|
+
]
|
|
188
197
|
```
|
|
189
198
|
|
|
199
|
+
## If you use Tailwind CSS v4
|
|
200
|
+
|
|
201
|
+
You can add linting rules for Tailwind CSS v4 using `eslint-plugin-better-tailwindcss`. You need to provide the path to your CSS entry file via the `entryPoint` option.
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
import { baseConfig, betterTailwindcssConfig } from '@viclafouch/eslint-config-viclafouch'
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @type {import("eslint").Linter.Config}
|
|
208
|
+
*/
|
|
209
|
+
export default [
|
|
210
|
+
...baseConfig,
|
|
211
|
+
...betterTailwindcssConfig({
|
|
212
|
+
entryPoint: 'src/global.css'
|
|
213
|
+
}),
|
|
214
|
+
{
|
|
215
|
+
ignores: ['**/node_modules/**']
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
```
|
|
190
219
|
|
|
191
220
|
## If you want to use Prettier
|
|
192
221
|
|
|
193
|
-
Be sure
|
|
222
|
+
Be sure for the prettier config to be the last one.
|
|
194
223
|
|
|
195
224
|
```js
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
225
|
+
import {
|
|
226
|
+
baseConfig,
|
|
227
|
+
hooksConfig,
|
|
228
|
+
importsConfig,
|
|
229
|
+
prettierConfig,
|
|
230
|
+
reactConfig,
|
|
231
|
+
typescriptConfig
|
|
232
|
+
} from '@viclafouch/eslint-config-viclafouch'
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @type {import("eslint").Linter.Config}
|
|
236
|
+
*/
|
|
237
|
+
export default [
|
|
238
|
+
...baseConfig,
|
|
239
|
+
...reactConfig,
|
|
240
|
+
...hooksConfig,
|
|
241
|
+
...importsConfig,
|
|
242
|
+
...typescriptConfig,
|
|
243
|
+
...prettierConfig,
|
|
244
|
+
{
|
|
245
|
+
ignores: ['**/node_modules/**', '**/dist/**']
|
|
246
|
+
}
|
|
247
|
+
]
|
|
205
248
|
```
|
|
206
249
|
|
|
207
250
|
## 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
|
+
]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import betterTailwindcss from 'eslint-plugin-better-tailwindcss'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {Object} BetterTailwindcssOptions
|
|
5
|
+
* @property {string} entryPoint - Path to the CSS entry file (Tailwind v4)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates ESLint flat config for eslint-plugin-better-tailwindcss (Tailwind v4)
|
|
10
|
+
* @param {BetterTailwindcssOptions} options
|
|
11
|
+
* @returns {import("eslint").Linter.Config[]}
|
|
12
|
+
*/
|
|
13
|
+
export default function betterTailwindcssConfig({ entryPoint }) {
|
|
14
|
+
const recommendedRules = betterTailwindcss.configs?.recommended?.rules ?? {}
|
|
15
|
+
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
19
|
+
plugins: {
|
|
20
|
+
'better-tailwindcss': betterTailwindcss
|
|
21
|
+
},
|
|
22
|
+
settings: {
|
|
23
|
+
'better-tailwindcss': {
|
|
24
|
+
entryPoint
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
...recommendedRules
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
package/eslint.config.mjs
CHANGED
package/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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[]
|
|
10
|
+
|
|
11
|
+
export interface BetterTailwindcssOptions {
|
|
12
|
+
/** Path to the CSS entry file (Tailwind v4) */
|
|
13
|
+
entryPoint: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare function betterTailwindcssConfig(
|
|
17
|
+
options: BetterTailwindcssOptions
|
|
18
|
+
): Linter.Config[]
|
package/index.mjs
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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'
|
|
8
|
+
export { default as betterTailwindcssConfig } from './better-tailwindcss.mjs'
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viclafouch/eslint-config-viclafouch",
|
|
3
|
-
"version": "4.22.
|
|
3
|
+
"version": "4.22.1-beta.1",
|
|
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",
|
|
@@ -37,23 +45,24 @@
|
|
|
37
45
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
38
46
|
"app-root-path": "^3.1.0",
|
|
39
47
|
"babel-loader": "^10.0.0",
|
|
48
|
+
"eslint": ">= 9",
|
|
40
49
|
"eslint-config-prettier": "^10.1.1",
|
|
50
|
+
"eslint-plugin-better-tailwindcss": "^3.8.0",
|
|
41
51
|
"eslint-plugin-import": "^2.31.0",
|
|
42
52
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
43
53
|
"eslint-plugin-prettier": "^5.2.3",
|
|
44
54
|
"eslint-plugin-promise": "^7.2.1",
|
|
45
55
|
"eslint-plugin-react": "^7.37.4",
|
|
46
56
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
47
|
-
"eslint-plugin-unicorn": "^58.0.0",
|
|
48
57
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
49
58
|
"eslint-plugin-testing-library": "^7.1.1",
|
|
59
|
+
"eslint-plugin-unicorn": "^58.0.0",
|
|
50
60
|
"get-tsconfig": "^4.10.0",
|
|
51
61
|
"globals": "^16.0.0",
|
|
52
62
|
"prettier": ">= 3",
|
|
53
63
|
"prettier-plugin-curly": "^0.3.1",
|
|
54
64
|
"typescript": ">= 5",
|
|
55
|
-
"typescript-eslint": "^8.26.0"
|
|
56
|
-
"eslint": ">= 9"
|
|
65
|
+
"typescript-eslint": "^8.26.0"
|
|
57
66
|
},
|
|
58
67
|
"scripts": {
|
|
59
68
|
"lint": "eslint .",
|