@pob/eslint-config 56.1.0 → 57.0.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/CHANGELOG.md +6 -84
- package/lib/_base.js +39 -17
- package/lib/base/commonjs.js +8 -4
- package/lib/base/module.js +22 -4
- package/lib/index.js +67 -13
- package/lib/node/_base.js +10 -18
- package/lib/node/commonjs.js +13 -23
- package/lib/node/module.js +21 -30
- package/lib/plugins/import/import-base.js +105 -72
- package/lib/plugins/import/import-commonjs.js +1 -3
- package/lib/plugins/import/import-module.js +1 -3
- package/lib/plugins/unicorn.js +238 -239
- package/lib/rules/best-practices.js +11 -5
- package/lib/rules/code-quality.js +1 -3
- package/lib/rules/dev-only.js +3 -3
- package/lib/rules/errors.js +1 -3
- package/lib/rules/style.js +1 -3
- package/package.json +9 -9
- package/utils.js +1 -3
- package/lib/.eslintrc.json +0 -4
- package/lib/node-commonjs.js +0 -25
- package/lib/node-module.js +0 -25
- package/lib/root-commonjs.js +0 -6
- package/lib/root-module.js +0 -6
- package/lib/rules/modules/base.js +0 -8
- package/lib/rules/modules/commonjs.js +0 -11
- package/lib/rules/modules/esm.js +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -3,98 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [
|
|
7
|
-
## [51.1.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-10-03)
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* fix react/function-component-definition rule and enable func-names ([e656eba](https://github.com/christophehurpeau/eslint-config-pob/commit/e656ebaba4639a0eb547ef11dc9d3fbf32aec60e))
|
|
12
|
-
## [51.1.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-10-18)
|
|
13
|
-
|
|
14
|
-
### Bug Fixes
|
|
15
|
-
|
|
16
|
-
* fix no-restricted-exports rule ([a1dd956](https://github.com/christophehurpeau/eslint-config-pob/commit/a1dd956448099f77f3adadca1ce031044a3a4492))
|
|
17
|
-
## [51.1.2](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-10-19)
|
|
18
|
-
## [51.2.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-10)
|
|
19
|
-
## [51.2.2](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-14)
|
|
20
|
-
## [52.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-28)
|
|
21
|
-
|
|
22
|
-
### ⚠ BREAKING CHANGES
|
|
23
|
-
|
|
24
|
-
* change import/extensions to ignorePackages
|
|
25
|
-
|
|
26
|
-
### Features
|
|
27
|
-
|
|
28
|
-
* change import/extensions to ignorePackages ([1833642](https://github.com/christophehurpeau/eslint-config-pob/commit/183364280552d484acd37bbf3b9816d88c1f6bfe))
|
|
29
|
-
## [52.0.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-28)
|
|
30
|
-
|
|
31
|
-
### Reverts
|
|
32
|
-
|
|
33
|
-
* Revert "feat!: change import/extensions to ignorePackages" ([22d14bc](https://github.com/christophehurpeau/eslint-config-pob/commit/22d14bc6d6f94cae03a547cf53d939f6c1c756a7))
|
|
34
|
-
## [53.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-28)
|
|
35
|
-
|
|
36
|
-
### ⚠ BREAKING CHANGES
|
|
37
|
-
|
|
38
|
-
* feat: change import/extensions to ignorePackages
|
|
39
|
-
|
|
40
|
-
### Reverts
|
|
41
|
-
|
|
42
|
-
* feat: change import/extensions to ignorePackages ([0a15b9e](https://github.com/christophehurpeau/eslint-config-pob/commit/0a15b9e80b990a8f6277a1bd19481a9fe72f3f22))
|
|
43
|
-
## [54.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-02-17)
|
|
44
|
-
|
|
45
|
-
### ⚠ BREAKING CHANGES
|
|
46
|
-
|
|
47
|
-
* replace eslint-plugin-node by eslint-plugin-n
|
|
48
|
-
|
|
49
|
-
### Features
|
|
50
|
-
|
|
51
|
-
* replace eslint-plugin-node by eslint-plugin-n ([7d9764c](https://github.com/christophehurpeau/eslint-config-pob/commit/7d9764cf80fffcd4381056624eb06887a3d86e3f))
|
|
52
|
-
## [54.0.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-02-24)
|
|
53
|
-
## [55.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-20)
|
|
6
|
+
## [57.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.1.0...v57.0.0) (2024-08-11)
|
|
54
7
|
|
|
55
8
|
### ⚠ BREAKING CHANGES
|
|
56
9
|
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
### Features
|
|
60
|
-
|
|
61
|
-
* remove eslint-config-airbnb-base ([295a348](https://github.com/christophehurpeau/eslint-config-pob/commit/295a34808018f395e22d935772ac9e614bc6bd47))
|
|
62
|
-
## [55.0.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
|
|
63
|
-
|
|
64
|
-
### Bug Fixes
|
|
65
|
-
|
|
66
|
-
* properly configure module vs commonjs ([8ae7ffd](https://github.com/christophehurpeau/eslint-config-pob/commit/8ae7ffdb3b37f1ec898b4ce8694420253ff3260d))
|
|
67
|
-
## [55.1.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
|
|
68
|
-
|
|
69
|
-
### Features
|
|
70
|
-
|
|
71
|
-
* remove max-lines ([38d7fda](https://github.com/christophehurpeau/eslint-config-pob/commit/38d7fdaa36f40a6f7434fea242bf6a72bef4bcca))
|
|
72
|
-
## [55.2.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
|
|
73
|
-
|
|
74
|
-
### Features
|
|
75
|
-
|
|
76
|
-
* enable max-params ([93f60a1](https://github.com/christophehurpeau/eslint-config-pob/commit/93f60a12ffa4a94a8adf0f74866c8f2c81c37c2e))
|
|
77
|
-
## [55.2.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
|
|
78
|
-
|
|
79
|
-
### Bug Fixes
|
|
80
|
-
|
|
81
|
-
* remove generator-star-spacing ([a9bf679](https://github.com/christophehurpeau/eslint-config-pob/commit/a9bf679717e27b3e3cb86c25af17d89cae205f59))
|
|
82
|
-
## [55.3.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-05-05)
|
|
10
|
+
* use flat config
|
|
83
11
|
|
|
84
12
|
### Features
|
|
85
13
|
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* remove optional peer dependencies ([ddddeb2](https://github.com/christophehurpeau/eslint-config-pob/commit/ddddeb27d606f16dbf6c38b2f61c3a7bfe20510d))
|
|
89
|
-
## [56.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-05-05)
|
|
14
|
+
* add baseModule ([c1e7cef](https://github.com/christophehurpeau/eslint-config-pob/commit/c1e7cef19d835b3ab0333b4588d1810e09874d53))
|
|
15
|
+
* use flat config ([b0bda47](https://github.com/christophehurpeau/eslint-config-pob/commit/b0bda47976ec40a30679988c603d425f9b75346f))
|
|
90
16
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* use standard quotes
|
|
17
|
+
Version bump for dependency: @pob/eslint-plugin
|
|
94
18
|
|
|
95
|
-
### Features
|
|
96
19
|
|
|
97
|
-
* use standard quotes ([0083d81](https://github.com/christophehurpeau/eslint-config-pob/commit/0083d816bbe4e320eabe3c23a8d4edaa561df8a3))
|
|
98
20
|
## [56.1.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-07-27)
|
|
99
21
|
|
|
100
22
|
### Features
|
|
@@ -606,7 +528,7 @@ Note: no notable changes
|
|
|
606
528
|
|
|
607
529
|
### BREAKING CHANGES
|
|
608
530
|
|
|
609
|
-
* **deps:** requires eslint-plugin-unicorn 34 and enable new rules
|
|
531
|
+
* **deps:** requires eslint-plugin-unicorn 34 and enable new rules
|
|
610
532
|
* requires new min supported node versions
|
|
611
533
|
|
|
612
534
|
|
package/lib/_base.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import pobPlugin from "@pob/eslint-plugin";
|
|
3
|
+
import unicornPluginConfigs from "./plugins/unicorn.js";
|
|
4
|
+
import bestPracticesConfig from "./rules/best-practices.js";
|
|
5
|
+
import codeQualityConfig from "./rules/code-quality.js";
|
|
6
|
+
import devOnlyConfig from "./rules/dev-only.js";
|
|
7
|
+
import errorsConfig from "./rules/errors.js";
|
|
8
|
+
import styleConfig from "./rules/style.js";
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
export default [
|
|
11
|
+
{
|
|
12
|
+
linterOptions: {
|
|
13
|
+
// todo noInlineConfig: true,
|
|
14
|
+
reportUnusedDisableDirectives: "error",
|
|
15
|
+
},
|
|
16
|
+
plugins: {
|
|
17
|
+
"@pob": pobPlugin,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
ignores: [".yarn", "**/dist/", "**/build/", "**/coverage/"],
|
|
22
|
+
},
|
|
23
|
+
js.configs.recommended,
|
|
24
|
+
pobPlugin.configs.base,
|
|
25
|
+
...unicornPluginConfigs,
|
|
26
|
+
bestPracticesConfig,
|
|
27
|
+
codeQualityConfig,
|
|
28
|
+
errorsConfig,
|
|
29
|
+
styleConfig,
|
|
30
|
+
devOnlyConfig,
|
|
31
|
+
|
|
32
|
+
// TODO
|
|
33
|
+
// {
|
|
34
|
+
// files: ["*.json"],
|
|
35
|
+
// languageOptions: {
|
|
36
|
+
// parser: jsoncParser,
|
|
37
|
+
// },
|
|
38
|
+
// rules: {},
|
|
39
|
+
// },
|
|
40
|
+
];
|
package/lib/base/commonjs.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
parserOptions: {
|
|
1
|
+
export default {
|
|
2
|
+
languageOptions: {
|
|
5
3
|
sourceType: "script",
|
|
6
4
|
},
|
|
7
5
|
rules: {
|
|
8
6
|
strict: ["error", "safe"],
|
|
7
|
+
|
|
8
|
+
// https://eslint.org/docs/rules/global-require
|
|
9
|
+
"global-require": "error",
|
|
10
|
+
|
|
11
|
+
// disallow use of new operator with the require function
|
|
12
|
+
"no-new-require": "error",
|
|
9
13
|
},
|
|
10
14
|
};
|
package/lib/base/module.js
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
parserOptions: {
|
|
1
|
+
export default {
|
|
2
|
+
languageOptions: {
|
|
5
3
|
sourceType: "module",
|
|
6
4
|
},
|
|
7
5
|
rules: {
|
|
8
6
|
strict: "off",
|
|
7
|
+
|
|
8
|
+
// replaced by import/no-duplicates
|
|
9
|
+
"no-duplicate-imports": "off",
|
|
10
|
+
|
|
11
|
+
// https://eslint.org/docs/rules/no-restricted-exports
|
|
12
|
+
"no-restricted-exports": [
|
|
13
|
+
"error",
|
|
14
|
+
{
|
|
15
|
+
restrictDefaultExports: {
|
|
16
|
+
direct: false, // permits `export default` declarations
|
|
17
|
+
named: true, // restricts `export { foo as default };` declarations
|
|
18
|
+
defaultFrom: false, // permits `export { default } from 'foo';` declarations
|
|
19
|
+
namedFrom: false, // permits `export { foo as default } from 'foo';` declarations
|
|
20
|
+
namespaceFrom: true, // restricts `export * as default from 'foo';` declarations
|
|
21
|
+
},
|
|
22
|
+
restrictedNamedExports: [
|
|
23
|
+
"then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
9
27
|
},
|
|
10
28
|
};
|
package/lib/index.js
CHANGED
|
@@ -1,20 +1,74 @@
|
|
|
1
|
-
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
4
|
+
import baseConfigs from "./_base.js";
|
|
5
|
+
import baseCommonjsConfig from "./base/commonjs.js";
|
|
6
|
+
import baseModuleConfig from "./base/module.js";
|
|
7
|
+
import nodePluginCommonjsConfigs from "./node/commonjs.js";
|
|
8
|
+
import nodePluginModuleConfigs from "./node/module.js";
|
|
9
|
+
import importPluginBaseConfigs from "./plugins/import/import-base.js";
|
|
10
|
+
import importPluginCommonjsConfig from "./plugins/import/import-commonjs.js";
|
|
11
|
+
import importPluginModuleConfig from "./plugins/import/import-module.js";
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
|
|
13
|
+
export default (url) => {
|
|
14
|
+
const __filename = fileURLToPath(url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
5
16
|
|
|
6
|
-
|
|
17
|
+
const compat = new FlatCompat({
|
|
18
|
+
baseDirectory: __dirname,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const nodeCommonjs = [
|
|
22
|
+
...baseConfigs,
|
|
23
|
+
baseCommonjsConfig,
|
|
24
|
+
...importPluginBaseConfigs(compat),
|
|
25
|
+
importPluginCommonjsConfig,
|
|
26
|
+
...nodePluginCommonjsConfigs,
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
files: ["**/*.mjs"],
|
|
30
|
+
...baseModuleConfig,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
files: ["**/*.mjs"],
|
|
34
|
+
...importPluginModuleConfig,
|
|
35
|
+
},
|
|
36
|
+
...nodePluginModuleConfigs.map((config) => ({
|
|
37
|
+
...config,
|
|
38
|
+
files: ["**/*.mjs"],
|
|
39
|
+
})),
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const baseModule = [
|
|
43
|
+
...baseConfigs,
|
|
44
|
+
baseModuleConfig,
|
|
45
|
+
...importPluginBaseConfigs(compat),
|
|
46
|
+
importPluginModuleConfig,
|
|
7
47
|
{
|
|
8
|
-
files: ["
|
|
9
|
-
|
|
10
|
-
require.resolve,
|
|
11
|
-
),
|
|
48
|
+
files: ["**/*.cjs"],
|
|
49
|
+
...baseCommonjsConfig,
|
|
12
50
|
},
|
|
13
51
|
{
|
|
14
|
-
files: ["
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
52
|
+
files: ["**/*.cjs"],
|
|
53
|
+
...importPluginCommonjsConfig,
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const nodeModule = [
|
|
58
|
+
...baseModule,
|
|
59
|
+
...nodePluginModuleConfigs,
|
|
60
|
+
...nodePluginCommonjsConfigs.map((config) => ({
|
|
61
|
+
...config,
|
|
62
|
+
files: ["**/*.cjs"],
|
|
63
|
+
})),
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
compat,
|
|
68
|
+
configs: {
|
|
69
|
+
baseModule,
|
|
70
|
+
nodeModule,
|
|
71
|
+
nodeCommonjs,
|
|
18
72
|
},
|
|
19
|
-
|
|
73
|
+
};
|
|
20
74
|
};
|
package/lib/node/_base.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.overrideRules = {
|
|
1
|
+
export const overrideRules = {
|
|
4
2
|
// Disable rules already checked by import plugin
|
|
5
3
|
"n/no-unpublished-require": "off",
|
|
6
4
|
"n/no-extraneous-require": "off",
|
|
@@ -25,19 +23,13 @@ exports.overrideRules = {
|
|
|
25
23
|
"no-sync": "off",
|
|
26
24
|
|
|
27
25
|
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/import/extensions.md
|
|
28
|
-
"import/extensions": [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
],
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
exports.env = {
|
|
40
|
-
browser: false,
|
|
41
|
-
node: true,
|
|
42
|
-
es6: true,
|
|
26
|
+
// "import/extensions": [
|
|
27
|
+
// "error",
|
|
28
|
+
// "ignorePackages",
|
|
29
|
+
// {
|
|
30
|
+
// mjs: "always",
|
|
31
|
+
// cjs: "always",
|
|
32
|
+
// js: "never",
|
|
33
|
+
// },
|
|
34
|
+
// ],
|
|
43
35
|
};
|
package/lib/node/commonjs.js
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// top level await is introduced in 2022
|
|
14
|
-
// current ecmaVersion in eslint-plugin-node is 2019
|
|
15
|
-
ecmaVersion: 2022,
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
rules: {
|
|
19
|
-
...overrideRules,
|
|
20
|
-
"unicorn/prefer-module": "off",
|
|
21
|
-
"n/no-new-require": "error",
|
|
22
|
-
"n/no-path-concat": "error",
|
|
1
|
+
import nodePlugin from "eslint-plugin-n";
|
|
2
|
+
import { overrideRules } from "./_base.js";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
nodePlugin.configs["flat/recommended-script"],
|
|
6
|
+
{
|
|
7
|
+
rules: {
|
|
8
|
+
...overrideRules,
|
|
9
|
+
// "unicorn/prefer-module": "off",
|
|
10
|
+
"n/no-new-require": "error",
|
|
11
|
+
"n/no-path-concat": "error",
|
|
12
|
+
},
|
|
23
13
|
},
|
|
24
|
-
|
|
14
|
+
];
|
package/lib/node/module.js
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import nodePlugin from "eslint-plugin-n";
|
|
2
|
+
import { overrideRules } from "./_base.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export default [
|
|
5
|
+
nodePlugin.configs["flat/recommended-module"],
|
|
6
|
+
{
|
|
7
|
+
rules: {
|
|
8
|
+
...overrideRules,
|
|
9
|
+
"unicorn/prefer-module": "error",
|
|
10
|
+
"unicorn/import-index": "off",
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/import/extensions.md
|
|
13
|
+
"import/extensions": [
|
|
14
|
+
"error",
|
|
15
|
+
"ignorePackages",
|
|
16
|
+
{
|
|
17
|
+
mjs: "always",
|
|
18
|
+
cjs: "always",
|
|
19
|
+
js: "always",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
15
23
|
},
|
|
16
|
-
|
|
17
|
-
rules: {
|
|
18
|
-
...overrideRules,
|
|
19
|
-
"unicorn/prefer-module": "error",
|
|
20
|
-
"unicorn/import-index": "off",
|
|
21
|
-
|
|
22
|
-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/import/extensions.md
|
|
23
|
-
"import/extensions": [
|
|
24
|
-
"error",
|
|
25
|
-
"ignorePackages",
|
|
26
|
-
{
|
|
27
|
-
mjs: "always",
|
|
28
|
-
cjs: "always",
|
|
29
|
-
js: "always",
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
};
|
|
24
|
+
];
|
|
@@ -1,99 +1,132 @@
|
|
|
1
|
-
|
|
1
|
+
import { fixupPluginRules } from "@eslint/compat";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
plugins
|
|
3
|
+
function legacyPlugin(compat, name, alias = name) {
|
|
4
|
+
const plugin = compat.plugins(name)[0]?.plugins?.[alias];
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
if (!plugin) {
|
|
7
|
+
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return fixupPluginRules(plugin);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default (compat) => [
|
|
14
|
+
{
|
|
15
|
+
//
|
|
16
|
+
languageOptions: {
|
|
17
|
+
parserOptions: {
|
|
18
|
+
ecmaVersion: 2022,
|
|
19
|
+
sourceType: "module",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
plugins: {
|
|
23
|
+
import: legacyPlugin(compat, "eslint-plugin-import", "import"),
|
|
24
|
+
},
|
|
25
|
+
settings: {
|
|
26
|
+
"import/parsers": {
|
|
27
|
+
// https://github.com/import-js/eslint-plugin-import/issues/2556#issuecomment-1419518561
|
|
28
|
+
espree: [".js", ".cjs", ".mjs"],
|
|
29
|
+
},
|
|
30
|
+
"import/resolver": {
|
|
31
|
+
node: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
10
34
|
},
|
|
35
|
+
...compat.config({
|
|
36
|
+
settings: {
|
|
37
|
+
"import/extensions": [".js", ".mjs"],
|
|
38
|
+
"import/ignore": ["node_modules"],
|
|
39
|
+
},
|
|
11
40
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
41
|
+
rules: {
|
|
42
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
|
|
43
|
+
"import/no-unresolved": [
|
|
44
|
+
"error",
|
|
45
|
+
{ commonjs: true, caseSensitive: true },
|
|
46
|
+
],
|
|
15
47
|
|
|
16
|
-
|
|
17
|
-
|
|
48
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/named.md
|
|
49
|
+
"import/named": "error",
|
|
18
50
|
|
|
19
|
-
|
|
20
|
-
|
|
51
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/export.md
|
|
52
|
+
"import/export": "error",
|
|
21
53
|
|
|
22
|
-
|
|
23
|
-
|
|
54
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
|
|
55
|
+
"import/no-named-as-default": "error",
|
|
24
56
|
|
|
25
|
-
|
|
26
|
-
|
|
57
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
|
|
58
|
+
"import/no-named-as-default-member": "error",
|
|
27
59
|
|
|
28
|
-
|
|
29
|
-
|
|
60
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
|
|
61
|
+
"import/no-deprecated": "off",
|
|
30
62
|
|
|
31
|
-
|
|
32
|
-
|
|
63
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
64
|
+
"import/no-extraneous-dependencies": "error",
|
|
33
65
|
|
|
34
|
-
|
|
35
|
-
|
|
66
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
|
|
67
|
+
"import/no-mutable-exports": "error",
|
|
36
68
|
|
|
37
|
-
|
|
38
|
-
|
|
69
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-amd.md
|
|
70
|
+
"import/no-amd": "error",
|
|
39
71
|
|
|
40
|
-
|
|
41
|
-
|
|
72
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/first.md
|
|
73
|
+
"import/first": "error",
|
|
42
74
|
|
|
43
|
-
|
|
44
|
-
|
|
75
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
|
|
76
|
+
"import/no-duplicates": "error",
|
|
45
77
|
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
|
|
79
|
+
"import/newline-after-import": "error",
|
|
48
80
|
|
|
49
|
-
|
|
50
|
-
|
|
81
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
|
|
82
|
+
"import/prefer-default-export": "off",
|
|
51
83
|
|
|
52
|
-
|
|
53
|
-
|
|
84
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
|
|
85
|
+
"import/no-absolute-path": "error",
|
|
54
86
|
|
|
55
|
-
|
|
56
|
-
|
|
87
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
|
|
88
|
+
"import/no-dynamic-require": "error",
|
|
57
89
|
|
|
58
|
-
|
|
59
|
-
|
|
90
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
|
|
91
|
+
"import/no-webpack-loader-syntax": "error",
|
|
60
92
|
|
|
61
|
-
|
|
62
|
-
|
|
93
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
|
|
94
|
+
"import/no-named-default": "error",
|
|
63
95
|
|
|
64
|
-
|
|
65
|
-
|
|
96
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-self-import.md
|
|
97
|
+
"import/no-self-import": "error",
|
|
66
98
|
|
|
67
|
-
|
|
68
|
-
|
|
99
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-cycle.md
|
|
100
|
+
"import/no-cycle": ["error", { maxDepth: "∞" }],
|
|
69
101
|
|
|
70
|
-
|
|
71
|
-
|
|
102
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-useless-path-segments.md
|
|
103
|
+
"import/no-useless-path-segments": ["error", { commonjs: true }],
|
|
72
104
|
|
|
73
|
-
|
|
74
|
-
|
|
105
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-import-module-exports.md
|
|
106
|
+
"import/no-import-module-exports": "error",
|
|
75
107
|
|
|
76
|
-
|
|
77
|
-
|
|
108
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-relative-packages.md
|
|
109
|
+
"import/no-relative-packages": "error",
|
|
78
110
|
|
|
79
|
-
|
|
80
|
-
|
|
111
|
+
// https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-empty-named-blocks.md
|
|
112
|
+
"import/no-empty-named-blocks": "error",
|
|
81
113
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
114
|
+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
|
|
115
|
+
"import/order": [
|
|
116
|
+
"error",
|
|
117
|
+
{
|
|
118
|
+
groups: [
|
|
119
|
+
"builtin",
|
|
120
|
+
"external",
|
|
121
|
+
"internal",
|
|
122
|
+
"parent",
|
|
123
|
+
"sibling",
|
|
124
|
+
"index",
|
|
125
|
+
],
|
|
126
|
+
alphabetize: { order: "asc", caseInsensitive: false },
|
|
127
|
+
"newlines-between": "never",
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
];
|