@keeex/eslint-config 2.3.0 → 2.4.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 +31 -24
- package/package.json +11 -8
- package/prettier.config.js +0 -1
- package/src/config/mocha.js +7 -0
package/README.md
CHANGED
|
@@ -23,7 +23,8 @@ npm install -D @keeex/eslint-config
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
To prepare the configuration file, you can run `npx kxeslint-setup` to create a blank config file.
|
|
26
|
-
Alternatively, you can create the file yourself.
|
|
26
|
+
Alternatively, you can create the file yourself.
|
|
27
|
+
In both cases, it will be named `eslint.config.js`.
|
|
27
28
|
|
|
28
29
|
Here is all the available options with their default values:
|
|
29
30
|
|
|
@@ -67,17 +68,18 @@ export default await eslintConfig({
|
|
|
67
68
|
});
|
|
68
69
|
```
|
|
69
70
|
|
|
70
|
-
If any of the top-level property is not defined, it will be set to its default value.
|
|
71
|
-
customize the output, instead of directly exporting the return value of the function
|
|
72
|
-
|
|
71
|
+
If any of the top-level property is not defined, it will be set to its default value.
|
|
72
|
+
If you want to customize the output, instead of directly exporting the return value of the function
|
|
73
|
+
you can edit it by hand.
|
|
74
|
+
Good luck with that.
|
|
73
75
|
|
|
74
76
|
## Configuration
|
|
75
77
|
|
|
76
78
|
### `globals`
|
|
77
79
|
|
|
78
|
-
The `globals` property is an array of object to define which globals are available in the code.
|
|
79
|
-
of these objects can have two properties: `files`, which is an array of globs to match the
|
|
80
|
-
be considered, and `globals`, which is an object that can have the following properties:
|
|
80
|
+
The `globals` property is an array of object to define which globals are available in the code.
|
|
81
|
+
Each of these objects can have two properties: `files`, which is an array of globs to match the
|
|
82
|
+
files to be considered, and `globals`, which is an object that can have the following properties:
|
|
81
83
|
|
|
82
84
|
- "builtin": generic JS built-in globals
|
|
83
85
|
- "browser": globals available in the browser
|
|
@@ -93,7 +95,8 @@ be considered, and `globals`, which is an object that can have the following pro
|
|
|
93
95
|
|
|
94
96
|
### `environments`
|
|
95
97
|
|
|
96
|
-
Allows you to define general environments for specific directory.
|
|
98
|
+
Allows you to define general environments for specific directory.
|
|
99
|
+
The full configuration is:
|
|
97
100
|
|
|
98
101
|
```javascript
|
|
99
102
|
{
|
|
@@ -106,9 +109,10 @@ Allows you to define general environments for specific directory. The full confi
|
|
|
106
109
|
}
|
|
107
110
|
```
|
|
108
111
|
|
|
109
|
-
The four type of environments are: "node", "webapp", "mobile" and "mocha".
|
|
110
|
-
for the source files in the given directories, as well as restrict some
|
|
111
|
-
"webapp" or "mobile" are defined, react will only apply to these
|
|
112
|
+
The four type of environments are: "node", "webapp", "mobile" and "mocha".
|
|
113
|
+
They set-up some globals for the source files in the given directories, as well as restrict some
|
|
114
|
+
rules (for example, if "webapp" or "mobile" are defined, react will only apply to these
|
|
115
|
+
directories).
|
|
112
116
|
|
|
113
117
|
The "mocha" environment expects a full file specification, where other environments will be applied
|
|
114
118
|
to directories.
|
|
@@ -166,9 +170,9 @@ Array of globs to globally ignore for eslint.
|
|
|
166
170
|
### `import`
|
|
167
171
|
|
|
168
172
|
Some extra rules for formatting and ordering imports can be used by setting `import` to true
|
|
169
|
-
(enabled by default with a depth of 3).
|
|
170
|
-
|
|
171
|
-
missing a dependency cycle.
|
|
173
|
+
(enabled by default with a depth of 3).
|
|
174
|
+
It is possible to pass a number instead of a boolean to limit the depth of circular imports check.
|
|
175
|
+
This greatly improves performances, at the risk of missing a dependency cycle.
|
|
172
176
|
|
|
173
177
|
### `mocha`
|
|
174
178
|
|
|
@@ -177,13 +181,14 @@ true.
|
|
|
177
181
|
|
|
178
182
|
### `noBase`
|
|
179
183
|
|
|
180
|
-
The base configuration imports all eslint recommendeds rules and promises handling rules.
|
|
181
|
-
`noBase` to true removes that.
|
|
184
|
+
The base configuration imports all eslint recommendeds rules and promises handling rules.
|
|
185
|
+
Setting `noBase` to true removes that.
|
|
186
|
+
There is absolutely no reason to do so.
|
|
182
187
|
|
|
183
188
|
### `react`
|
|
184
189
|
|
|
185
|
-
To improve handling of React/JSX, set `react` to true.
|
|
186
|
-
following boolean properties:
|
|
190
|
+
To improve handling of React/JSX, set `react` to true.
|
|
191
|
+
You can also pass an object with the following boolean properties:
|
|
187
192
|
|
|
188
193
|
- `reactHooks`: enable/disable React hooks rules
|
|
189
194
|
- `newJsxRuntime`: enable/disable new JSX runtime rules
|
|
@@ -193,14 +198,16 @@ is automatically enabled.
|
|
|
193
198
|
|
|
194
199
|
### `typescript`
|
|
195
200
|
|
|
196
|
-
Set to `true` (the default value) to enable all TypeScript rules.
|
|
201
|
+
Set to `true` (the default value) to enable all TypeScript rules.
|
|
202
|
+
This includes tsdoc rules.
|
|
197
203
|
|
|
198
204
|
## Dependencies
|
|
199
205
|
|
|
200
206
|
This configuration depends on various packages to be available depending on the user settings for
|
|
201
|
-
each individual projects.
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
each individual projects.
|
|
208
|
+
You can list the required dependencies for the current configuration by running
|
|
209
|
+
`npx kxeslint-setup`.
|
|
210
|
+
You can also automatically install missing dependencies by adding the "auto" flag to the command.
|
|
204
211
|
|
|
205
212
|
All dependencies are set as peer dependencies, as they are almost all optional depending on local
|
|
206
213
|
settings.
|
|
@@ -210,8 +217,8 @@ The tool will also uninstall older dependencies that we used to have but are not
|
|
|
210
217
|
## Migration from .eslintrc.cjs
|
|
211
218
|
|
|
212
219
|
When running `npx kxeslint-setup`, the tool will automatically detect an existing `.eslintrc.cjs`
|
|
213
|
-
file and provides instructions for the migration.
|
|
214
|
-
update the new `eslint.config.js` file by hand.
|
|
220
|
+
file and provides instructions for the migration.
|
|
221
|
+
The migration process is manual; you have to update the new `eslint.config.js` file by hand.
|
|
215
222
|
|
|
216
223
|
## Debugging config issues
|
|
217
224
|
|
package/package.json
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@eslint/compat": "^1.2.6",
|
|
20
20
|
"@eslint/js": "^9.12.0",
|
|
21
|
-
"eslint": "^9.20.
|
|
22
|
-
"eslint-import-resolver-typescript": "^3.
|
|
21
|
+
"eslint": "^9.20.1",
|
|
22
|
+
"eslint-import-resolver-typescript": "^3.8.3",
|
|
23
23
|
"eslint-import-resolver-webpack": "^0.13.10",
|
|
24
24
|
"eslint-plugin-import-x": "^4.6.1",
|
|
25
25
|
"eslint-plugin-mocha": "^10.5.0",
|
|
@@ -27,16 +27,19 @@
|
|
|
27
27
|
"eslint-plugin-react": "^7.37.4",
|
|
28
28
|
"eslint-plugin-react-hooks": "^5.1.0",
|
|
29
29
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
30
|
-
"globals": "^
|
|
31
|
-
"prettier": "^3.5.
|
|
32
|
-
"typescript-eslint": "^8.24.
|
|
30
|
+
"globals": "^16.0.0",
|
|
31
|
+
"prettier": "^3.5.1",
|
|
32
|
+
"typescript-eslint": "^8.24.1"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": "./src/index.js",
|
|
36
|
+
"./prettier.config.js": "./prettier.config.js"
|
|
33
37
|
},
|
|
34
38
|
"files": [
|
|
35
39
|
"prettier.config.js",
|
|
36
40
|
"src"
|
|
37
41
|
],
|
|
38
42
|
"license": "MIT",
|
|
39
|
-
"main": "src/index.js",
|
|
40
43
|
"name": "@keeex/eslint-config",
|
|
41
44
|
"peerDependencies": {
|
|
42
45
|
"@eslint/compat": "^1.2.0",
|
|
@@ -50,7 +53,7 @@
|
|
|
50
53
|
"eslint-plugin-react": "7.x",
|
|
51
54
|
"eslint-plugin-react-hooks": "5.x",
|
|
52
55
|
"eslint-plugin-tsdoc": "0.x",
|
|
53
|
-
"globals": "15.x",
|
|
56
|
+
"globals": "15.x || 16.x",
|
|
54
57
|
"prettier": "3.x",
|
|
55
58
|
"typescript-eslint": "8.x"
|
|
56
59
|
},
|
|
@@ -113,5 +116,5 @@
|
|
|
113
116
|
"test": "echo No test for this project"
|
|
114
117
|
},
|
|
115
118
|
"type": "module",
|
|
116
|
-
"version": "2.
|
|
119
|
+
"version": "2.4.1"
|
|
117
120
|
}
|
package/prettier.config.js
CHANGED
package/src/config/mocha.js
CHANGED
|
@@ -21,8 +21,15 @@ export const apply = (configResult, eslintConfig) => {
|
|
|
21
21
|
"no-setup-in-describe": "off",
|
|
22
22
|
"prefer-arrow-callback": "off",
|
|
23
23
|
});
|
|
24
|
+
sections.configureRules(override, "mocha", {
|
|
25
|
+
"no-exports": "off",
|
|
26
|
+
"no-setup-in-describe": "off",
|
|
27
|
+
"no-top-level-hooks": "off",
|
|
28
|
+
});
|
|
24
29
|
if (eslintConfig.typescript) {
|
|
25
30
|
sections.configureRules(override, "@typescript-eslint", {
|
|
31
|
+
"explicit-function-return-type": "off",
|
|
32
|
+
"init-declarations": "off",
|
|
26
33
|
"max-params": "off",
|
|
27
34
|
"no-magic-numbers": "off",
|
|
28
35
|
});
|