eslint-config-decent 2.8.64 → 2.8.65

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
@@ -66,21 +66,6 @@ export default [
66
66
  ];
67
67
  ```
68
68
 
69
- ## Use typescript-eslint config
70
-
71
- ```mjs
72
- // eslint.config.mjs
73
-
74
- import { tsEslintConfig } from 'eslint-config-decent';
75
- import tsEslint from 'typescript-eslint';
76
-
77
- export default tsEslint(
78
- ...tsEslintConfig({
79
- tsconfigRootDir: import.meta.dirname,
80
- }),
81
- );
82
- ```
83
-
84
69
  ## License
85
70
 
86
71
  MIT
package/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const eslint = require('@eslint/js');
4
+ const config$1 = require('eslint/config');
4
5
  const prettier = require('eslint-plugin-prettier/recommended');
5
6
  const globals = require('globals');
6
7
  const tsEslint = require('typescript-eslint');
7
8
  const node_fs = require('node:fs');
8
9
  const node_path = require('node:path');
9
- const utils = require('@typescript-eslint/utils');
10
10
  const importPlugin = require('eslint-plugin-import-x');
11
11
  const jest = require('eslint-plugin-jest');
12
12
  const jestDom = require('eslint-plugin-jest-dom');
@@ -260,12 +260,12 @@ const configs$e = {
260
260
  cjs
261
261
  };
262
262
 
263
- const requireExtensionRule = utils.ESLintUtils.RuleCreator(() => "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireExtensionRule.ts")({
264
- name: "require-extension",
263
+ const requireExtensionRule = {
265
264
  meta: {
266
265
  type: "suggestion",
267
266
  docs: {
268
- description: "Ensure import and export statements include a file extension"
267
+ description: "Ensure import and export statements include a file extension",
268
+ url: "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireExtensionRule.ts"
269
269
  },
270
270
  fixable: "code",
271
271
  schema: [],
@@ -273,9 +273,11 @@ const requireExtensionRule = utils.ESLintUtils.RuleCreator(() => "https://github
273
273
  requireExtension: "Relative imports and exports must include a file extension."
274
274
  }
275
275
  },
276
- defaultOptions: [],
277
276
  create(context) {
278
277
  function checkSource(source) {
278
+ if (source?.type !== "Literal" || typeof source.value !== "string") {
279
+ return;
280
+ }
279
281
  const importPath = source.value;
280
282
  if (!importPath || !importPath.startsWith(".") || importPath.endsWith(".js")) {
281
283
  return;
@@ -294,43 +296,49 @@ const requireExtensionRule = utils.ESLintUtils.RuleCreator(() => "https://github
294
296
  }
295
297
  return {
296
298
  ImportDeclaration(node) {
297
- checkSource(node.source);
299
+ if (node.type === "ImportDeclaration") {
300
+ checkSource(node.source);
301
+ }
298
302
  },
299
303
  ExportNamedDeclaration(node) {
300
- if (node.source) {
304
+ if (node.type === "ExportNamedDeclaration" && node.source) {
301
305
  checkSource(node.source);
302
306
  }
303
307
  },
304
308
  ExportAllDeclaration(node) {
305
- checkSource(node.source);
309
+ if (node.type === "ExportAllDeclaration") {
310
+ checkSource(node.source);
311
+ }
306
312
  }
307
313
  };
308
314
  }
309
- });
315
+ };
310
316
 
311
- const requireIndexRule = utils.ESLintUtils.RuleCreator(() => "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireIndexRule.ts")({
312
- name: "require-index",
317
+ const requireIndexRule = {
313
318
  meta: {
314
319
  type: "suggestion",
315
320
  docs: {
316
- description: "Ensure directory import and export statements use index.js"
321
+ description: "Ensure directory import and export statements use index.js",
322
+ url: "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireIndexRule.ts"
317
323
  },
318
324
  fixable: "code",
319
325
  schema: [],
320
326
  messages: {
321
- requireExtension: "Directory imports and exports must use index.js."
327
+ requireIndex: "Directory imports and exports must use index.js."
322
328
  }
323
329
  },
324
- defaultOptions: [],
325
330
  create(context) {
326
331
  function checkSource(source) {
332
+ if (source?.type !== "Literal" || typeof source.value !== "string") {
333
+ return;
334
+ }
327
335
  const importPath = source.value;
328
336
  const resolvedPath = node_path.resolve(node_path.dirname(context.filename), importPath);
329
337
  const isDirectory = node_fs.existsSync(resolvedPath) && node_fs.lstatSync(resolvedPath).isDirectory();
330
338
  if (isDirectory) {
331
339
  context.report({
332
340
  node: source,
333
- messageId: "requireExtension",
341
+ messageId: "requireIndex",
334
342
  fix(fixer) {
335
343
  const fixedPath = importPath.replace(/\/?$/, "/index.js");
336
344
  return fixer.replaceText(source, `'${fixedPath}'`);
@@ -340,19 +348,23 @@ const requireIndexRule = utils.ESLintUtils.RuleCreator(() => "https://github.com
340
348
  }
341
349
  return {
342
350
  ImportDeclaration(node) {
343
- checkSource(node.source);
351
+ if (node.type === "ImportDeclaration") {
352
+ checkSource(node.source);
353
+ }
344
354
  },
345
355
  ExportNamedDeclaration(node) {
346
- if (node.source) {
356
+ if (node.type === "ExportNamedDeclaration" && node.source) {
347
357
  checkSource(node.source);
348
358
  }
349
359
  },
350
360
  ExportAllDeclaration(node) {
351
- checkSource(node.source);
361
+ if (node.type === "ExportAllDeclaration") {
362
+ checkSource(node.source);
363
+ }
352
364
  }
353
365
  };
354
366
  }
355
- });
367
+ };
356
368
 
357
369
  const base$d = {
358
370
  plugins: {
@@ -563,7 +575,7 @@ const base$6 = {
563
575
  plugins: {
564
576
  "jsx-a11y": a11y__default,
565
577
  react: react__default,
566
- "react-hooks": compat.fixupPluginRules(reactHooks__default)
578
+ "react-hooks": reactHooks__default
567
579
  },
568
580
  rules: {
569
581
  ...a11y__default.configs.recommended.rules,
@@ -848,8 +860,10 @@ const configs = {
848
860
  base
849
861
  };
850
862
 
851
- const defaultConfig = tsEslintConfig;
852
863
  function tsEslintConfig(options) {
864
+ return decentConfig(options);
865
+ }
866
+ function decentConfig(options) {
853
867
  const enableRequireExtensionRule = options?.enableRequireExtensionRule ?? true;
854
868
  const enableJest = options?.enableJest ?? true;
855
869
  const enableVitest = options?.enableVitest ?? true;
@@ -1028,11 +1042,10 @@ function tsEslintConfig(options) {
1028
1042
  ];
1029
1043
  }
1030
1044
  function config(options) {
1031
- return tsEslint__default.config(...tsEslintConfig(options));
1045
+ return config$1.defineConfig(...decentConfig(options));
1032
1046
  }
1033
1047
 
1034
1048
  exports.config = config;
1035
- exports.defaultConfig = defaultConfig;
1036
1049
  exports.eslintConfigs = configs$e;
1037
1050
  exports.extensionConfigs = configs$d;
1038
1051
  exports.importConfigs = configs$c;
package/dist/index.d.cts CHANGED
@@ -1,62 +1,63 @@
1
- import { TSESLint } from '@typescript-eslint/utils';
2
- import { ConfigWithExtends } from 'typescript-eslint';
1
+ import { ConfigWithExtends, Config } from '@eslint/config-helpers';
2
+ import * as node_modules__eslint_config_helpers_dist_esm_types_js from 'node_modules/@eslint/config-helpers/dist/esm/types.js';
3
+ import * as _eslint_core from '@eslint/core';
3
4
 
4
5
  declare const configs$d: {
5
- base: TSESLint.FlatConfig.Config;
6
- cjsAndEsm: TSESLint.FlatConfig.Config;
7
- cjs: TSESLint.FlatConfig.Config;
6
+ base: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
7
+ cjsAndEsm: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
8
+ cjs: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
8
9
  };
9
10
 
10
11
  declare const configs$c: {
11
- base: TSESLint.FlatConfig.Config;
12
+ base: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
12
13
  };
13
14
 
14
15
  declare const configs$b: {
15
- base: TSESLint.FlatConfig.Config;
16
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
16
17
  };
17
18
 
18
19
  declare const configs$a: {
19
- base: TSESLint.FlatConfig.Config;
20
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
20
21
  };
21
22
 
22
23
  declare const configs$9: {
23
- base: TSESLint.FlatConfig.Config;
24
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
24
25
  };
25
26
 
26
27
  declare const configs$8: {
27
- base: TSESLint.FlatConfig.Config;
28
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
28
29
  };
29
30
 
30
31
  declare const configs$7: {
31
- base: TSESLint.FlatConfig.Config;
32
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
32
33
  };
33
34
 
34
35
  declare const configs$6: {
35
- base: TSESLint.FlatConfig.Config;
36
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
36
37
  };
37
38
 
38
39
  declare const configs$5: {
39
- base: TSESLint.FlatConfig.Config;
40
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
40
41
  };
41
42
 
42
43
  declare const configs$4: {
43
- base: TSESLint.FlatConfig.Config;
44
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
44
45
  };
45
46
 
46
47
  declare const configs$3: {
47
- base: TSESLint.FlatConfig.Config;
48
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
48
49
  };
49
50
 
50
51
  declare const configs$2: {
51
- base: TSESLint.FlatConfig.Config;
52
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
52
53
  };
53
54
 
54
55
  declare const configs$1: {
55
- base: TSESLint.FlatConfig.Config;
56
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
56
57
  };
57
58
 
58
59
  declare const configs: {
59
- base: TSESLint.FlatConfig.Config;
60
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
60
61
  };
61
62
 
62
63
  interface DefaultConfigOptions {
@@ -72,13 +73,10 @@ interface DefaultConfigOptions {
72
73
  enableTestingLibrary?: boolean;
73
74
  }
74
75
  /**
75
- * @deprecated Use `tsEslintConfig` instead
76
- */
77
- declare const defaultConfig: typeof tsEslintConfig;
78
- /**
79
- * Exports the default configuration to be passed to `tsEslint.config`. Use this if you want more control of typescript-eslint configuration output.
76
+ * Exports the default configuration to be passed to `defineConfig` from eslint. Use this if you want more control of the configuration output.
80
77
  * @param {DefaultConfigOptions} options
81
78
  * @returns Array of typescript-eslint configurations
79
+ * @deprecated Will be removed in the future
82
80
  */
83
81
  declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExtends[];
84
82
  /**
@@ -86,7 +84,7 @@ declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExten
86
84
  * @param {object} options
87
85
  * @returns An array of eslint configurations
88
86
  */
89
- declare function config(options?: DefaultConfigOptions): TSESLint.FlatConfig.ConfigArray;
87
+ declare function config(options?: DefaultConfigOptions): Config[];
90
88
 
91
- export { config, defaultConfig, configs$d as eslintConfigs, configs$c as extensionConfigs, configs$b as importConfigs, configs$a as jestConfigs, configs$9 as jsdocConfigs, configs$8 as mochaConfigs, configs$7 as nextJsConfigs, configs$6 as promiseConfigs, configs$5 as reactConfigs, configs$4 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };
89
+ export { config, configs$d as eslintConfigs, configs$c as extensionConfigs, configs$b as importConfigs, configs$a as jestConfigs, configs$9 as jsdocConfigs, configs$8 as mochaConfigs, configs$7 as nextJsConfigs, configs$6 as promiseConfigs, configs$5 as reactConfigs, configs$4 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };
92
90
  export type { DefaultConfigOptions };
package/dist/index.d.mts CHANGED
@@ -1,62 +1,63 @@
1
- import { TSESLint } from '@typescript-eslint/utils';
2
- import { ConfigWithExtends } from 'typescript-eslint';
1
+ import { ConfigWithExtends, Config } from '@eslint/config-helpers';
2
+ import * as node_modules__eslint_config_helpers_dist_esm_types_js from 'node_modules/@eslint/config-helpers/dist/esm/types.js';
3
+ import * as _eslint_core from '@eslint/core';
3
4
 
4
5
  declare const configs$d: {
5
- base: TSESLint.FlatConfig.Config;
6
- cjsAndEsm: TSESLint.FlatConfig.Config;
7
- cjs: TSESLint.FlatConfig.Config;
6
+ base: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
7
+ cjsAndEsm: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
8
+ cjs: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
8
9
  };
9
10
 
10
11
  declare const configs$c: {
11
- base: TSESLint.FlatConfig.Config;
12
+ base: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
12
13
  };
13
14
 
14
15
  declare const configs$b: {
15
- base: TSESLint.FlatConfig.Config;
16
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
16
17
  };
17
18
 
18
19
  declare const configs$a: {
19
- base: TSESLint.FlatConfig.Config;
20
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
20
21
  };
21
22
 
22
23
  declare const configs$9: {
23
- base: TSESLint.FlatConfig.Config;
24
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
24
25
  };
25
26
 
26
27
  declare const configs$8: {
27
- base: TSESLint.FlatConfig.Config;
28
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
28
29
  };
29
30
 
30
31
  declare const configs$7: {
31
- base: TSESLint.FlatConfig.Config;
32
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
32
33
  };
33
34
 
34
35
  declare const configs$6: {
35
- base: TSESLint.FlatConfig.Config;
36
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
36
37
  };
37
38
 
38
39
  declare const configs$5: {
39
- base: TSESLint.FlatConfig.Config;
40
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
40
41
  };
41
42
 
42
43
  declare const configs$4: {
43
- base: TSESLint.FlatConfig.Config;
44
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
44
45
  };
45
46
 
46
47
  declare const configs$3: {
47
- base: TSESLint.FlatConfig.Config;
48
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
48
49
  };
49
50
 
50
51
  declare const configs$2: {
51
- base: TSESLint.FlatConfig.Config;
52
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
52
53
  };
53
54
 
54
55
  declare const configs$1: {
55
- base: TSESLint.FlatConfig.Config;
56
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
56
57
  };
57
58
 
58
59
  declare const configs: {
59
- base: TSESLint.FlatConfig.Config;
60
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
60
61
  };
61
62
 
62
63
  interface DefaultConfigOptions {
@@ -72,13 +73,10 @@ interface DefaultConfigOptions {
72
73
  enableTestingLibrary?: boolean;
73
74
  }
74
75
  /**
75
- * @deprecated Use `tsEslintConfig` instead
76
- */
77
- declare const defaultConfig: typeof tsEslintConfig;
78
- /**
79
- * Exports the default configuration to be passed to `tsEslint.config`. Use this if you want more control of typescript-eslint configuration output.
76
+ * Exports the default configuration to be passed to `defineConfig` from eslint. Use this if you want more control of the configuration output.
80
77
  * @param {DefaultConfigOptions} options
81
78
  * @returns Array of typescript-eslint configurations
79
+ * @deprecated Will be removed in the future
82
80
  */
83
81
  declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExtends[];
84
82
  /**
@@ -86,7 +84,7 @@ declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExten
86
84
  * @param {object} options
87
85
  * @returns An array of eslint configurations
88
86
  */
89
- declare function config(options?: DefaultConfigOptions): TSESLint.FlatConfig.ConfigArray;
87
+ declare function config(options?: DefaultConfigOptions): Config[];
90
88
 
91
- export { config, defaultConfig, configs$d as eslintConfigs, configs$c as extensionConfigs, configs$b as importConfigs, configs$a as jestConfigs, configs$9 as jsdocConfigs, configs$8 as mochaConfigs, configs$7 as nextJsConfigs, configs$6 as promiseConfigs, configs$5 as reactConfigs, configs$4 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };
89
+ export { config, configs$d as eslintConfigs, configs$c as extensionConfigs, configs$b as importConfigs, configs$a as jestConfigs, configs$9 as jsdocConfigs, configs$8 as mochaConfigs, configs$7 as nextJsConfigs, configs$6 as promiseConfigs, configs$5 as reactConfigs, configs$4 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };
92
90
  export type { DefaultConfigOptions };
package/dist/index.d.ts CHANGED
@@ -1,62 +1,63 @@
1
- import { TSESLint } from '@typescript-eslint/utils';
2
- import { ConfigWithExtends } from 'typescript-eslint';
1
+ import { ConfigWithExtends, Config } from '@eslint/config-helpers';
2
+ import * as node_modules__eslint_config_helpers_dist_esm_types_js from 'node_modules/@eslint/config-helpers/dist/esm/types.js';
3
+ import * as _eslint_core from '@eslint/core';
3
4
 
4
5
  declare const configs$d: {
5
- base: TSESLint.FlatConfig.Config;
6
- cjsAndEsm: TSESLint.FlatConfig.Config;
7
- cjs: TSESLint.FlatConfig.Config;
6
+ base: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
7
+ cjsAndEsm: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
8
+ cjs: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
8
9
  };
9
10
 
10
11
  declare const configs$c: {
11
- base: TSESLint.FlatConfig.Config;
12
+ base: node_modules__eslint_config_helpers_dist_esm_types_js.ConfigWithExtends;
12
13
  };
13
14
 
14
15
  declare const configs$b: {
15
- base: TSESLint.FlatConfig.Config;
16
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
16
17
  };
17
18
 
18
19
  declare const configs$a: {
19
- base: TSESLint.FlatConfig.Config;
20
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
20
21
  };
21
22
 
22
23
  declare const configs$9: {
23
- base: TSESLint.FlatConfig.Config;
24
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
24
25
  };
25
26
 
26
27
  declare const configs$8: {
27
- base: TSESLint.FlatConfig.Config;
28
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
28
29
  };
29
30
 
30
31
  declare const configs$7: {
31
- base: TSESLint.FlatConfig.Config;
32
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
32
33
  };
33
34
 
34
35
  declare const configs$6: {
35
- base: TSESLint.FlatConfig.Config;
36
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
36
37
  };
37
38
 
38
39
  declare const configs$5: {
39
- base: TSESLint.FlatConfig.Config;
40
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
40
41
  };
41
42
 
42
43
  declare const configs$4: {
43
- base: TSESLint.FlatConfig.Config;
44
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
44
45
  };
45
46
 
46
47
  declare const configs$3: {
47
- base: TSESLint.FlatConfig.Config;
48
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
48
49
  };
49
50
 
50
51
  declare const configs$2: {
51
- base: TSESLint.FlatConfig.Config;
52
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
52
53
  };
53
54
 
54
55
  declare const configs$1: {
55
- base: TSESLint.FlatConfig.Config;
56
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
56
57
  };
57
58
 
58
59
  declare const configs: {
59
- base: TSESLint.FlatConfig.Config;
60
+ base: _eslint_core.ConfigObject<_eslint_core.RulesConfig>;
60
61
  };
61
62
 
62
63
  interface DefaultConfigOptions {
@@ -72,13 +73,10 @@ interface DefaultConfigOptions {
72
73
  enableTestingLibrary?: boolean;
73
74
  }
74
75
  /**
75
- * @deprecated Use `tsEslintConfig` instead
76
- */
77
- declare const defaultConfig: typeof tsEslintConfig;
78
- /**
79
- * Exports the default configuration to be passed to `tsEslint.config`. Use this if you want more control of typescript-eslint configuration output.
76
+ * Exports the default configuration to be passed to `defineConfig` from eslint. Use this if you want more control of the configuration output.
80
77
  * @param {DefaultConfigOptions} options
81
78
  * @returns Array of typescript-eslint configurations
79
+ * @deprecated Will be removed in the future
82
80
  */
83
81
  declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExtends[];
84
82
  /**
@@ -86,7 +84,7 @@ declare function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExten
86
84
  * @param {object} options
87
85
  * @returns An array of eslint configurations
88
86
  */
89
- declare function config(options?: DefaultConfigOptions): TSESLint.FlatConfig.ConfigArray;
87
+ declare function config(options?: DefaultConfigOptions): Config[];
90
88
 
91
- export { config, defaultConfig, configs$d as eslintConfigs, configs$c as extensionConfigs, configs$b as importConfigs, configs$a as jestConfigs, configs$9 as jsdocConfigs, configs$8 as mochaConfigs, configs$7 as nextJsConfigs, configs$6 as promiseConfigs, configs$5 as reactConfigs, configs$4 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };
89
+ export { config, configs$d as eslintConfigs, configs$c as extensionConfigs, configs$b as importConfigs, configs$a as jestConfigs, configs$9 as jsdocConfigs, configs$8 as mochaConfigs, configs$7 as nextJsConfigs, configs$6 as promiseConfigs, configs$5 as reactConfigs, configs$4 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };
92
90
  export type { DefaultConfigOptions };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import eslint from '@eslint/js';
2
+ import { defineConfig } from 'eslint/config';
2
3
  import prettier from 'eslint-plugin-prettier/recommended';
3
4
  import globals from 'globals';
4
5
  import tsEslint from 'typescript-eslint';
5
6
  import { existsSync, lstatSync } from 'node:fs';
6
7
  import { resolve, dirname } from 'node:path';
7
- import { ESLintUtils } from '@typescript-eslint/utils';
8
8
  import importPlugin from 'eslint-plugin-import-x';
9
9
  import jest from 'eslint-plugin-jest';
10
10
  import jestDom from 'eslint-plugin-jest-dom';
@@ -236,12 +236,12 @@ const configs$e = {
236
236
  cjs
237
237
  };
238
238
 
239
- const requireExtensionRule = ESLintUtils.RuleCreator(() => "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireExtensionRule.ts")({
240
- name: "require-extension",
239
+ const requireExtensionRule = {
241
240
  meta: {
242
241
  type: "suggestion",
243
242
  docs: {
244
- description: "Ensure import and export statements include a file extension"
243
+ description: "Ensure import and export statements include a file extension",
244
+ url: "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireExtensionRule.ts"
245
245
  },
246
246
  fixable: "code",
247
247
  schema: [],
@@ -249,9 +249,11 @@ const requireExtensionRule = ESLintUtils.RuleCreator(() => "https://github.com/j
249
249
  requireExtension: "Relative imports and exports must include a file extension."
250
250
  }
251
251
  },
252
- defaultOptions: [],
253
252
  create(context) {
254
253
  function checkSource(source) {
254
+ if (source?.type !== "Literal" || typeof source.value !== "string") {
255
+ return;
256
+ }
255
257
  const importPath = source.value;
256
258
  if (!importPath || !importPath.startsWith(".") || importPath.endsWith(".js")) {
257
259
  return;
@@ -270,43 +272,49 @@ const requireExtensionRule = ESLintUtils.RuleCreator(() => "https://github.com/j
270
272
  }
271
273
  return {
272
274
  ImportDeclaration(node) {
273
- checkSource(node.source);
275
+ if (node.type === "ImportDeclaration") {
276
+ checkSource(node.source);
277
+ }
274
278
  },
275
279
  ExportNamedDeclaration(node) {
276
- if (node.source) {
280
+ if (node.type === "ExportNamedDeclaration" && node.source) {
277
281
  checkSource(node.source);
278
282
  }
279
283
  },
280
284
  ExportAllDeclaration(node) {
281
- checkSource(node.source);
285
+ if (node.type === "ExportAllDeclaration") {
286
+ checkSource(node.source);
287
+ }
282
288
  }
283
289
  };
284
290
  }
285
- });
291
+ };
286
292
 
287
- const requireIndexRule = ESLintUtils.RuleCreator(() => "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireIndexRule.ts")({
288
- name: "require-index",
293
+ const requireIndexRule = {
289
294
  meta: {
290
295
  type: "suggestion",
291
296
  docs: {
292
- description: "Ensure directory import and export statements use index.js"
297
+ description: "Ensure directory import and export statements use index.js",
298
+ url: "https://github.com/jgeurts/eslint-config-decent/tree/main/src/rules/requireIndexRule.ts"
293
299
  },
294
300
  fixable: "code",
295
301
  schema: [],
296
302
  messages: {
297
- requireExtension: "Directory imports and exports must use index.js."
303
+ requireIndex: "Directory imports and exports must use index.js."
298
304
  }
299
305
  },
300
- defaultOptions: [],
301
306
  create(context) {
302
307
  function checkSource(source) {
308
+ if (source?.type !== "Literal" || typeof source.value !== "string") {
309
+ return;
310
+ }
303
311
  const importPath = source.value;
304
312
  const resolvedPath = resolve(dirname(context.filename), importPath);
305
313
  const isDirectory = existsSync(resolvedPath) && lstatSync(resolvedPath).isDirectory();
306
314
  if (isDirectory) {
307
315
  context.report({
308
316
  node: source,
309
- messageId: "requireExtension",
317
+ messageId: "requireIndex",
310
318
  fix(fixer) {
311
319
  const fixedPath = importPath.replace(/\/?$/, "/index.js");
312
320
  return fixer.replaceText(source, `'${fixedPath}'`);
@@ -316,19 +324,23 @@ const requireIndexRule = ESLintUtils.RuleCreator(() => "https://github.com/jgeur
316
324
  }
317
325
  return {
318
326
  ImportDeclaration(node) {
319
- checkSource(node.source);
327
+ if (node.type === "ImportDeclaration") {
328
+ checkSource(node.source);
329
+ }
320
330
  },
321
331
  ExportNamedDeclaration(node) {
322
- if (node.source) {
332
+ if (node.type === "ExportNamedDeclaration" && node.source) {
323
333
  checkSource(node.source);
324
334
  }
325
335
  },
326
336
  ExportAllDeclaration(node) {
327
- checkSource(node.source);
337
+ if (node.type === "ExportAllDeclaration") {
338
+ checkSource(node.source);
339
+ }
328
340
  }
329
341
  };
330
342
  }
331
- });
343
+ };
332
344
 
333
345
  const base$d = {
334
346
  plugins: {
@@ -539,7 +551,7 @@ const base$6 = {
539
551
  plugins: {
540
552
  "jsx-a11y": a11y,
541
553
  react,
542
- "react-hooks": fixupPluginRules(reactHooks)
554
+ "react-hooks": reactHooks
543
555
  },
544
556
  rules: {
545
557
  ...a11y.configs.recommended.rules,
@@ -824,8 +836,10 @@ const configs = {
824
836
  base
825
837
  };
826
838
 
827
- const defaultConfig = tsEslintConfig;
828
839
  function tsEslintConfig(options) {
840
+ return decentConfig(options);
841
+ }
842
+ function decentConfig(options) {
829
843
  const enableRequireExtensionRule = options?.enableRequireExtensionRule ?? true;
830
844
  const enableJest = options?.enableJest ?? true;
831
845
  const enableVitest = options?.enableVitest ?? true;
@@ -1004,7 +1018,7 @@ function tsEslintConfig(options) {
1004
1018
  ];
1005
1019
  }
1006
1020
  function config(options) {
1007
- return tsEslint.config(...tsEslintConfig(options));
1021
+ return defineConfig(...decentConfig(options));
1008
1022
  }
1009
1023
 
1010
- export { config, defaultConfig, configs$e as eslintConfigs, configs$d as extensionConfigs, configs$c as importConfigs, configs$b as jestConfigs, configs$a as jsdocConfigs, configs$9 as mochaConfigs, configs$8 as nextJsConfigs, configs$7 as promiseConfigs, configs$6 as reactConfigs, configs$5 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };
1024
+ export { config, configs$e as eslintConfigs, configs$d as extensionConfigs, configs$c as importConfigs, configs$b as jestConfigs, configs$a as jsdocConfigs, configs$9 as mochaConfigs, configs$8 as nextJsConfigs, configs$7 as promiseConfigs, configs$6 as reactConfigs, configs$5 as securityConfigs, configs$3 as testingLibraryConfigs, tsEslintConfig, configs$2 as typescriptEslintConfigs, configs$1 as unicornConfigs, configs as vitestConfigs };