@open-xchange/linter-presets 1.6.0 → 1.7.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 +14 -1
- package/dist/eslint/core/base.d.ts +3 -4
- package/dist/eslint/core/base.js +95 -94
- package/dist/eslint/core/directives.d.ts +3 -3
- package/dist/eslint/core/directives.js +4 -4
- package/dist/eslint/core/js.d.ts +3 -3
- package/dist/eslint/core/js.js +4 -4
- package/dist/eslint/core/jsdoc.d.ts +3 -3
- package/dist/eslint/core/jsdoc.js +43 -42
- package/dist/eslint/core/json.d.ts +3 -4
- package/dist/eslint/core/json.js +4 -4
- package/dist/eslint/core/license.d.ts +4 -4
- package/dist/eslint/core/license.js +5 -5
- package/dist/eslint/core/markdown.d.ts +1 -1
- package/dist/eslint/core/markdown.js +1 -1
- package/dist/eslint/core/packages.d.ts +3 -4
- package/dist/eslint/core/packages.js +16 -15
- package/dist/eslint/core/promises.d.ts +3 -3
- package/dist/eslint/core/promises.js +18 -18
- package/dist/eslint/core/regexp.d.ts +3 -3
- package/dist/eslint/core/regexp.js +4 -5
- package/dist/eslint/core/stylistic.d.ts +3 -4
- package/dist/eslint/core/stylistic.js +99 -99
- package/dist/eslint/core/ts.d.ts +6 -3
- package/dist/eslint/core/ts.js +78 -72
- package/dist/eslint/core/vue.d.ts +3 -4
- package/dist/eslint/core/vue.js +4 -4
- package/dist/eslint/core/yaml.d.ts +3 -4
- package/dist/eslint/core/yaml.js +4 -4
- package/dist/eslint/env/browser.d.ts +3 -3
- package/dist/eslint/env/browser.js +18 -17
- package/dist/eslint/env/codecept.d.ts +3 -4
- package/dist/eslint/env/codecept.js +27 -26
- package/dist/eslint/env/decorators.d.ts +3 -4
- package/dist/eslint/env/decorators.js +19 -16
- package/dist/eslint/env/eslint.d.ts +3 -4
- package/dist/eslint/env/eslint.js +16 -15
- package/dist/eslint/env/jest.d.ts +3 -3
- package/dist/eslint/env/jest.js +37 -36
- package/dist/eslint/env/node.d.ts +3 -4
- package/dist/eslint/env/node.js +22 -21
- package/dist/eslint/env/project.d.ts +3 -4
- package/dist/eslint/env/project.js +25 -24
- package/dist/eslint/env/react.d.ts +3 -4
- package/dist/eslint/env/react.js +65 -64
- package/dist/eslint/env/tsconfig.d.ts +3 -4
- package/dist/eslint/env/tsconfig.js +14 -13
- package/dist/eslint/env/vitest.d.ts +3 -3
- package/dist/eslint/env/vitest.js +54 -53
- package/dist/eslint/index.d.ts +26 -21
- package/dist/eslint/index.js +15 -13
- package/dist/eslint/shared/env-utils.d.ts +11 -23
- package/dist/eslint/shared/env-utils.js +17 -31
- package/dist/eslint/shared/restricted.d.ts +3 -3
- package/dist/eslint/shared/restricted.js +12 -11
- package/dist/eslint/shared/unittest.d.ts +4 -5
- package/dist/eslint/shared/unittest.js +21 -20
- package/dist/stylelint/index.d.ts +9 -6
- package/dist/stylelint/index.js +7 -6
- package/dist/utils/resolver.d.ts +20 -10
- package/dist/utils/resolver.js +28 -10
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +1 -1
- package/docs/eslint/README.md +3 -30
- package/docs/stylelint/README.md +3 -30
- package/package.json +3 -3
package/dist/eslint/env/react.js
CHANGED
|
@@ -5,7 +5,7 @@ import reactRefreshPlugin from "eslint-plugin-react-refresh";
|
|
|
5
5
|
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
|
|
6
6
|
import { fixupPluginRules } from "@eslint/compat";
|
|
7
7
|
import { parser } from "typescript-eslint";
|
|
8
|
-
import {
|
|
8
|
+
import { createConfig, customRules, convertRuleWarningsToErrors } from "../shared/env-utils.js";
|
|
9
9
|
// functions ==================================================================
|
|
10
10
|
/**
|
|
11
11
|
* Creates configuration objects with linter rules for ReactJS.
|
|
@@ -21,71 +21,72 @@ import { createConfigArray, createConfig, customRules, convertRuleWarningsToErro
|
|
|
21
21
|
* Configuration options for the environment.
|
|
22
22
|
*
|
|
23
23
|
* @returns
|
|
24
|
-
*
|
|
24
|
+
* The configuration entries to be added to the resulting configuration array.
|
|
25
25
|
*/
|
|
26
26
|
export default function react(envOptions) {
|
|
27
27
|
// recommended configuration of the main plugin
|
|
28
28
|
const recommendedConfig = reactPlugin.configs["recommended-typescript"];
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
29
|
+
return [
|
|
30
|
+
// configure "react" plugin for all source files (JSX and TSX)
|
|
31
|
+
createConfig("react:recommended", envOptions, {
|
|
32
|
+
// auto-detect installed React version
|
|
33
|
+
languageOptions: {
|
|
34
|
+
parser: parser,
|
|
35
|
+
parserOptions: { projectService: true },
|
|
36
|
+
},
|
|
37
|
+
// register rule implementations and language settings
|
|
38
|
+
...recommendedConfig,
|
|
39
|
+
rules: {
|
|
40
|
+
// raise all recommended rules to "error" level
|
|
41
|
+
...convertRuleWarningsToErrors(recommendedConfig.rules),
|
|
42
|
+
// custom overrides
|
|
43
|
+
"@eslint-react/jsx-no-iife": "error",
|
|
44
|
+
"@eslint-react/jsx-no-undef": "error",
|
|
45
|
+
"@eslint-react/no-children-prop": "error",
|
|
46
|
+
"@eslint-react/no-class-component": "error",
|
|
47
|
+
"@eslint-react/no-duplicate-jsx-props": "error",
|
|
48
|
+
"@eslint-react/no-implicit-key": "error",
|
|
49
|
+
"@eslint-react/no-missing-component-display-name": "error",
|
|
50
|
+
"@eslint-react/no-useless-fragment": "error",
|
|
51
|
+
"@eslint-react/prefer-read-only-props": "error",
|
|
52
|
+
"@eslint-react/prefer-shorthand-boolean": "error",
|
|
53
|
+
"@eslint-react/prefer-shorthand-fragment": "error",
|
|
54
|
+
"@eslint-react/use-jsx-vars": "error",
|
|
55
|
+
"@eslint-react/dom/no-flush-sync": "error",
|
|
56
|
+
"@eslint-react/dom/no-unknown-property": "error",
|
|
57
|
+
"@eslint-react/hooks-extra/no-unnecessary-use-callback": "error",
|
|
58
|
+
"@eslint-react/hooks-extra/no-unnecessary-use-memo": "error",
|
|
59
|
+
"@eslint-react/naming-convention/filename-extension": ["error", { allow: "as-needed" }],
|
|
60
|
+
"@eslint-react/naming-convention/use-state": "error",
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
// "react-hooks" plugin
|
|
64
|
+
createConfig("react:hooks", envOptions, {
|
|
65
|
+
// register rule implementations of the plugins
|
|
66
|
+
plugins: {
|
|
67
|
+
"react-hooks": reactHooksPlugin,
|
|
68
|
+
},
|
|
69
|
+
// recommended rules (raise all recommended rules to "error" level)
|
|
70
|
+
rules: convertRuleWarningsToErrors(reactHooksPlugin.configs.recommended.rules),
|
|
71
|
+
}),
|
|
72
|
+
// "react-hooks-static-deps" plugin
|
|
73
|
+
(envOptions.additionalHooks ?? envOptions.staticHooks) && createConfig("react:exhaustive-deps", envOptions, {
|
|
74
|
+
plugins: {
|
|
75
|
+
"react-hooks-static-deps": fixupPluginRules(reactHooksStaticDepsPlugin), // https://github.com/stoikio/eslint-plugin-react-hooks-static-deps/issues/1
|
|
76
|
+
},
|
|
77
|
+
rules: {
|
|
78
|
+
"react-hooks/exhaustive-deps": "off",
|
|
79
|
+
"react-hooks-static-deps/exhaustive-deps": ["error", {
|
|
80
|
+
additionalHooks: envOptions.additionalHooks,
|
|
81
|
+
staticHooks: envOptions.staticHooks,
|
|
82
|
+
}],
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
// "react-refresh" plugin
|
|
86
|
+
createConfig("react:refresh", envOptions, reactRefreshPlugin.configs.vite),
|
|
87
|
+
// "jsx-a11y" plugin
|
|
88
|
+
createConfig("react:jsx-a11y", envOptions, jsxA11yPlugin.flatConfigs.recommended),
|
|
89
|
+
// custom rules
|
|
90
|
+
customRules("react:rules", envOptions),
|
|
91
|
+
];
|
|
91
92
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { EnvBaseOptions } from "../shared/env-utils.js";
|
|
1
|
+
import type { ConfigWithExtendsArg, EnvBaseOptions } from "../shared/env-utils.js";
|
|
3
2
|
/**
|
|
4
3
|
* Configuration options for the environment preset "env.tsconfig".
|
|
5
4
|
*/
|
|
@@ -16,6 +15,6 @@ export interface EnvTSConfigOptions extends EnvBaseOptions {
|
|
|
16
15
|
* Configuration options for the environment.
|
|
17
16
|
*
|
|
18
17
|
* @returns
|
|
19
|
-
*
|
|
18
|
+
* The configuration entries to be added to the resulting configuration array.
|
|
20
19
|
*/
|
|
21
|
-
export default function tsconfig(envOptions: EnvTSConfigOptions):
|
|
20
|
+
export default function tsconfig(envOptions: EnvTSConfigOptions): ConfigWithExtendsArg;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createConfig, customRules } from "../shared/env-utils.js";
|
|
2
2
|
// functions ==================================================================
|
|
3
3
|
/**
|
|
4
4
|
* Creates configuration objects for TypeScript projects.
|
|
@@ -7,19 +7,20 @@ import { createConfigArray, createConfig, customRules } from "../shared/env-util
|
|
|
7
7
|
* Configuration options for the environment.
|
|
8
8
|
*
|
|
9
9
|
* @returns
|
|
10
|
-
*
|
|
10
|
+
* The configuration entries to be added to the resulting configuration array.
|
|
11
11
|
*/
|
|
12
12
|
export default function tsconfig(envOptions) {
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
return [
|
|
14
|
+
// path to project configuration file
|
|
15
|
+
createConfig("tsconfig:language-options", envOptions, {
|
|
16
|
+
languageOptions: {
|
|
17
|
+
parserOptions: {
|
|
18
|
+
projectService: false,
|
|
19
|
+
project: envOptions.project,
|
|
20
|
+
},
|
|
20
21
|
},
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
}),
|
|
23
|
+
// custom rules
|
|
24
|
+
customRules("tsconfig:rules", envOptions),
|
|
25
|
+
];
|
|
25
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ConfigWithExtendsArg } from "../shared/env-utils.js";
|
|
2
2
|
import { type EnvUnitTestOptions } from "../shared/unittest.js";
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options for the environment preset "env.vitest".
|
|
@@ -19,6 +19,6 @@ export interface EnvVitestOptions extends EnvUnitTestOptions {
|
|
|
19
19
|
* Configuration options for the environment.
|
|
20
20
|
*
|
|
21
21
|
* @returns
|
|
22
|
-
*
|
|
22
|
+
* The configuration entries to be added to the resulting configuration array.
|
|
23
23
|
*/
|
|
24
|
-
export default function vitest(envOptions: EnvVitestOptions):
|
|
24
|
+
export default function vitest(envOptions: EnvVitestOptions): ConfigWithExtendsArg;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import vitestPlugin from "@vitest/eslint-plugin";
|
|
2
|
-
import { JS_GLOB,
|
|
2
|
+
import { JS_GLOB, createConfig, customRules } from "../shared/env-utils.js";
|
|
3
3
|
import { createUnitTestPluginConfigs } from "../shared/unittest.js";
|
|
4
4
|
// functions ==================================================================
|
|
5
5
|
/**
|
|
@@ -16,59 +16,60 @@ import { createUnitTestPluginConfigs } from "../shared/unittest.js";
|
|
|
16
16
|
* Configuration options for the environment.
|
|
17
17
|
*
|
|
18
18
|
* @returns
|
|
19
|
-
*
|
|
19
|
+
* The configuration entries to be added to the resulting configuration array.
|
|
20
20
|
*/
|
|
21
21
|
export default function vitest(envOptions) {
|
|
22
|
-
return
|
|
23
|
-
// "vitest" plugin
|
|
24
|
-
createConfig("vitest:recommended", envOptions, {
|
|
25
|
-
// register rule implementations of the plugins
|
|
26
|
-
plugins: {
|
|
27
|
-
vitest: vitestPlugin,
|
|
28
|
-
},
|
|
29
|
-
// register global symbols of Vitest
|
|
30
|
-
languageOptions: {
|
|
31
|
-
globals: vitestPlugin.environments.env.globals,
|
|
32
|
-
},
|
|
33
|
-
// recommended rules
|
|
34
|
-
rules: vitestPlugin.configs.recommended.rules,
|
|
35
|
-
}),
|
|
36
|
-
// "jest-dom" and "testing-library" plugin
|
|
37
|
-
createUnitTestPluginConfigs("vitest", envOptions),
|
|
38
|
-
// allow to add type-checking expectations in tests
|
|
39
|
-
createConfig("vitest:type-check", envOptions, {
|
|
40
|
-
ignores: JS_GLOB,
|
|
41
|
-
settings: {
|
|
42
|
-
vitest: {
|
|
43
|
-
typecheck: true,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
}),
|
|
47
|
-
// custom rules
|
|
48
|
-
customRules("vitest:rules", envOptions, {
|
|
22
|
+
return [
|
|
49
23
|
// "vitest" plugin
|
|
50
|
-
"vitest
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"vitest
|
|
64
|
-
|
|
65
|
-
"vitest
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
24
|
+
createConfig("vitest:recommended", envOptions, {
|
|
25
|
+
// register rule implementations of the plugins
|
|
26
|
+
plugins: {
|
|
27
|
+
vitest: vitestPlugin,
|
|
28
|
+
},
|
|
29
|
+
// register global symbols of Vitest
|
|
30
|
+
languageOptions: {
|
|
31
|
+
globals: vitestPlugin.environments.env.globals,
|
|
32
|
+
},
|
|
33
|
+
// recommended rules
|
|
34
|
+
rules: vitestPlugin.configs.recommended.rules,
|
|
35
|
+
}),
|
|
36
|
+
// "jest-dom" and "testing-library" plugin
|
|
37
|
+
createUnitTestPluginConfigs("vitest", envOptions),
|
|
38
|
+
// allow to add type-checking expectations in tests
|
|
39
|
+
createConfig("vitest:type-check", envOptions, {
|
|
40
|
+
ignores: JS_GLOB,
|
|
41
|
+
settings: {
|
|
42
|
+
vitest: {
|
|
43
|
+
typecheck: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
// custom rules
|
|
48
|
+
customRules("vitest:rules", envOptions, {
|
|
49
|
+
// "vitest" plugin
|
|
50
|
+
"vitest/consistent-test-it": "error",
|
|
51
|
+
"vitest/no-alias-methods": "error",
|
|
52
|
+
"vitest/no-disabled-tests": "warn",
|
|
53
|
+
"vitest/no-duplicate-hooks": "error",
|
|
54
|
+
"vitest/no-focused-tests": "error",
|
|
55
|
+
"vitest/no-standalone-expect": "error",
|
|
56
|
+
"vitest/no-test-prefixes": "error",
|
|
57
|
+
"vitest/no-test-return-statement": "error",
|
|
58
|
+
"vitest/prefer-comparison-matcher": "error",
|
|
59
|
+
"vitest/prefer-each": "error",
|
|
60
|
+
"vitest/prefer-equality-matcher": "error",
|
|
61
|
+
"vitest/prefer-expect-resolves": "error",
|
|
62
|
+
"vitest/prefer-hooks-in-order": "error",
|
|
63
|
+
"vitest/prefer-hooks-on-top": "error",
|
|
64
|
+
"vitest/prefer-mock-promise-shorthand": "error",
|
|
65
|
+
"vitest/prefer-spy-on": "error",
|
|
66
|
+
"vitest/prefer-strict-equal": "error",
|
|
67
|
+
"vitest/prefer-to-be": "error",
|
|
68
|
+
"vitest/prefer-to-contain": "error",
|
|
69
|
+
"vitest/prefer-to-have-length": "error",
|
|
70
|
+
"vitest/prefer-vi-mocked": "error",
|
|
71
|
+
"vitest/require-top-level-describe": "error",
|
|
72
|
+
"vitest/valid-expect-in-promise": "error",
|
|
73
|
+
}),
|
|
74
|
+
];
|
|
74
75
|
}
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
+
import { PathResolver } from "../utils/resolver.js";
|
|
2
3
|
import type { ConfigWithExtendsArg, LanguageOptions, PackagesOptions, StylisticOptions } from "./shared/env-utils.js";
|
|
3
4
|
import node from "./env/node.js";
|
|
4
5
|
import browser from "./env/browser.js";
|
|
@@ -10,19 +11,22 @@ import eslint from "./env/eslint.js";
|
|
|
10
11
|
import project from "./env/project.js";
|
|
11
12
|
import tsconfig from "./env/tsconfig.js";
|
|
12
13
|
import decorators from "./env/decorators.js";
|
|
13
|
-
export * from "../utils/resolver.js";
|
|
14
14
|
/**
|
|
15
15
|
* Configuration options for linting the entire project with ESLint.
|
|
16
16
|
*/
|
|
17
|
-
export interface
|
|
17
|
+
export interface ProjectOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The URL of the project root containing the ESLint configuration file.
|
|
20
|
+
* Should usually be set to `import.meta.url`.
|
|
21
|
+
*/
|
|
22
|
+
root: string;
|
|
18
23
|
/**
|
|
19
24
|
* Glob patterns with all files and folders to be ignored by ESLint.
|
|
20
25
|
*/
|
|
21
26
|
ignores?: readonly string[];
|
|
22
27
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* path to an absolute path.
|
|
28
|
+
* Path to the template file containing the license header to be used in
|
|
29
|
+
* all source files. May be a path relative to the project root.
|
|
26
30
|
*/
|
|
27
31
|
license?: string;
|
|
28
32
|
/**
|
|
@@ -46,28 +50,29 @@ export interface ConfigureOptions {
|
|
|
46
50
|
* A collection with all available environment presets.
|
|
47
51
|
*/
|
|
48
52
|
export declare const env: {
|
|
49
|
-
node: typeof node;
|
|
50
|
-
browser: typeof browser;
|
|
51
|
-
jest: typeof jest;
|
|
52
|
-
vitest: typeof vitest;
|
|
53
|
-
codecept: typeof codecept;
|
|
54
|
-
react: typeof react;
|
|
55
|
-
eslint: typeof eslint;
|
|
56
|
-
project: typeof project;
|
|
57
|
-
tsconfig: typeof tsconfig;
|
|
58
|
-
decorators: typeof decorators;
|
|
53
|
+
readonly node: typeof node;
|
|
54
|
+
readonly browser: typeof browser;
|
|
55
|
+
readonly jest: typeof jest;
|
|
56
|
+
readonly vitest: typeof vitest;
|
|
57
|
+
readonly codecept: typeof codecept;
|
|
58
|
+
readonly react: typeof react;
|
|
59
|
+
readonly eslint: typeof eslint;
|
|
60
|
+
readonly project: typeof project;
|
|
61
|
+
readonly tsconfig: typeof tsconfig;
|
|
62
|
+
readonly decorators: typeof decorators;
|
|
59
63
|
};
|
|
60
64
|
/**
|
|
61
|
-
* Generates ESLint configuration
|
|
62
|
-
* entire project.
|
|
65
|
+
* Generates a complete ESLint configuration array.
|
|
63
66
|
*
|
|
64
67
|
* @param options
|
|
65
|
-
*
|
|
68
|
+
* Options for the base configuration that will be generated.
|
|
66
69
|
*
|
|
67
70
|
* @param configs
|
|
68
|
-
* Additional configuration entries
|
|
71
|
+
* Additional configuration entries: Each parameter may be a callback function
|
|
72
|
+
* that will be invoked with a `PathResolver` utility.
|
|
69
73
|
*
|
|
70
74
|
* @returns
|
|
71
|
-
*
|
|
75
|
+
* The resulting ESLint configuration array that must be returned from the
|
|
76
|
+
* `eslint.config.*` file.
|
|
72
77
|
*/
|
|
73
|
-
export declare function defineConfig(options:
|
|
78
|
+
export declare function defineConfig(options: ProjectOptions, ...configs: Array<ConfigWithExtendsArg | ((resolver: PathResolver) => ConfigWithExtendsArg)>): Linter.Config[];
|
package/dist/eslint/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { globalIgnores } from "@eslint/config-helpers";
|
|
2
|
-
import {
|
|
1
|
+
import { defineConfig as defineEslintConfig, globalIgnores } from "@eslint/config-helpers";
|
|
2
|
+
import { flattenDeepArrays } from "../utils/utils.js";
|
|
3
|
+
import { PathResolver } from "../utils/resolver.js";
|
|
3
4
|
import base from "./core/base.js";
|
|
4
5
|
import js from "./core/js.js";
|
|
5
6
|
import ts from "./core/ts.js";
|
|
@@ -24,8 +25,6 @@ import eslint from "./env/eslint.js";
|
|
|
24
25
|
import project from "./env/project.js";
|
|
25
26
|
import tsconfig from "./env/tsconfig.js";
|
|
26
27
|
import decorators from "./env/decorators.js";
|
|
27
|
-
// re-exports =================================================================
|
|
28
|
-
export * from "../utils/resolver.js";
|
|
29
28
|
// environment presets ========================================================
|
|
30
29
|
/**
|
|
31
30
|
* A collection with all available environment presets.
|
|
@@ -44,17 +43,18 @@ export const env = {
|
|
|
44
43
|
};
|
|
45
44
|
// functions ==================================================================
|
|
46
45
|
/**
|
|
47
|
-
* Generates ESLint configuration
|
|
48
|
-
* entire project.
|
|
46
|
+
* Generates a complete ESLint configuration array.
|
|
49
47
|
*
|
|
50
48
|
* @param options
|
|
51
|
-
*
|
|
49
|
+
* Options for the base configuration that will be generated.
|
|
52
50
|
*
|
|
53
51
|
* @param configs
|
|
54
|
-
* Additional configuration entries
|
|
52
|
+
* Additional configuration entries: Each parameter may be a callback function
|
|
53
|
+
* that will be invoked with a `PathResolver` utility.
|
|
55
54
|
*
|
|
56
55
|
* @returns
|
|
57
|
-
*
|
|
56
|
+
* The resulting ESLint configuration array that must be returned from the
|
|
57
|
+
* `eslint.config.*` file.
|
|
58
58
|
*/
|
|
59
59
|
export function defineConfig(options, ...configs) {
|
|
60
60
|
const ignores = [
|
|
@@ -94,7 +94,9 @@ export function defineConfig(options, ...configs) {
|
|
|
94
94
|
...options.stylistic?.indent,
|
|
95
95
|
},
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
// the resolver for relative file paths
|
|
98
|
+
const resolver = new PathResolver(options.root);
|
|
99
|
+
return defineEslintConfig(flattenDeepArrays(
|
|
98
100
|
// ignore certain files and folders
|
|
99
101
|
globalIgnores(ignores, "index:global-ignores"),
|
|
100
102
|
// module types and standard rules for all JS/TS source files
|
|
@@ -102,7 +104,7 @@ export function defineConfig(options, ...configs) {
|
|
|
102
104
|
// default configuration for JavaScript files
|
|
103
105
|
js(),
|
|
104
106
|
// default configuration for TypeScript files
|
|
105
|
-
ts(),
|
|
107
|
+
ts(resolver.root),
|
|
106
108
|
// default configuration for Vue.js files
|
|
107
109
|
vue(languageConfig, stylisticConfig),
|
|
108
110
|
// default configuration for JSON files
|
|
@@ -112,7 +114,7 @@ export function defineConfig(options, ...configs) {
|
|
|
112
114
|
// default configuration for Markdown files
|
|
113
115
|
markdown(),
|
|
114
116
|
// check for correct license headers
|
|
115
|
-
options.license ? license(options.license) : undefined,
|
|
117
|
+
options.license ? license(resolver.path(options.license)) : undefined,
|
|
116
118
|
// default configuration for ESLint inline directives
|
|
117
119
|
directives(),
|
|
118
120
|
// default configuration for outdated dependencies
|
|
@@ -128,5 +130,5 @@ export function defineConfig(options, ...configs) {
|
|
|
128
130
|
// custom rules
|
|
129
131
|
options.rules && { name: "index:custom-rules", rules: options.rules },
|
|
130
132
|
// custom configuration entries
|
|
131
|
-
configs);
|
|
133
|
+
configs.map(config => (typeof config === "function") ? config(resolver) : config)));
|
|
132
134
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import {
|
|
2
|
+
import type { ConfigWithExtends } from "@eslint/config-helpers";
|
|
3
3
|
import type { DeepRequired, DeepOptArray } from "../../utils/utils.js";
|
|
4
4
|
export type ConfigWithExtendsArg = DeepOptArray<ConfigWithExtends>;
|
|
5
5
|
/**
|
|
@@ -201,20 +201,8 @@ export declare const NO_IMPLICIT_COERCION_OPTIONS: {
|
|
|
201
201
|
*/
|
|
202
202
|
export declare function extGlob(extensions: string[]): string[];
|
|
203
203
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* parameters.
|
|
207
|
-
*
|
|
208
|
-
* @param configs
|
|
209
|
-
* The configuration objects to be flattened and filtered.
|
|
210
|
-
*
|
|
211
|
-
* @returns
|
|
212
|
-
* The flattened configuration array.
|
|
213
|
-
*/
|
|
214
|
-
export declare function createConfigArray(...configs: ConfigWithExtendsArg[]): Linter.Config[];
|
|
215
|
-
/**
|
|
216
|
-
* Creates a flat configuration object with "files" and "ignores" settings from
|
|
217
|
-
* an environment's "envOptions" object.
|
|
204
|
+
* Creates a configuration entry with "files" and "ignores" settings from an
|
|
205
|
+
* environment's "envOptions" object.
|
|
218
206
|
*
|
|
219
207
|
* @param name
|
|
220
208
|
* The name of the configuration entry.
|
|
@@ -222,20 +210,20 @@ export declare function createConfigArray(...configs: ConfigWithExtendsArg[]): L
|
|
|
222
210
|
* @param envOptions
|
|
223
211
|
* The environment options containing "files" and "ignores" settings.
|
|
224
212
|
*
|
|
225
|
-
* @param
|
|
226
|
-
* Properties for the
|
|
213
|
+
* @param config
|
|
214
|
+
* Properties for the configuration entry to be built. Additional "files" and
|
|
227
215
|
* "ignores" properties will be merged with the settings from "envOptions".
|
|
228
216
|
*
|
|
229
217
|
* @param rules
|
|
230
218
|
* Hard-coded rule settings to be added to the configuration.
|
|
231
219
|
*
|
|
232
220
|
* @returns
|
|
233
|
-
* The resulting
|
|
221
|
+
* The resulting configuration entry.
|
|
234
222
|
*/
|
|
235
|
-
export declare function createConfig(name: string, envOptions: EnvFilesOptions,
|
|
223
|
+
export declare function createConfig(name: string, envOptions: EnvFilesOptions, config: Linter.Config, rules?: Linter.RulesRecord): Linter.Config;
|
|
236
224
|
/**
|
|
237
|
-
* Creates a
|
|
238
|
-
*
|
|
225
|
+
* Creates a configuration entry with "files", "ignores", and "rules" settings
|
|
226
|
+
* from an environment's "envOptions" object.
|
|
239
227
|
*
|
|
240
228
|
* @param name
|
|
241
229
|
* The name of the configuration entry.
|
|
@@ -250,7 +238,7 @@ export declare function createConfig(name: string, envOptions: EnvFilesOptions,
|
|
|
250
238
|
* allow to override them.
|
|
251
239
|
*
|
|
252
240
|
* @returns
|
|
253
|
-
* The resulting
|
|
241
|
+
* The resulting configuration entry, if the environment options contain
|
|
254
242
|
* custom rule settings, otherwise `undefined`.
|
|
255
243
|
*/
|
|
256
244
|
export declare function customRules(name: string, envOptions: EnvBaseOptions, rules?: Linter.RulesRecord): Linter.Config | undefined;
|
|
@@ -265,7 +253,7 @@ export declare function customRules(name: string, envOptions: EnvBaseOptions, ru
|
|
|
265
253
|
* @returns
|
|
266
254
|
* The fixed configuration options.
|
|
267
255
|
*/
|
|
268
|
-
export declare function fixMissingFilesOption(configs:
|
|
256
|
+
export declare function fixMissingFilesOption(...configs: ConfigWithExtendsArg[]): ConfigWithExtends[];
|
|
269
257
|
/**
|
|
270
258
|
* Converts all warnings in the passed rule options to errors.
|
|
271
259
|
*
|