@open-xchange/linter-presets 0.1.4 → 0.1.6
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/.vscode/settings.json +3 -0
- package/CHANGELOG.md +9 -0
- package/dist/eslint/config/base.js +1 -1
- package/dist/eslint/config/ts.js +2 -0
- package/dist/eslint/env/browser.d.ts +4 -9
- package/dist/eslint/env/browser.js +14 -25
- package/dist/eslint/env/codecept.d.ts +2 -2
- package/dist/eslint/env/codecept.js +25 -36
- package/dist/eslint/env/eslint.d.ts +2 -2
- package/dist/eslint/env/eslint.js +8 -20
- package/dist/eslint/env/jest.d.ts +2 -2
- package/dist/eslint/env/jest.js +28 -34
- package/dist/eslint/env/node.d.ts +4 -9
- package/dist/eslint/env/node.js +20 -34
- package/dist/eslint/env/project.d.ts +7 -3
- package/dist/eslint/env/project.js +18 -21
- package/dist/eslint/env/react.d.ts +2 -2
- package/dist/eslint/env/react.js +68 -63
- package/dist/eslint/env/tsconfig.d.ts +2 -2
- package/dist/eslint/env/tsconfig.js +13 -18
- package/dist/eslint/env/vitest.d.ts +2 -2
- package/dist/eslint/env/vitest.js +52 -67
- package/dist/eslint/rules/no-invalid-modules.js +5 -5
- package/dist/eslint/shared/env-utils.d.ts +62 -10
- package/dist/eslint/shared/env-utils.js +81 -26
- package/doc/eslint/README.md +1 -0
- package/doc/eslint/env/project.md +26 -19
- package/package.json +14 -13
- package/test/src/project1/file1.js +26 -0
- package/test/src/project2/file2.js +2 -0
- package/test/src/project3/file3.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.6] - 2024-07-23
|
|
4
|
+
|
|
5
|
+
- changed: [ESLint] moved rule options for `env.project` into own `modules` option
|
|
6
|
+
- chore: [ESLint] unit test for `env.project`
|
|
7
|
+
|
|
8
|
+
## [0.1.5] - 2024-07-23
|
|
9
|
+
|
|
10
|
+
- chore: bump dependencies
|
|
11
|
+
|
|
3
12
|
## [0.1.4] - 2024-07-15
|
|
4
13
|
|
|
5
14
|
- added: [ESLint] option `language.nativeDecorators` to support native ES decorators in JS files
|
|
@@ -119,7 +119,7 @@ export default function base(options) {
|
|
|
119
119
|
"object-shorthand": "error",
|
|
120
120
|
"operator-assignment": "error",
|
|
121
121
|
"prefer-arrow-callback": "error",
|
|
122
|
-
"prefer-const": ["error", { ignoreReadBeforeAssign: true }],
|
|
122
|
+
"prefer-const": ["error", { destructuring: "all", ignoreReadBeforeAssign: true }],
|
|
123
123
|
"prefer-numeric-literals": "error",
|
|
124
124
|
"prefer-regex-literals": "error",
|
|
125
125
|
"prefer-rest-params": "error",
|
package/dist/eslint/config/ts.js
CHANGED
|
@@ -63,9 +63,11 @@ export default function ts() {
|
|
|
63
63
|
"@typescript-eslint/no-shadow": ["error", { ignoreOnInitialization: true }],
|
|
64
64
|
"@typescript-eslint/no-unnecessary-template-expression": "error",
|
|
65
65
|
"@typescript-eslint/no-unsafe-enum-comparison": "error",
|
|
66
|
+
"@typescript-eslint/no-unsafe-function-type": "error",
|
|
66
67
|
"@typescript-eslint/no-unsafe-unary-minus": "error",
|
|
67
68
|
"@typescript-eslint/no-unused-vars": ["error", NO_UNUSED_VARS_OPTIONS],
|
|
68
69
|
"@typescript-eslint/no-useless-constructor": "error",
|
|
70
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
69
71
|
"@typescript-eslint/only-throw-error": "error",
|
|
70
72
|
"@typescript-eslint/prefer-find": "error",
|
|
71
73
|
"@typescript-eslint/prefer-literal-enum-member": "error",
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
-
import type {
|
|
2
|
+
import type { EnvRestrictedOptions } from "../shared/env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options for the environment preset "env.browser".
|
|
5
5
|
*/
|
|
6
|
-
export interface EnvBrowserOptions extends
|
|
7
|
-
/**
|
|
8
|
-
* All globals, imports, properties, and syntax constructs to be banned for
|
|
9
|
-
* the files included by the environment.
|
|
10
|
-
*/
|
|
11
|
-
restricted?: EnvRestrictedOptions;
|
|
6
|
+
export interface EnvBrowserOptions extends EnvRestrictedOptions {
|
|
12
7
|
}
|
|
13
8
|
/**
|
|
14
9
|
* Creates configuration objects with global symbols and linter rules for for
|
|
@@ -18,10 +13,10 @@ export interface EnvBrowserOptions extends EnvBaseOptions {
|
|
|
18
13
|
* - `globals`
|
|
19
14
|
* - `confusing-browser-globals`
|
|
20
15
|
*
|
|
21
|
-
* @param
|
|
16
|
+
* @param envOptions
|
|
22
17
|
* Configuration options for the environment.
|
|
23
18
|
*
|
|
24
19
|
* @returns
|
|
25
20
|
* An array of configuration objects to be added to the flat configuration.
|
|
26
21
|
*/
|
|
27
|
-
export default function browser(
|
|
22
|
+
export default function browser(envOptions: EnvBrowserOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import JAVASCRIPT_GLOBALS from "globals";
|
|
2
2
|
import CONFUSING_BROWSER_GLOBALS from "confusing-browser-globals";
|
|
3
|
-
import {
|
|
3
|
+
import { concatConfigs, createConfig, restrictedRules, customRules } from "../shared/env-utils.js";
|
|
4
4
|
// constants ==================================================================
|
|
5
5
|
/**
|
|
6
6
|
* Global builtin symbols that are confusing or deprecated.
|
|
@@ -84,37 +84,26 @@ const RESTRICTED_GLOBALS = AMBIGUOUS_BROWSER_TYPES.map(name => {
|
|
|
84
84
|
* - `globals`
|
|
85
85
|
* - `confusing-browser-globals`
|
|
86
86
|
*
|
|
87
|
-
* @param
|
|
87
|
+
* @param envOptions
|
|
88
88
|
* Configuration options for the environment.
|
|
89
89
|
*
|
|
90
90
|
* @returns
|
|
91
91
|
* An array of configuration objects to be added to the flat configuration.
|
|
92
92
|
*/
|
|
93
|
-
export default function browser(
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
export default function browser(envOptions) {
|
|
94
|
+
return concatConfigs(
|
|
95
|
+
// register global symbols used in browser scripts
|
|
96
|
+
createConfig(envOptions, {
|
|
97
|
+
languageOptions: {
|
|
98
|
+
globals: BROWSER_GLOBALS,
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
96
101
|
// generate the "no-restricted-?" rules according to passed configuration
|
|
97
|
-
|
|
102
|
+
restrictedRules(envOptions, {
|
|
98
103
|
globals: RESTRICTED_GLOBALS,
|
|
99
104
|
properties: RESTRICTED_PROPERTIES,
|
|
100
105
|
syntax: RESTRICTED_SYNTAX,
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
files,
|
|
106
|
-
ignores,
|
|
107
|
-
// register global symbols used in browser scripts
|
|
108
|
-
languageOptions: {
|
|
109
|
-
globals: BROWSER_GLOBALS,
|
|
110
|
-
},
|
|
111
|
-
// configure rules
|
|
112
|
-
rules: {
|
|
113
|
-
...restricted.rules,
|
|
114
|
-
...rules,
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
// "no-restricted-?" rules overrides for specific files
|
|
118
|
-
...restricted.overrides,
|
|
119
|
-
];
|
|
106
|
+
}),
|
|
107
|
+
// custom rules
|
|
108
|
+
customRules(envOptions));
|
|
120
109
|
}
|
|
@@ -13,10 +13,10 @@ export interface EnvCodeceptOptions extends EnvBaseOptions {
|
|
|
13
13
|
* - `eslint-plugin-codeceptjs`
|
|
14
14
|
* - `eslint-plugin-chai-expect`
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param envOptions
|
|
17
17
|
* Configuration options for the environment.
|
|
18
18
|
*
|
|
19
19
|
* @returns
|
|
20
20
|
* An array of configuration objects to be added to the flat configuration.
|
|
21
21
|
*/
|
|
22
|
-
export default function codecept(
|
|
22
|
+
export default function codecept(envOptions: EnvCodeceptOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import codeceptPlugin from "eslint-plugin-codeceptjs";
|
|
8
8
|
import chaiExpectPlugin from "eslint-plugin-chai-expect";
|
|
9
|
+
import { concatConfigs, createConfig, customRules } from "../shared/env-utils.js";
|
|
9
10
|
// functions ==================================================================
|
|
10
11
|
/**
|
|
11
12
|
* Creates configuration objects with global symbols and linter rules for E2E
|
|
@@ -15,47 +16,35 @@ import chaiExpectPlugin from "eslint-plugin-chai-expect";
|
|
|
15
16
|
* - `eslint-plugin-codeceptjs`
|
|
16
17
|
* - `eslint-plugin-chai-expect`
|
|
17
18
|
*
|
|
18
|
-
* @param
|
|
19
|
+
* @param envOptions
|
|
19
20
|
* Configuration options for the environment.
|
|
20
21
|
*
|
|
21
22
|
* @returns
|
|
22
23
|
* An array of configuration objects to be added to the flat configuration.
|
|
23
24
|
*/
|
|
24
|
-
export default function codecept(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// register rule implementations of the plugins
|
|
32
|
-
plugins: {
|
|
33
|
-
codeceptjs: codeceptPlugin,
|
|
34
|
-
},
|
|
35
|
-
// register global symbols of CodeceptJS
|
|
36
|
-
languageOptions: {
|
|
37
|
-
globals: {
|
|
38
|
-
...codeceptPlugin.environments.codeceptjs.globals,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
// configure plugin rules
|
|
42
|
-
rules: {
|
|
43
|
-
// recommended rules
|
|
44
|
-
...codeceptPlugin.configs.recommended.rules,
|
|
45
|
-
// extra rules
|
|
46
|
-
"new-cap": ["error", {
|
|
47
|
-
capIsNewExceptions: ["After", "AfterSuite", "Before", "BeforeSuite", "Feature", "Scenario"],
|
|
48
|
-
}],
|
|
49
|
-
"no-restricted-properties": ["warn", { object: "Scenario", property: "todo", message: "Unexpected unimplemented test." }],
|
|
50
|
-
"codeceptjs/no-skipped-tests": "warn",
|
|
51
|
-
// custom rules
|
|
52
|
-
...rules,
|
|
53
|
-
},
|
|
25
|
+
export default function codecept(envOptions) {
|
|
26
|
+
return concatConfigs(
|
|
27
|
+
// "codecept" plugin
|
|
28
|
+
createConfig(envOptions, {
|
|
29
|
+
// register rule implementations of the plugins
|
|
30
|
+
plugins: {
|
|
31
|
+
codeceptjs: codeceptPlugin,
|
|
54
32
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...chaiExpectPlugin.configs["recommended-flat"],
|
|
33
|
+
// register global symbols of CodeceptJS
|
|
34
|
+
languageOptions: {
|
|
35
|
+
globals: codeceptPlugin.environments.codeceptjs.globals,
|
|
59
36
|
},
|
|
60
|
-
|
|
37
|
+
// recommended rules
|
|
38
|
+
rules: codeceptPlugin.configs.recommended.rules,
|
|
39
|
+
}),
|
|
40
|
+
// "chai-expect" plugin
|
|
41
|
+
createConfig(envOptions, chaiExpectPlugin.configs["recommended-flat"]),
|
|
42
|
+
// custom rules
|
|
43
|
+
customRules(envOptions, {
|
|
44
|
+
"new-cap": ["error", {
|
|
45
|
+
capIsNewExceptions: ["After", "AfterSuite", "Before", "BeforeSuite", "Feature", "Scenario"],
|
|
46
|
+
}],
|
|
47
|
+
"no-restricted-properties": ["warn", { object: "Scenario", property: "todo", message: "Unexpected unimplemented test." }],
|
|
48
|
+
"codeceptjs/no-skipped-tests": "warn",
|
|
49
|
+
}));
|
|
61
50
|
}
|
|
@@ -11,10 +11,10 @@ export interface EnvEslintOptions extends EnvBaseOptions {
|
|
|
11
11
|
* Wraps the following packages:
|
|
12
12
|
* - `eslint-plugin-eslint-plugin`
|
|
13
13
|
*
|
|
14
|
-
* @param
|
|
14
|
+
* @param envOptions
|
|
15
15
|
* Configuration options for the environment.
|
|
16
16
|
*
|
|
17
17
|
* @returns
|
|
18
18
|
* An array of configuration objects to be added to the flat configuration.
|
|
19
19
|
*/
|
|
20
|
-
export default function eslint(
|
|
20
|
+
export default function eslint(envOptions: EnvEslintOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import eslintPlugin from "eslint-plugin-eslint-plugin";
|
|
2
|
+
import { concatConfigs, createConfig, customRules } from "../shared/env-utils.js";
|
|
2
3
|
// exports ====================================================================
|
|
3
4
|
/**
|
|
4
5
|
* Adds linter rules for ESLint plugin implementations.
|
|
@@ -6,29 +7,16 @@ import eslintPlugin from "eslint-plugin-eslint-plugin";
|
|
|
6
7
|
* Wraps the following packages:
|
|
7
8
|
* - `eslint-plugin-eslint-plugin`
|
|
8
9
|
*
|
|
9
|
-
* @param
|
|
10
|
+
* @param envOptions
|
|
10
11
|
* Configuration options for the environment.
|
|
11
12
|
*
|
|
12
13
|
* @returns
|
|
13
14
|
* An array of configuration objects to be added to the flat configuration.
|
|
14
15
|
*/
|
|
15
|
-
export default function eslint(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// register rule implementations and recommended rules
|
|
22
|
-
{
|
|
23
|
-
files,
|
|
24
|
-
ignores,
|
|
25
|
-
...pluginConfig,
|
|
26
|
-
},
|
|
27
|
-
// reconfigure plugin rules
|
|
28
|
-
{
|
|
29
|
-
files,
|
|
30
|
-
ignores,
|
|
31
|
-
rules,
|
|
32
|
-
},
|
|
33
|
-
];
|
|
16
|
+
export default function eslint(envOptions) {
|
|
17
|
+
return concatConfigs(
|
|
18
|
+
// register rule implementations and recommended rules
|
|
19
|
+
createConfig(envOptions, eslintPlugin.configs["flat/rules-recommended"]),
|
|
20
|
+
// custom rules
|
|
21
|
+
customRules(envOptions));
|
|
34
22
|
}
|
|
@@ -12,10 +12,10 @@ export interface EnvJestOptions extends EnvBaseOptions {
|
|
|
12
12
|
* Wraps the following packages:
|
|
13
13
|
* - `eslint-plugin-jest`
|
|
14
14
|
*
|
|
15
|
-
* @param
|
|
15
|
+
* @param envOptions
|
|
16
16
|
* Configuration options for the environment.
|
|
17
17
|
*
|
|
18
18
|
* @returns
|
|
19
19
|
* An array of configuration objects to be added to the flat configuration.
|
|
20
20
|
*/
|
|
21
|
-
export default function jest(
|
|
21
|
+
export default function jest(envOptions: EnvJestOptions): TSESLint.FlatConfig.ConfigArray;
|
package/dist/eslint/env/jest.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import jestPlugin from "eslint-plugin-jest";
|
|
2
|
+
import { concatConfigs, createConfig, customRules } from "../shared/env-utils.js";
|
|
2
3
|
// functions ==================================================================
|
|
3
4
|
/**
|
|
4
5
|
* Creates configuration objects with global symbols and linter rules for unit
|
|
@@ -7,43 +8,36 @@ import jestPlugin from "eslint-plugin-jest";
|
|
|
7
8
|
* Wraps the following packages:
|
|
8
9
|
* - `eslint-plugin-jest`
|
|
9
10
|
*
|
|
10
|
-
* @param
|
|
11
|
+
* @param envOptions
|
|
11
12
|
* Configuration options for the environment.
|
|
12
13
|
*
|
|
13
14
|
* @returns
|
|
14
15
|
* An array of configuration objects to be added to the flat configuration.
|
|
15
16
|
*/
|
|
16
|
-
export default function jest(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"jest/prefer-spy-on": "error",
|
|
43
|
-
"jest/prefer-todo": "error",
|
|
44
|
-
"jest/require-top-level-describe": "error",
|
|
45
|
-
// custom rules
|
|
46
|
-
...rules,
|
|
47
|
-
},
|
|
48
|
-
}];
|
|
17
|
+
export default function jest(envOptions) {
|
|
18
|
+
return concatConfigs(
|
|
19
|
+
// register rule implementations, globals, and recommended rules
|
|
20
|
+
createConfig(envOptions, jestPlugin.configs["flat/recommended"]),
|
|
21
|
+
// add recommended stylistic rules
|
|
22
|
+
createConfig(envOptions, {
|
|
23
|
+
rules: jestPlugin.configs["flat/style"].rules,
|
|
24
|
+
}),
|
|
25
|
+
// custom rules
|
|
26
|
+
customRules(envOptions, {
|
|
27
|
+
"jest/consistent-test-it": ["error", { fn: "it" }],
|
|
28
|
+
"jest/no-commented-out-tests": "error",
|
|
29
|
+
"jest/no-conditional-expect": "off",
|
|
30
|
+
"jest/no-confusing-set-timeout": "error",
|
|
31
|
+
"jest/no-duplicate-hooks": "error",
|
|
32
|
+
"jest/no-test-return-statement": "error",
|
|
33
|
+
"jest/prefer-comparison-matcher": "error",
|
|
34
|
+
"jest/prefer-equality-matcher": "error",
|
|
35
|
+
"jest/prefer-expect-resolves": "error",
|
|
36
|
+
"jest/prefer-hooks-on-top": "error",
|
|
37
|
+
"jest/prefer-lowercase-title": "error",
|
|
38
|
+
"jest/prefer-mock-promise-shorthand": "error",
|
|
39
|
+
"jest/prefer-spy-on": "error",
|
|
40
|
+
"jest/prefer-todo": "error",
|
|
41
|
+
"jest/require-top-level-describe": "error",
|
|
42
|
+
}));
|
|
49
43
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
-
import type { LanguageOptions,
|
|
2
|
+
import type { LanguageOptions, EnvRestrictedOptions } from "../shared/env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options for the environment preset "env.node".
|
|
5
5
|
*/
|
|
6
|
-
export interface EnvNodeOptions extends
|
|
6
|
+
export interface EnvNodeOptions extends EnvRestrictedOptions {
|
|
7
7
|
/**
|
|
8
8
|
* The module mode used by the linted files. Default value is "module".
|
|
9
9
|
*/
|
|
10
10
|
sourceType?: LanguageOptions["sourceType"];
|
|
11
|
-
/**
|
|
12
|
-
* All globals, imports, properties, and syntax constructs to be banned for
|
|
13
|
-
* the files included by the environment.
|
|
14
|
-
*/
|
|
15
|
-
restricted?: EnvRestrictedOptions;
|
|
16
11
|
}
|
|
17
12
|
/**
|
|
18
13
|
* Creates configuration objects with global symbols and linter rules for
|
|
@@ -21,10 +16,10 @@ export interface EnvNodeOptions extends EnvBaseOptions {
|
|
|
21
16
|
* Wraps the following packages:
|
|
22
17
|
* - `eslint-plugin-n`
|
|
23
18
|
*
|
|
24
|
-
* @param
|
|
19
|
+
* @param envOptions
|
|
25
20
|
* Configuration options for the environment.
|
|
26
21
|
*
|
|
27
22
|
* @returns
|
|
28
23
|
* An array of configuration objects to be added to the flat configuration.
|
|
29
24
|
*/
|
|
30
|
-
export default function node(
|
|
25
|
+
export default function node(envOptions: EnvNodeOptions): TSESLint.FlatConfig.ConfigArray;
|
package/dist/eslint/env/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import nodePlugin from "eslint-plugin-n";
|
|
2
|
-
import {
|
|
2
|
+
import { concatConfigs, createConfig, restrictedRules, customRules } from "../shared/env-utils.js";
|
|
3
3
|
// functions ==================================================================
|
|
4
4
|
/**
|
|
5
5
|
* Creates configuration objects with global symbols and linter rules for
|
|
@@ -8,44 +8,30 @@ import { generateRestrictedRules } from "../shared/env-utils.js";
|
|
|
8
8
|
* Wraps the following packages:
|
|
9
9
|
* - `eslint-plugin-n`
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param envOptions
|
|
12
12
|
* Configuration options for the environment.
|
|
13
13
|
*
|
|
14
14
|
* @returns
|
|
15
15
|
* An array of configuration objects to be added to the flat configuration.
|
|
16
16
|
*/
|
|
17
|
-
export default function node(
|
|
18
|
-
// configuration
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
files,
|
|
29
|
-
ignores,
|
|
30
|
-
...nodeConfig,
|
|
31
|
-
settings: {
|
|
32
|
-
node: {
|
|
33
|
-
tryExtensions: [".js", ".ts", ".d.ts"], // automatically add missing extensions in imports
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
// reconfigure plugin rules
|
|
38
|
-
{
|
|
39
|
-
files,
|
|
40
|
-
ignores,
|
|
41
|
-
rules: {
|
|
42
|
-
"n/no-unsupported-features/node-builtins": ["error", { allowExperimental: true }],
|
|
43
|
-
"n/prefer-node-protocol": "error",
|
|
44
|
-
...restricted.rules,
|
|
45
|
-
...rules,
|
|
17
|
+
export default function node(envOptions) {
|
|
18
|
+
// the plugin configuration key, according to source module type
|
|
19
|
+
const configKey = (envOptions.sourceType === "commonjs") ? "flat/recommended-script" : "flat/recommended-module";
|
|
20
|
+
return concatConfigs(
|
|
21
|
+
// register rule implementations
|
|
22
|
+
createConfig(envOptions, {
|
|
23
|
+
...nodePlugin.configs[configKey],
|
|
24
|
+
settings: {
|
|
25
|
+
node: {
|
|
26
|
+
tryExtensions: [".js", ".ts", ".d.ts"], // automatically add missing extensions in imports
|
|
46
27
|
},
|
|
47
28
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
}),
|
|
30
|
+
// generate the "no-restricted-?" rules according to passed configuration
|
|
31
|
+
restrictedRules(envOptions),
|
|
32
|
+
// custom rules
|
|
33
|
+
customRules(envOptions, {
|
|
34
|
+
"n/no-unsupported-features/node-builtins": ["error", { allowExperimental: true }],
|
|
35
|
+
"n/prefer-node-protocol": "error",
|
|
36
|
+
}));
|
|
51
37
|
}
|
|
@@ -4,15 +4,19 @@ import { type RuleNoInvalidModulesOptions } from "../rules/no-invalid-modules.js
|
|
|
4
4
|
/**
|
|
5
5
|
* Configuration options for the environment preset "env.project".
|
|
6
6
|
*/
|
|
7
|
-
export interface EnvProjectOptions extends EnvBaseOptions
|
|
7
|
+
export interface EnvProjectOptions extends EnvBaseOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Options to be passed to the rule "env-project/no-invalid-modules".
|
|
10
|
+
*/
|
|
11
|
+
modules?: RuleNoInvalidModulesOptions;
|
|
8
12
|
}
|
|
9
13
|
/**
|
|
10
14
|
* Adds custom linter rules for checking project setup and module hierarchy.
|
|
11
15
|
*
|
|
12
|
-
* @param
|
|
16
|
+
* @param envOptions
|
|
13
17
|
* Configuration options for the environment.
|
|
14
18
|
*
|
|
15
19
|
* @returns
|
|
16
20
|
* An array of configuration objects to be added to the flat configuration.
|
|
17
21
|
*/
|
|
18
|
-
export default function project(
|
|
22
|
+
export default function project(envOptions: EnvProjectOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -1,35 +1,32 @@
|
|
|
1
|
+
import { concatConfigs, createConfig, customRules } from "../shared/env-utils.js";
|
|
1
2
|
import noAmdModuleDirective from "../rules/no-amd-module-directive.js";
|
|
2
3
|
import noInvalidModules from "../rules/no-invalid-modules.js";
|
|
3
4
|
// exports ====================================================================
|
|
4
5
|
/**
|
|
5
6
|
* Adds custom linter rules for checking project setup and module hierarchy.
|
|
6
7
|
*
|
|
7
|
-
* @param
|
|
8
|
+
* @param envOptions
|
|
8
9
|
* Configuration options for the environment.
|
|
9
10
|
*
|
|
10
11
|
* @returns
|
|
11
12
|
* An array of configuration objects to be added to the flat configuration.
|
|
12
13
|
*/
|
|
13
|
-
export default function project(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
rules: {
|
|
23
|
-
"no-amd-module-directive": noAmdModuleDirective,
|
|
24
|
-
"no-invalid-modules": noInvalidModules,
|
|
25
|
-
},
|
|
14
|
+
export default function project(envOptions) {
|
|
15
|
+
return concatConfigs(
|
|
16
|
+
// register rule implementations
|
|
17
|
+
createConfig(envOptions, {
|
|
18
|
+
plugins: {
|
|
19
|
+
"env-project": {
|
|
20
|
+
rules: {
|
|
21
|
+
"no-amd-module-directive": noAmdModuleDirective,
|
|
22
|
+
"no-invalid-modules": noInvalidModules,
|
|
26
23
|
},
|
|
27
24
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
// custom rules
|
|
28
|
+
customRules(envOptions, {
|
|
29
|
+
"env-project/no-amd-module-directive": "error",
|
|
30
|
+
"env-project/no-invalid-modules": ["error", envOptions.modules ?? {}],
|
|
31
|
+
}));
|
|
35
32
|
}
|
|
@@ -20,10 +20,10 @@ export interface EnvReactOptions extends EnvBaseOptions {
|
|
|
20
20
|
* - `eslint-plugin-jsx-expressions`
|
|
21
21
|
* - `eslint-plugin-jsx-a11y`
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
23
|
+
* @param envOptions
|
|
24
24
|
* Configuration options for the environment.
|
|
25
25
|
*
|
|
26
26
|
* @returns
|
|
27
27
|
* An array of configuration objects to be added to the flat configuration.
|
|
28
28
|
*/
|
|
29
|
-
export default function react(
|
|
29
|
+
export default function react(envOptions: EnvReactOptions): TSESLint.FlatConfig.ConfigArray;
|