@pob/eslint-config 67.14.0 → 68.1.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.
Files changed (47) hide show
  1. package/lib/_base.js +21 -31
  2. package/lib/eslint-rules.test.js +1 -3
  3. package/lib/index.js +77 -343
  4. package/lib/index.test.js +76 -40
  5. package/lib/node.js +60 -0
  6. package/lib/overrides/dev-only.js +10 -0
  7. package/lib/overrides/scripts.js +1 -1
  8. package/lib/overrides/test.js +7 -45
  9. package/lib/overrides/tools-project.js +4 -10
  10. package/lib/oxlint-js-plugins-rules.test.js +62 -0
  11. package/lib/oxlint-rules.test.js +2 -4
  12. package/lib/oxlint.test.js +58 -46
  13. package/lib/plugins/import.js +69 -0
  14. package/lib/typescript.js +27 -0
  15. package/oxlint/base.json +4 -0
  16. package/oxlint/commonjs.json +17 -0
  17. package/oxlint/module.json +5 -1
  18. package/oxlint/node.json +5 -1
  19. package/package.json +10 -15
  20. package/lib/base/commonjs.js +0 -12
  21. package/lib/base/module.js +0 -29
  22. package/lib/node/_base.js +0 -35
  23. package/lib/node/commonjs.js +0 -25
  24. package/lib/node/module.js +0 -35
  25. package/lib/node/typescript.js +0 -15
  26. package/lib/overrides/allow-implicit-return-type.js +0 -7
  27. package/lib/overrides/allow-unsafe-as-warn.js +0 -10
  28. package/lib/overrides/allow-unsafe.js +0 -10
  29. package/lib/overrides/app.js +0 -8
  30. package/lib/plugins/import/import-base.js +0 -136
  31. package/lib/plugins/import/import-commonjs.js +0 -7
  32. package/lib/plugins/import/import-module.js +0 -7
  33. package/lib/plugins/node.js +0 -17
  34. package/lib/plugins/regexp.js +0 -12
  35. package/lib/plugins/typescript-eslint/typescript-eslint-replace-eslint.js +0 -126
  36. package/lib/plugins/typescript-eslint/typescript-eslint-replace-unicorn.js +0 -13
  37. package/lib/plugins/typescript-eslint/typescript-eslint-rules.js +0 -213
  38. package/lib/plugins/unicorn.js +0 -392
  39. package/lib/rules/best-practices.js +0 -470
  40. package/lib/rules/code-quality.js +0 -10
  41. package/lib/rules/dev-only.js +0 -15
  42. package/lib/rules/errors.js +0 -128
  43. package/lib/rules/node.js +0 -26
  44. package/lib/rules/style.js +0 -26
  45. package/lib/rules/typescript.js +0 -61
  46. package/lib/utils/oxlint.js +0 -136
  47. package/lib/utils/oxlint.test.js +0 -197
