@keeex/eslint-config 1.8.2 → 1.9.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 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.8.2",
4
+ "version": "1.9.0",
5
5
  "main": "src/index.js",
6
6
  "files": [
7
7
  "src/**/*.js"
@@ -23,22 +23,23 @@
23
23
  ],
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "eslint": "^8.5.0",
27
- "eslint-plugin-import": "^2.23.4",
28
- "eslint-plugin-promise": "^6.0.0"
26
+ "eslint": "^8.28.0",
27
+ "eslint-plugin-import": "^2.26.0",
28
+ "eslint-plugin-promise": "^6.1.1"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@typescript-eslint/eslint-plugin": "5.x",
32
32
  "@typescript-eslint/parser": "5.x",
33
33
  "eslint": "8.x",
34
+ "eslint-import-resolver-typescript": "2.x",
35
+ "eslint-plugin-chai-friendly": "0.x",
36
+ "eslint-plugin-deprecation": "^1.3.3",
34
37
  "eslint-plugin-import": "2.x",
35
38
  "eslint-plugin-mocha": "10.x",
36
- "eslint-plugin-chai-friendly": "0.x",
37
39
  "eslint-plugin-promise": "6.x",
38
40
  "eslint-plugin-react": "7.x",
39
41
  "eslint-plugin-react-hooks": "4.x",
40
- "eslint-plugin-react-native": "4.x",
41
- "eslint-import-resolver-typescript": "2.x"
42
+ "eslint-plugin-react-native": "4.x"
42
43
  },
43
44
  "peerDependenciesMeta": {
44
45
  "eslint": {
@@ -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
  },
@@ -171,6 +171,7 @@ module.exports = {
171
171
  "warn",
172
172
  {
173
173
  "skipBlankLines": true,
174
+ "skipComments": true,
174
175
  "IIFEs": true,
175
176
  },
176
177
  ],
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ plugins: (presetSettings, allOptions) => {
3
+ if (typeof allOptions.typescript !== "string") return undefined;
4
+ return ["deprecation"];
5
+ },
6
+ rules: {},
7
+ };
@@ -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": [
@@ -66,7 +72,6 @@ const rulesBase = {
66
72
 
67
73
  "public-abstract-field",
68
74
  "protected-abstract-field",
69
- "private-abstract-field",
70
75
 
71
76
  "public-field",
72
77
  "protected-field",
@@ -102,7 +107,6 @@ const rulesBase = {
102
107
 
103
108
  ["public-abstract-get", "public-abstract-set"],
104
109
  ["protected-abstract-get", "protected-abstract-set"],
105
- ["private-abstract-get", "private-abstract-set"],
106
110
 
107
111
  ["public-get", "public-set"],
108
112
  ["protected-get", "protected-set"],
@@ -131,7 +135,6 @@ const rulesBase = {
131
135
 
132
136
  "public-abstract-method",
133
137
  "protected-abstract-method",
134
- "private-abstract-method",
135
138
 
136
139
  "public-method",
137
140
  "protected-method",
@@ -290,10 +293,14 @@ module.exports = {
290
293
  const typesOverride = useTypes(presetOptions)
291
294
  ? rulesType
292
295
  : undefined;
296
+ const deprecationOverride = useDeprecation(presetOptions, allOptions)
297
+ ? {"deprecation/deprecation": "warn"}
298
+ : undefined;
293
299
  return {
294
300
  ...rulesBase,
295
301
  ...typesOverride,
296
302
  ...importOverride,
303
+ ...deprecationOverride,
297
304
  };
298
305
  },
299
306
  },
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 = [...presetPlugins];
64
+ config.plugins = [...newPlugins];
63
65
  return;
64
66
  }
65
- presetPlugins.forEach(newPlugin => {
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;