@keeex/eslint-config 1.8.3 → 1.9.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 +6 -0
- package/package.json +7 -3
- package/src/config/base.js +2 -0
- package/src/config/deprecation.js +7 -0
- package/src/config/typescript.js +12 -0
- package/src/index.js +9 -4
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ module.exports = eslintConfig(
|
|
|
24
24
|
reacthooks: true,
|
|
25
25
|
reactnative: true,
|
|
26
26
|
typescript: "./tsconfig.json",
|
|
27
|
+
deprecation: true,
|
|
27
28
|
mocha: true,
|
|
28
29
|
},
|
|
29
30
|
{
|
|
@@ -107,6 +108,10 @@ Instead, it is advised to provide the path to the typescript configuration file
|
|
|
107
108
|
(typically `tsconfig.json`), in which case rules that requires typing
|
|
108
109
|
informations are enabled.
|
|
109
110
|
|
|
111
|
+
### Deprecation
|
|
112
|
+
Warn when using deprecated calls/properties.
|
|
113
|
+
This only work with TypeScript enabled with project types.
|
|
114
|
+
|
|
110
115
|
### React/JSX
|
|
111
116
|
To improve handling of React/JSX, set `jsx` to true.
|
|
112
117
|
It is also possible to pass a string indicating the expected React version.
|
|
@@ -153,6 +158,7 @@ Dependencies
|
|
|
153
158
|
Depend on `eslint`.
|
|
154
159
|
If typescript is enabled, `@typescript-eslint/eslint-plugin`,
|
|
155
160
|
`@typescript-eslint/parser` must be installed.
|
|
161
|
+
If deprecation is enabled, `eslint-plugin-deprecation` must be installed.
|
|
156
162
|
If React/JSX is enabled, `eslint-plugin-react` must be installed.
|
|
157
163
|
If React Hooks is enabled, `eslint-plugin-react-hooks` must be installed.
|
|
158
164
|
If React Native is enabled, `eslint-plugin-react-native` must be installed.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keeex/eslint-config",
|
|
3
3
|
"description": "Common eslint configuration",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.1",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"src/**/*.js"
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"eslint": "^8.
|
|
27
|
-
"eslint-plugin-import": "^2.
|
|
26
|
+
"eslint": "^8.32.0",
|
|
27
|
+
"eslint-plugin-import": "^2.27.5",
|
|
28
28
|
"eslint-plugin-promise": "^6.1.1"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"eslint": "8.x",
|
|
34
34
|
"eslint-import-resolver-typescript": "2.x",
|
|
35
35
|
"eslint-plugin-chai-friendly": "0.x",
|
|
36
|
+
"eslint-plugin-deprecation": "^1.3.3",
|
|
36
37
|
"eslint-plugin-import": "2.x",
|
|
37
38
|
"eslint-plugin-mocha": "10.x",
|
|
38
39
|
"eslint-plugin-promise": "6.x",
|
|
@@ -65,6 +66,9 @@
|
|
|
65
66
|
"eslint-plugin-chai-friendly": {
|
|
66
67
|
"optional": true
|
|
67
68
|
},
|
|
69
|
+
"eslint-plugin-deprecation": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
68
72
|
"eslint-plugin-react-hooks": {
|
|
69
73
|
"optional": true
|
|
70
74
|
},
|
package/src/config/base.js
CHANGED
package/src/config/typescript.js
CHANGED
|
@@ -8,6 +8,12 @@ const {
|
|
|
8
8
|
* Check if types-based rules can be used
|
|
9
9
|
*/
|
|
10
10
|
const useTypes = presetOptions => typeof presetOptions === "string";
|
|
11
|
+
const useDeprecation = (presetOptions, allOptions) => {
|
|
12
|
+
if (!useTypes(presetOptions)) return false;
|
|
13
|
+
const deprecationKey = "deprecation";
|
|
14
|
+
if (!(deprecationKey in allOptions)) return true;
|
|
15
|
+
return allOptions[deprecationKey] === true;
|
|
16
|
+
};
|
|
11
17
|
|
|
12
18
|
const rulesBase = {
|
|
13
19
|
"@typescript-eslint/array-type": [
|
|
@@ -184,6 +190,8 @@ const rulesBase = {
|
|
|
184
190
|
],
|
|
185
191
|
"ignoreDefaultValues": true,
|
|
186
192
|
"ignoreArrayIndexes": true,
|
|
193
|
+
"ignoreDefaultValues": true,
|
|
194
|
+
"ignoreClassFieldInitialValues": true,
|
|
187
195
|
},
|
|
188
196
|
],
|
|
189
197
|
"no-shadow": "off",
|
|
@@ -287,10 +295,14 @@ module.exports = {
|
|
|
287
295
|
const typesOverride = useTypes(presetOptions)
|
|
288
296
|
? rulesType
|
|
289
297
|
: undefined;
|
|
298
|
+
const deprecationOverride = useDeprecation(presetOptions, allOptions)
|
|
299
|
+
? {"deprecation/deprecation": "warn"}
|
|
300
|
+
: undefined;
|
|
290
301
|
return {
|
|
291
302
|
...rulesBase,
|
|
292
303
|
...typesOverride,
|
|
293
304
|
...importOverride,
|
|
305
|
+
...deprecationOverride,
|
|
294
306
|
};
|
|
295
307
|
},
|
|
296
308
|
},
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const cfgImport = require("./config/import.js");
|
|
|
4
4
|
const cfgReactHooks = require("./config/reacthooks.js");
|
|
5
5
|
const cfgReactNative = require("./config/reactnative.js");
|
|
6
6
|
const cfgTypescript = require("./config/typescript.js");
|
|
7
|
+
const cfgDeprecation = require("./config/deprecation.js");
|
|
7
8
|
const cfgPromise = require("./config/promise.js");
|
|
8
9
|
const cfgMocha = require("./config/mocha.js");
|
|
9
10
|
|
|
@@ -54,15 +55,16 @@ const addPlugins = (
|
|
|
54
55
|
config,
|
|
55
56
|
presetPlugins,
|
|
56
57
|
presetConfig,
|
|
58
|
+
allOptions,
|
|
57
59
|
) => {
|
|
58
|
-
const newPlugins = applyConfig(presetPlugins, presetConfig);
|
|
60
|
+
const newPlugins = applyConfig(presetPlugins, presetConfig, allOptions);
|
|
59
61
|
if (!newPlugins) return;
|
|
60
62
|
|
|
61
63
|
if (!config.plugins) {
|
|
62
|
-
config.plugins = [...
|
|
64
|
+
config.plugins = [...newPlugins];
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
newPlugins.forEach(newPlugin => {
|
|
66
68
|
if (config.plugins.includes(newPlugin)) return;
|
|
67
69
|
|
|
68
70
|
config.plugins.push(newPlugin);
|
|
@@ -201,6 +203,7 @@ const presets = {
|
|
|
201
203
|
"reacthooks": cfgReactHooks,
|
|
202
204
|
"reactnative": cfgReactNative,
|
|
203
205
|
"typescript": cfgTypescript,
|
|
206
|
+
"deprecation": cfgDeprecation,
|
|
204
207
|
"mocha": cfgMocha,
|
|
205
208
|
};
|
|
206
209
|
|
|
@@ -213,6 +216,7 @@ const presetsOrder = [
|
|
|
213
216
|
"reactnative",
|
|
214
217
|
"reacthooks",
|
|
215
218
|
"typescript",
|
|
219
|
+
"deprecation",
|
|
216
220
|
"mocha",
|
|
217
221
|
];
|
|
218
222
|
|
|
@@ -229,7 +233,7 @@ const mergePreset = (
|
|
|
229
233
|
addParserOptions(config, presetDef.parserOptions, presetConfig);
|
|
230
234
|
addSettings(config, presetDef.settings, presetConfig, allOptions);
|
|
231
235
|
addEnvs(config, presetDef.env, presetConfig);
|
|
232
|
-
addPlugins(config, presetDef.plugins, presetConfig);
|
|
236
|
+
addPlugins(config, presetDef.plugins, presetConfig, allOptions);
|
|
233
237
|
addExtends(config, presetDef.extendsBase, presetConfig, allOptions);
|
|
234
238
|
addRules(config, presetDef.rules, presetConfig, allOptions);
|
|
235
239
|
if (presetDef.overrides) {
|
|
@@ -275,6 +279,7 @@ module.exports = (
|
|
|
275
279
|
if (config.base === undefined) config.base = true;
|
|
276
280
|
if (config.promise === undefined) config.promise = true;
|
|
277
281
|
if (config.import === undefined) config.import = true;
|
|
282
|
+
if (config.deprecation === undefined) config.deprecation = true;
|
|
278
283
|
|
|
279
284
|
mergeAllPresets(result, config);
|
|
280
285
|
return result;
|