package/lib/node/_base.js DELETED
@@ -1,35 +0,0 @@
1
- export const overrideRules = {
2
- // Disable rules already checked by import plugin
3
- "n/no-unpublished-require": "off",
4
- "n/no-extraneous-require": "off",
5
- "n/no-unpublished-import": "off",
6
- "n/no-extraneous-import": "off",
7
- "n/no-missing-require": "off",
8
- "n/no-missing-import": "off",
9
-
10
- // Allow process.exit
11
- "n/no-process-exit": "off",
12
-
13
- // ensure deprecated eslint rules are disabled
14
- "callback-return": "off",
15
- "global-require": "off",
16
- "handle-callback-err": "off",
17
- "no-mixed-requires": "off",
18
- "no-new-require": "off",
19
- "no-path-concat": "off",
20
- "no-process-env": "off",
21
- "no-process-exit": "off",
22
- "no-restricted-modules": "off",
23
- "no-sync": "off",
24
-
25
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/import/extensions.md
26
- // "import-x/extensions": [
27
- // "error",
28
- // "ignorePackages",
29
- // {
30
- // mjs: "always",
31
- // cjs: "always",
32
- // js: "never",
33
- // },
34
- // ],
35
- };
@@ -1,25 +0,0 @@
1
- import pobPlugin from "@pob/eslint-plugin";
2
- import { createNodeResolver } from "eslint-plugin-import-x";
3
- import nodePlugin from "eslint-plugin-n";
4
- import { overrideRules } from "./_base.js";
5
-
6
- export default [
7
- nodePlugin.configs["flat/recommended-script"],
8
- pobPlugin.configs.node,
9
- {
10
- name: "@pob/eslint-config/node/commonjs",
11
- settings: {
12
- "import-x/resolver-next": [
13
- createNodeResolver({
14
- conditionNames: ["require", "default", "node"],
15
- }),
16
- ],
17
- },
18
- rules: {
19
- ...overrideRules,
20
- // "unicorn/prefer-module": "off",
21
- "n/no-new-require": "error",
22
- "n/no-path-concat": "error",
23
- },
24
- },
25
- ];
@@ -1,35 +0,0 @@
1
- import pobPlugin from "@pob/eslint-plugin";
2
- import { createNodeResolver } from "eslint-plugin-import-x";
3
- import nodePlugin from "eslint-plugin-n";
4
- import { overrideRules } from "./_base.js";
5
-
6
- export default [
7
- nodePlugin.configs["flat/recommended-module"],
8
- pobPlugin.configs.node,
9
- {
10
- name: "@pob/eslint-config/node/module",
11
- settings: {
12
- "import-x/resolver-next": [
13
- createNodeResolver({
14
- conditionNames: ["node", "import"],
15
- }),
16
- ],
17
- },
18
- rules: {
19
- ...overrideRules,
20
- "unicorn/prefer-module": "error",
21
- "unicorn/import-index": "off",
22
-
23
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/import/extensions.md
24
- "import-x/extensions": [
25
- "error",
26
- "ignorePackages",
27
- {
28
- mjs: "always",
29
- cjs: "always",
30
- js: "always",
31
- },
32
- ],
33
- },
34
- },
35
- ];
@@ -1,15 +0,0 @@
1
- import { createNodeResolver } from "eslint-plugin-import-x";
2
-
3
- export default [
4
- {
5
- name: "@pob/eslint-config/node/typescript",
6
- settings: {
7
- "import-x/resolver-next": [
8
- createNodeResolver({
9
- extensions: [".mjs", ".js", ".json", ".ts"],
10
- conditionNames: ["node", "import"],
11
- }),
12
- ],
13
- },
14
- },
15
- ];
@@ -1,7 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/overrides/allow-implicit-return-type",
3
- rules: {
4
- "@typescript-eslint/explicit-function-return-type": "off",
5
- "@typescript-eslint/explicit-module-boundary-types": "off",
6
- },
7
- };
@@ -1,10 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/overrides/allow-unsafe-as-warn",
3
- rules: {
4
- "@typescript-eslint/no-unsafe-argument": "warn",
5
- "@typescript-eslint/no-unsafe-assignment": "warn",
6
- "@typescript-eslint/no-unsafe-call": "warn",
7
- "@typescript-eslint/no-unsafe-member-access": "warn",
8
- "@typescript-eslint/no-unsafe-return": "warn",
9
- },
10
- };
@@ -1,10 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/overrides/allow-unsafe",
3
- rules: {
4
- "@typescript-eslint/no-unsafe-argument": "off",
5
- "@typescript-eslint/no-unsafe-assignment": "off",
6
- "@typescript-eslint/no-unsafe-call": "off",
7
- "@typescript-eslint/no-unsafe-member-access": "off",
8
- "@typescript-eslint/no-unsafe-return": "off",
9
- },
10
- };
@@ -1,8 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/overrides/app",
3
- rules: {
4
- /* No need for this rule in an app */
5
- "@typescript-eslint/explicit-module-boundary-types": "off",
6
- "@typescript-eslint/explicit-function-return-type": "off",
7
- },
8
- };
@@ -1,136 +0,0 @@
1
- import { createNodeResolver, flatConfigs } from "eslint-plugin-import-x";
2
-
3
- export default [
4
- flatConfigs.recommended,
5
- {
6
- name: "@pob/eslint-config/import/base",
7
- // override recommended language options
8
- languageOptions: {
9
- ecmaVersion: "latest",
10
- sourceType: "module",
11
- },
12
- settings: {
13
- "import-x/extensions": [".js", ".mjs"],
14
- "import-x/ignore": ["node_modules"],
15
- "import-x/parsers": {
16
- // https://github.com/un-ts/eslint-plugin-import-x/issues/2556#issuecomment-1419518561
17
- espree: [".js", ".cjs", ".mjs"],
18
- "@typescript-eslint/parser": [".ts"],
19
- },
20
- "import-x/resolver-next": [createNodeResolver()],
21
- },
22
- rules: {
23
- // disable in recommended
24
- "import-x/default": "off",
25
-
26
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
27
- "import-x/no-unresolved": [
28
- "error",
29
- { commonjs: true, caseSensitive: true },
30
- ],
31
-
32
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/named.md
33
- "import-x/named": "error",
34
-
35
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/export.md
36
- "import-x/export": "error",
37
-
38
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default.md
39
- "import-x/no-named-as-default": "error",
40
-
41
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-as-default-member.md
42
- "import-x/no-named-as-default-member": "error",
43
-
44
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-deprecated.md
45
- "import-x/no-deprecated": "off",
46
-
47
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md
48
- "import-x/no-extraneous-dependencies": "error",
49
-
50
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-mutable-exports.md
51
- "import-x/no-mutable-exports": "error",
52
-
53
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-amd.md
54
- "import-x/no-amd": "error",
55
-
56
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/first.md
57
- "import-x/first": "error",
58
-
59
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-duplicates.md
60
- "import-x/no-duplicates": "error",
61
-
62
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/newline-after-import.md
63
- "import-x/newline-after-import": "error",
64
-
65
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/prefer-default-export.md
66
- "import-x/prefer-default-export": "off",
67
-
68
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-absolute-path.md
69
- "import-x/no-absolute-path": "error",
70
-
71
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-dynamic-require.md
72
- "import-x/no-dynamic-require": "error",
73
-
74
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-webpack-loader-syntax.md
75
- "import-x/no-webpack-loader-syntax": "error",
76
-
77
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-named-default.md
78
- "import-x/no-named-default": "error",
79
-
80
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-self-import.md
81
- "import-x/no-self-import": "error",
82
-
83
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-cycle.md
84
- "import-x/no-cycle": ["error", { maxDepth: "∞" }],
85
-
86
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
87
- "import-x/no-useless-path-segments": ["error", { commonjs: true }],
88
-
89
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-import-module-exports.md
90
- "import-x/no-import-module-exports": "error",
91
-
92
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages.md
93
- "import-x/no-relative-packages": "error",
94
-
95
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-empty-named-blocks.md
96
- "import-x/no-empty-named-blocks": "error",
97
-
98
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/order.md
99
- "import-x/order": [
100
- "error",
101
- {
102
- groups: [
103
- "builtin",
104
- "external",
105
- "internal",
106
- "parent",
107
- "sibling",
108
- "index",
109
- ],
110
- alphabetize: { order: "asc", caseInsensitive: false },
111
- "newlines-between": "never",
112
- },
113
- ],
114
- },
115
- },
116
- {
117
- name: "@pob/eslint-config/import/rollup-config",
118
- files: ["rollup.config.js", "rollup.config.mjs"],
119
- rules: {
120
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages.md
121
- "import-x/no-relative-packages": "off",
122
-
123
- // https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/order.md
124
- "import-x/order": "off",
125
- },
126
- },
127
-
128
- {
129
- name: "@pob/eslint-config/import/typescript",
130
- files: ["*.ts"],
131
- rules: {
132
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md
133
- "import-x/consistent-type-specifier-style": "error",
134
- },
135
- },
136
- ];
@@ -1,7 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/import/commonjs",
3
- rules: {
4
- // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
5
- "import-x/no-commonjs": "off",
6
- },
7
- };
@@ -1,7 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/import/module",
3
- rules: {
4
- // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
5
- "import-x/no-commonjs": "error",
6
- },
7
- };
@@ -1,17 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/plugins/node",
3
-
4
- rules: {
5
- // Disable rules already checked by import plugin
6
- "n/no-unpublished-require": "off",
7
- "n/no-extraneous-require": "off",
8
- "n/no-unpublished-import": "off",
9
- "n/no-extraneous-import": "off",
10
- "n/no-missing-require": "off",
11
- "n/no-missing-import": "off",
12
-
13
- // disable no-unsupported-features when using babel
14
- "n/no-unsupported-features/es-builtins": "off",
15
- "n/no-unsupported-features/es-syntax": "off",
16
- },
17
- };
@@ -1,12 +0,0 @@
1
- import { configs } from "eslint-plugin-regexp";
2
-
3
- export default [
4
- {
5
- ...configs["flat/recommended"],
6
- name: "eslint-plugin-regexp/flat/recommended",
7
- },
8
- // {
9
- // name: "@pob/eslint-config/regexp",
10
- // rules: {},
11
- // },
12
- ];
@@ -1,126 +0,0 @@
1
- import pobBestPracticesConfig from "@pob/eslint-config/lib/rules/best-practices";
2
- import pobCodeQualityConfig from "@pob/eslint-config/lib/rules/code-quality";
3
- import pobErrorsConfig from "@pob/eslint-config/lib/rules/errors";
4
- import pobStyleConfig from "@pob/eslint-config/lib/rules/style";
5
-
6
- const getRuleValue = (config, ruleName) => {
7
- const value = config[ruleName];
8
- if (value == null) {
9
- throw new Error(`getRuleValue: missing value for rule "${ruleName}"`);
10
- }
11
-
12
- return value;
13
- };
14
-
15
- const replaceRules = (config, ruleNames) => {
16
- return Object.fromEntries(
17
- ruleNames.flatMap((ruleName) => [
18
- [ruleName, "off"],
19
- [`@typescript-eslint/${ruleName}`, getRuleValue(config, ruleName)],
20
- ]),
21
- );
22
- };
23
-
24
- const disabledRules = (ruleNames) => {
25
- return Object.fromEntries(
26
- ruleNames.map((ruleName) => {
27
- [
28
- pobBestPracticesConfig.rules,
29
- pobCodeQualityConfig.rules,
30
- pobErrorsConfig.rules,
31
- pobStyleConfig.rules,
32
- ].forEach((config) => {
33
- const value = config[ruleName];
34
- if (value != null && value !== "off") {
35
- throw new Error(`disabledRules: value for rule "${ruleName}" exists`);
36
- }
37
- });
38
- return [ruleName, "off"];
39
- }),
40
- );
41
- };
42
-
43
- const disableRules = (ruleNames) => {
44
- return Object.fromEntries(ruleNames.map((ruleName) => [ruleName, "off"]));
45
- };
46
-
47
- export default {
48
- name: "@pob/eslint-config/typescript-eslint/replace-eslint",
49
- /* Replace enabled rules in Airbnb by typescript-eslint rules */
50
- rules: {
51
- ...replaceRules(pobBestPracticesConfig.rules, [
52
- // https://typescript-eslint.io/rules/default-param-last
53
- "default-param-last",
54
- // https://typescript-eslint.io/rules/dot-notation
55
- "dot-notation",
56
- // https://typescript-eslint.io/rules/no-array-constructor
57
- "no-array-constructor",
58
- // https://typescript-eslint.io/rules/no-dupe-class-members
59
- "no-dupe-class-members",
60
- // https://typescript-eslint.io/rules/no-empty-function
61
- "no-empty-function",
62
- // https://typescript-eslint.io/rules/no-implied-eval
63
- "no-implied-eval",
64
- // https://typescript-eslint.io/rules/no-loop-func
65
- "no-loop-func",
66
- // https://typescript-eslint.io/rules/no-unused-expressions
67
- "no-unused-expressions",
68
- // https://typescript-eslint.io/rules/no-unused-vars
69
- "no-unused-vars",
70
- // https://typescript-eslint.io/rules/no-use-before-define
71
- "no-use-before-define",
72
- // https://typescript-eslint.io/rules/no-useless-constructor
73
- "no-useless-constructor",
74
- // https://typescript-eslint.io/rules/require-await
75
- "require-await",
76
- // https://typescript-eslint.io/rules/consistent-return
77
- "consistent-return",
78
- // https://typescript-eslint.io/rules/class-methods-use-this
79
- "class-methods-use-this",
80
- // https://typescript-eslint.io/rules/max-params
81
- "max-params",
82
- ]),
83
-
84
- ...disabledRules([
85
- // https://typescript-eslint.io/rules/brace-style
86
- "brace-style",
87
- // https://typescript-eslint.io/rules/comma-dangle
88
- "comma-dangle",
89
- // https://typescript-eslint.io/rules/comma-spacing
90
- "comma-spacing",
91
- // https://typescript-eslint.io/rules/func-call-spacing
92
- "func-call-spacing",
93
- // https://typescript-eslint.io/rules/indent
94
- "indent",
95
- // https://typescript-eslint.io/rules/init-declarations
96
- "init-declarations",
97
- // https://typescript-eslint.io/rules/keyword-spacing
98
- "keyword-spacing",
99
- // https://typescript-eslint.io/rules/lines-between-class-members
100
- "lines-between-class-members",
101
- // https://typescript-eslint.io/rules/no-magic-numbers
102
- "no-magic-numbers",
103
- // https://typescript-eslint.io/rules/no-restricted-imports
104
- "no-restricted-imports",
105
- // https://typescript-eslint.io/rules/no-shadow
106
- "no-shadow",
107
- // https://typescript-eslint.io/rules/object-curly-spacing
108
- "object-curly-spacing",
109
- // https://typescript-eslint.io/rules/padding-line-between-statements
110
- "padding-line-between-statements",
111
- // https://typescript-eslint.io/rules/semi
112
- "semi",
113
- // https://typescript-eslint.io/rules/prefer-destructuring
114
- "prefer-destructuring",
115
- ]),
116
-
117
- /* covered by tsc */
118
-
119
- ...disableRules([
120
- // https://typescript-eslint.io/rules/no-invalid-this
121
- "no-invalid-this",
122
- // https://typescript-eslint.io/rules/no-redeclare
123
- "no-redeclare",
124
- ]),
125
- },
126
- };
@@ -1,13 +0,0 @@
1
- export default {
2
- name: "@pob/eslint-config/typescript-eslint/replace-unicorn",
3
-
4
- /* Replace unicorn rules by better type-aware typescript-eslint rules */
5
- rules: {
6
- "unicorn/prefer-string-starts-ends-with": "off",
7
- "unicorn/prefer-string-slice": "off",
8
- "@typescript-eslint/prefer-string-starts-ends-with": "error",
9
-
10
- "unicorn/prefer-array-find": "off",
11
- "@typescript-eslint/prefer-find": "error",
12
- },
13
- };