@open-xchange/linter-presets 0.0.6 → 0.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.
- package/CHANGELOG.md +19 -14
- package/README.md +3 -3
- package/dist/eslint/config/base.d.ts +16 -0
- package/{lib → dist}/eslint/config/base.js +5 -26
- package/dist/eslint/config/directives.d.ts +11 -0
- package/{lib → dist}/eslint/config/directives.js +1 -5
- package/dist/eslint/config/imports.d.ts +15 -0
- package/dist/eslint/config/imports.js +58 -0
- package/dist/eslint/config/js.d.ts +9 -0
- package/dist/eslint/config/js.js +32 -0
- package/dist/eslint/config/jsdoc.d.ts +11 -0
- package/{lib → dist}/eslint/config/jsdoc.js +1 -9
- package/dist/eslint/config/json.d.ts +15 -0
- package/{lib → dist}/eslint/config/json.js +2 -8
- package/dist/eslint/config/license.d.ts +14 -0
- package/{lib → dist}/eslint/config/license.js +12 -18
- package/dist/eslint/config/promises.d.ts +11 -0
- package/{lib → dist}/eslint/config/promises.js +3 -9
- package/dist/eslint/config/stylistic.d.ts +16 -0
- package/{lib → dist}/eslint/config/stylistic.js +12 -22
- package/dist/eslint/config/ts.d.ts +11 -0
- package/{lib → dist}/eslint/config/ts.js +9 -18
- package/dist/eslint/config/yaml.d.ts +15 -0
- package/{lib → dist}/eslint/config/yaml.js +2 -8
- package/dist/eslint/env/browser.d.ts +27 -0
- package/{lib → dist}/eslint/env/browser.js +5 -26
- package/dist/eslint/env/codecept.d.ts +22 -0
- package/{lib → dist}/eslint/env/codecept.js +4 -13
- package/dist/eslint/env/eslint.d.ts +20 -0
- package/{lib → dist}/eslint/env/eslint.js +2 -9
- package/dist/eslint/env/jest.d.ts +21 -0
- package/dist/eslint/env/jest.js +49 -0
- package/dist/eslint/env/node.d.ts +30 -0
- package/{lib → dist}/eslint/env/node.js +2 -14
- package/dist/eslint/env/project.d.ts +18 -0
- package/{lib → dist}/eslint/env/project.js +18 -25
- package/dist/eslint/env/react.d.ts +29 -0
- package/{lib → dist}/eslint/env/react.js +3 -15
- package/dist/eslint/env/tsconfig.d.ts +21 -0
- package/{lib → dist}/eslint/env/tsconfig.js +15 -21
- package/dist/eslint/env/vitest.d.ts +23 -0
- package/{lib → dist}/eslint/env/vitest.js +3 -16
- package/dist/eslint/index.d.ts +63 -0
- package/{lib → dist}/eslint/index.js +3 -25
- package/dist/eslint/rules/no-amd-module-directive.d.ts +3 -0
- package/{lib → dist}/eslint/rules/no-amd-module-directive.js +22 -26
- package/dist/eslint/rules/no-invalid-modules.d.ts +38 -0
- package/{lib → dist}/eslint/rules/no-invalid-modules.js +40 -63
- package/dist/eslint/shared/env-utils.d.ts +150 -0
- package/{lib → dist}/eslint/shared/env-utils.js +12 -23
- package/dist/eslint/shared/rule-utils.d.ts +76 -0
- package/{lib → dist}/eslint/shared/rule-utils.js +27 -60
- package/dist/index.d.ts +3 -0
- package/{lib → dist}/index.js +0 -1
- package/dist/stylelint/index.d.ts +49 -0
- package/{lib → dist}/stylelint/index.js +5 -22
- package/dist/utils/index.d.ts +12 -0
- package/{lib → dist}/utils/index.js +2 -5
- package/package.json +12 -4
- package/lib/eslint/config/imports.js +0 -68
- package/lib/eslint/config/js.js +0 -36
- package/lib/eslint/env/browser.d.ts +0 -21
- package/lib/eslint/env/codecept.d.ts +0 -14
- package/lib/eslint/env/eslint.d.ts +0 -14
- package/lib/eslint/env/jest.d.ts +0 -14
- package/lib/eslint/env/jest.js +0 -56
- package/lib/eslint/env/node.d.ts +0 -28
- package/lib/eslint/env/project.d.ts +0 -21
- package/lib/eslint/env/react.d.ts +0 -20
- package/lib/eslint/env/tsconfig.d.ts +0 -20
- package/lib/eslint/env/vitest.d.ts +0 -14
- package/lib/eslint/index.d.ts +0 -43
- package/lib/eslint/shared/env-utils.d.ts +0 -95
- package/lib/eslint/shared/types.d.ts +0 -107
- package/lib/index.d.ts +0 -4
- package/lib/stylelint/index.d.ts +0 -18
- package/lib/stylelint/types.d.ts +0 -44
- package/lib/utils/index.d.ts +0 -4
- /package/{lib → doc}/eslint/README.md +0 -0
- /package/{lib → doc}/eslint/env/browser.md +0 -0
- /package/{lib → doc}/eslint/env/codecept.md +0 -0
- /package/{lib → doc}/eslint/env/eslint.md +0 -0
- /package/{lib → doc}/eslint/env/jest.md +0 -0
- /package/{lib → doc}/eslint/env/node.md +0 -0
- /package/{lib → doc}/eslint/env/project.md +0 -0
- /package/{lib → doc}/eslint/env/react.md +0 -0
- /package/{lib → doc}/eslint/env/tsconfig.md +0 -0
- /package/{lib → doc}/eslint/env/vitest.md +0 -0
- /package/{lib → doc}/stylelint/README.md +0 -0
- /package/{lib → doc}/utils/README.md +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
import type { EnvBaseOptions } from "../shared/env-utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the environment preset "env.react".
|
|
5
|
+
*/
|
|
6
|
+
export interface EnvReactOptions extends EnvBaseOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for the rule "react-hooks-static-deps/exhaustive-deps".
|
|
9
|
+
*/
|
|
10
|
+
staticHooks?: Record<string, boolean | boolean[] | Record<string, boolean>>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates configuration objects with linter rules for ReactJS.
|
|
14
|
+
*
|
|
15
|
+
* Wraps the following packages:
|
|
16
|
+
* - `eslint-plugin-react`
|
|
17
|
+
* - `eslint-plugin-react-hooks`
|
|
18
|
+
* - `eslint-plugin-react-hooks-static-deps`
|
|
19
|
+
* - `eslint-plugin-react-refresh`
|
|
20
|
+
* - `eslint-plugin-jsx-expressions`
|
|
21
|
+
* - `eslint-plugin-jsx-a11y`
|
|
22
|
+
*
|
|
23
|
+
* @param options
|
|
24
|
+
* Configuration options for the environment.
|
|
25
|
+
*
|
|
26
|
+
* @returns
|
|
27
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
28
|
+
*/
|
|
29
|
+
export default function react(options: EnvReactOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { fixupPluginRules } from "@eslint/compat";
|
|
3
1
|
import reactPlugin from "eslint-plugin-react";
|
|
4
2
|
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
5
3
|
import reactHooksStaticDepsPlugin from "eslint-plugin-react-hooks-static-deps";
|
|
6
4
|
import reactRefreshPlugin from "eslint-plugin-react-refresh";
|
|
7
5
|
import jsxExpressionsPlugin from "eslint-plugin-jsx-expressions";
|
|
8
6
|
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
|
|
9
|
-
|
|
7
|
+
import { fixupPluginRules } from "@eslint/compat";
|
|
10
8
|
// functions ==================================================================
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Creates configuration objects with linter rules for ReactJS.
|
|
14
11
|
*
|
|
@@ -20,24 +17,20 @@ import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
|
|
|
20
17
|
* - `eslint-plugin-jsx-expressions`
|
|
21
18
|
* - `eslint-plugin-jsx-a11y`
|
|
22
19
|
*
|
|
23
|
-
* @param
|
|
20
|
+
* @param options
|
|
24
21
|
* Configuration options for the environment.
|
|
25
22
|
*
|
|
26
|
-
* @returns
|
|
23
|
+
* @returns
|
|
27
24
|
* An array of configuration objects to be added to the flat configuration.
|
|
28
25
|
*/
|
|
29
26
|
export default function react(options) {
|
|
30
|
-
|
|
31
27
|
// configuration properties
|
|
32
28
|
const { files, ignores = [], rules, staticHooks = {} } = options;
|
|
33
|
-
|
|
34
29
|
return [
|
|
35
|
-
|
|
36
30
|
// configure plugins and rules for all source files (JSX and TSX)
|
|
37
31
|
{
|
|
38
32
|
files,
|
|
39
33
|
ignores,
|
|
40
|
-
|
|
41
34
|
// register rule implementations of the plugins
|
|
42
35
|
plugins: {
|
|
43
36
|
react: fixupPluginRules(reactPlugin), // https://github.com/jsx-eslint/eslint-plugin-react/issues/3699
|
|
@@ -47,18 +40,15 @@ export default function react(options) {
|
|
|
47
40
|
"jsx-expressions": fixupPluginRules(jsxExpressionsPlugin), // https://github.com/hluisson/eslint-plugin-jsx-expressions/issues/18
|
|
48
41
|
"jsx-a11y": jsxA11yPlugin,
|
|
49
42
|
},
|
|
50
|
-
|
|
51
43
|
settings: {
|
|
52
44
|
react: {
|
|
53
45
|
version: "detect",
|
|
54
46
|
},
|
|
55
47
|
},
|
|
56
|
-
|
|
57
48
|
// enable JSX support
|
|
58
49
|
languageOptions: {
|
|
59
50
|
parserOptions: reactPlugin.configs.recommended.parserOptions,
|
|
60
51
|
},
|
|
61
|
-
|
|
62
52
|
// configure plugin rules
|
|
63
53
|
rules: {
|
|
64
54
|
// recommended rules
|
|
@@ -87,12 +77,10 @@ export default function react(options) {
|
|
|
87
77
|
...rules,
|
|
88
78
|
},
|
|
89
79
|
},
|
|
90
|
-
|
|
91
80
|
// additional rules for TSX only
|
|
92
81
|
{
|
|
93
82
|
files,
|
|
94
83
|
ignores: [...ignores, "**/*.{js,jsx}"],
|
|
95
|
-
|
|
96
84
|
// configure plugin rules
|
|
97
85
|
rules: {
|
|
98
86
|
// replace "react/jsx-no-leaked-render" rule with advanced alternative
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
import type { EnvBaseOptions } from "../shared/env-utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the environment preset "env.tsconfig".
|
|
5
|
+
*/
|
|
6
|
+
export interface EnvTSConfigOptions extends EnvBaseOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The path to the TypeScript project configuration file (`tsconfig.json`).
|
|
9
|
+
*/
|
|
10
|
+
project: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates configuration objects for TypeScript projects.
|
|
14
|
+
*
|
|
15
|
+
* @param options
|
|
16
|
+
* Configuration options for the environment.
|
|
17
|
+
*
|
|
18
|
+
* @returns
|
|
19
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
20
|
+
*/
|
|
21
|
+
export default function tsconfig(options: EnvTSConfigOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
|
|
2
1
|
// functions ==================================================================
|
|
3
|
-
|
|
4
2
|
/**
|
|
5
3
|
* Creates configuration objects for TypeScript projects.
|
|
6
4
|
*
|
|
7
|
-
* @param
|
|
5
|
+
* @param options
|
|
8
6
|
* Configuration options for the environment.
|
|
9
7
|
*
|
|
10
|
-
* @returns
|
|
8
|
+
* @returns
|
|
11
9
|
* An array of configuration objects to be added to the flat configuration.
|
|
12
10
|
*/
|
|
13
11
|
export default function tsconfig(options) {
|
|
14
|
-
|
|
15
12
|
// configuration properties
|
|
16
13
|
const { files, ignores = [], rules } = options;
|
|
17
|
-
|
|
18
14
|
return [{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
files,
|
|
16
|
+
ignores,
|
|
17
|
+
// path to project configuration file
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parserOptions: {
|
|
20
|
+
project: options.project,
|
|
21
|
+
},
|
|
26
22
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
}];
|
|
23
|
+
// configure plugin rules
|
|
24
|
+
rules: {
|
|
25
|
+
// custom rules
|
|
26
|
+
...rules,
|
|
27
|
+
},
|
|
28
|
+
}];
|
|
35
29
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
import type { EnvBaseOptions } from "../shared/env-utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for the environment preset "env.vitest".
|
|
5
|
+
*/
|
|
6
|
+
export interface EnvVitestOptions extends EnvBaseOptions {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates configuration objects with global symbols and linter rules for unit
|
|
10
|
+
* tests using Vitest.
|
|
11
|
+
*
|
|
12
|
+
* Wraps the following packages:
|
|
13
|
+
* - `eslint-plugin-vitest`
|
|
14
|
+
* - `eslint-plugin-jest-dom`
|
|
15
|
+
* - `eslint-plugin-testing-library`
|
|
16
|
+
*
|
|
17
|
+
* @param options
|
|
18
|
+
* Configuration options for the environment.
|
|
19
|
+
*
|
|
20
|
+
* @returns
|
|
21
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
22
|
+
*/
|
|
23
|
+
export default function vitest(options: EnvVitestOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { fixupPluginRules } from "@eslint/compat";
|
|
3
1
|
import vitestPlugin from "eslint-plugin-vitest";
|
|
4
2
|
import jestDomPlugin from "eslint-plugin-jest-dom";
|
|
5
3
|
import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
6
|
-
|
|
4
|
+
import { fixupPluginRules } from "@eslint/compat";
|
|
7
5
|
// functions ==================================================================
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* Creates configuration objects with global symbols and linter rules for unit
|
|
11
8
|
* tests using Vitest.
|
|
@@ -15,34 +12,28 @@ import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
|
15
12
|
* - `eslint-plugin-jest-dom`
|
|
16
13
|
* - `eslint-plugin-testing-library`
|
|
17
14
|
*
|
|
18
|
-
* @param
|
|
15
|
+
* @param options
|
|
19
16
|
* Configuration options for the environment.
|
|
20
17
|
*
|
|
21
|
-
* @returns
|
|
18
|
+
* @returns
|
|
22
19
|
* An array of configuration objects to be added to the flat configuration.
|
|
23
20
|
*/
|
|
24
21
|
export default function vitest(options) {
|
|
25
|
-
|
|
26
22
|
// configuration properties
|
|
27
23
|
const { files, ignores = [], rules } = options;
|
|
28
|
-
|
|
29
24
|
return [
|
|
30
|
-
|
|
31
25
|
// "vitest" plugin
|
|
32
26
|
{
|
|
33
27
|
files,
|
|
34
28
|
ignores,
|
|
35
|
-
|
|
36
29
|
// register rule implementations of the plugins
|
|
37
30
|
plugins: {
|
|
38
31
|
vitest: vitestPlugin,
|
|
39
32
|
},
|
|
40
|
-
|
|
41
33
|
// register global symbols of Vitest
|
|
42
34
|
languageOptions: {
|
|
43
35
|
globals: vitestPlugin.environments.env.globals,
|
|
44
36
|
},
|
|
45
|
-
|
|
46
37
|
// configure plugin rules
|
|
47
38
|
rules: {
|
|
48
39
|
// recommended rules
|
|
@@ -73,24 +64,20 @@ export default function vitest(options) {
|
|
|
73
64
|
...rules,
|
|
74
65
|
},
|
|
75
66
|
},
|
|
76
|
-
|
|
77
67
|
// "jest-dom" plugin
|
|
78
68
|
{
|
|
79
69
|
files,
|
|
80
70
|
ignores,
|
|
81
71
|
...jestDomPlugin.configs["flat/recommended"],
|
|
82
72
|
},
|
|
83
|
-
|
|
84
73
|
// "testing-library" plugin
|
|
85
74
|
{
|
|
86
75
|
files,
|
|
87
76
|
ignores,
|
|
88
|
-
|
|
89
77
|
// register rule implementations of the plugins
|
|
90
78
|
plugins: {
|
|
91
79
|
"testing-library": fixupPluginRules(testingLibraryPlugin), // https://github.com/testing-library/eslint-plugin-testing-library/issues/899
|
|
92
80
|
},
|
|
93
|
-
|
|
94
81
|
// configure plugin rules
|
|
95
82
|
rules: {
|
|
96
83
|
// recommended rules
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
+
import type { LanguageOptions, StylisticOptions } from "./shared/env-utils.js";
|
|
3
|
+
import tsconfig from "./env/tsconfig.js";
|
|
4
|
+
import node from "./env/node.js";
|
|
5
|
+
import browser from "./env/browser.js";
|
|
6
|
+
import jest from "./env/jest.js";
|
|
7
|
+
import vitest from "./env/vitest.js";
|
|
8
|
+
import codecept from "./env/codecept.js";
|
|
9
|
+
import react from "./env/react.js";
|
|
10
|
+
import project from "./env/project.js";
|
|
11
|
+
import eslint from "./env/eslint.js";
|
|
12
|
+
/**
|
|
13
|
+
* Configuration options for linting the entire project with ESLint.
|
|
14
|
+
*/
|
|
15
|
+
export interface ConfigureOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Glob patterns with all files and folders to be ignored by ESLint.
|
|
18
|
+
*/
|
|
19
|
+
ignores?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Full path to the template file containing the license header to be used
|
|
22
|
+
* in all source files. The function `resolver` helps to to convert a local
|
|
23
|
+
* path to an absolute path.
|
|
24
|
+
*/
|
|
25
|
+
license?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for language and project setup.
|
|
28
|
+
*/
|
|
29
|
+
language?: LanguageOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Configuration options for code style.
|
|
32
|
+
*/
|
|
33
|
+
stylistic?: StylisticOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Additional linter rules to be added to the global configuration.
|
|
36
|
+
*/
|
|
37
|
+
rules?: TSESLint.FlatConfig.Rules;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A collection with all available environment presets.
|
|
41
|
+
*/
|
|
42
|
+
export declare const env: {
|
|
43
|
+
tsconfig: typeof tsconfig;
|
|
44
|
+
node: typeof node;
|
|
45
|
+
browser: typeof browser;
|
|
46
|
+
jest: typeof jest;
|
|
47
|
+
vitest: typeof vitest;
|
|
48
|
+
codecept: typeof codecept;
|
|
49
|
+
react: typeof react;
|
|
50
|
+
project: typeof project;
|
|
51
|
+
eslint: typeof eslint;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Generates ESLint configuration objects targeting the source files in the
|
|
55
|
+
* entire project.
|
|
56
|
+
*
|
|
57
|
+
* @param options
|
|
58
|
+
* Plugin configuration options.
|
|
59
|
+
*
|
|
60
|
+
* @returns
|
|
61
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
62
|
+
*/
|
|
63
|
+
export declare function configure(options?: ConfigureOptions): TSESLint.FlatConfig.ConfigArray;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import base from "./config/base.js";
|
|
3
2
|
import js from "./config/js.js";
|
|
4
3
|
import ts from "./config/ts.js";
|
|
@@ -10,7 +9,6 @@ import imports from "./config/imports.js";
|
|
|
10
9
|
import promises from "./config/promises.js";
|
|
11
10
|
import jsdoc from "./config/jsdoc.js";
|
|
12
11
|
import stylistic from "./config/stylistic.js";
|
|
13
|
-
|
|
14
12
|
import tsconfig from "./env/tsconfig.js";
|
|
15
13
|
import node from "./env/node.js";
|
|
16
14
|
import browser from "./env/browser.js";
|
|
@@ -20,9 +18,7 @@ import codecept from "./env/codecept.js";
|
|
|
20
18
|
import react from "./env/react.js";
|
|
21
19
|
import project from "./env/project.js";
|
|
22
20
|
import eslint from "./env/eslint.js";
|
|
23
|
-
|
|
24
21
|
// environment presets ========================================================
|
|
25
|
-
|
|
26
22
|
/**
|
|
27
23
|
* A collection with all available environment presets.
|
|
28
24
|
*/
|
|
@@ -37,28 +33,24 @@ export const env = {
|
|
|
37
33
|
project,
|
|
38
34
|
eslint,
|
|
39
35
|
};
|
|
40
|
-
|
|
41
36
|
// functions ==================================================================
|
|
42
|
-
|
|
43
37
|
/**
|
|
44
|
-
* Generates
|
|
38
|
+
* Generates ESLint configuration objects targeting the source files in the
|
|
45
39
|
* entire project.
|
|
46
40
|
*
|
|
47
|
-
* @param
|
|
41
|
+
* @param options
|
|
48
42
|
* Plugin configuration options.
|
|
49
43
|
*
|
|
50
|
-
* @returns
|
|
44
|
+
* @returns
|
|
51
45
|
* An array of configuration objects to be added to the flat configuration.
|
|
52
46
|
*/
|
|
53
47
|
export function configure(options) {
|
|
54
|
-
|
|
55
48
|
// resolve language configuration options
|
|
56
49
|
const languageOptions = {
|
|
57
50
|
ecmaVersion: 2022,
|
|
58
51
|
sourceType: "module",
|
|
59
52
|
...options?.language,
|
|
60
53
|
};
|
|
61
|
-
|
|
62
54
|
// resolve stylistic configuration options
|
|
63
55
|
const stylisticOptions = {
|
|
64
56
|
indent: 2,
|
|
@@ -67,45 +59,31 @@ export function configure(options) {
|
|
|
67
59
|
dangle: "always",
|
|
68
60
|
...options?.stylistic,
|
|
69
61
|
};
|
|
70
|
-
|
|
71
62
|
return [
|
|
72
|
-
|
|
73
63
|
// ignore certain files and folders
|
|
74
64
|
...(options?.ignores?.length ? [{ ignores: options.ignores }] : []),
|
|
75
|
-
|
|
76
65
|
// module types and standard rules for all JS/TS source files
|
|
77
66
|
...base(languageOptions),
|
|
78
|
-
|
|
79
67
|
// default configuration for JavaScript files
|
|
80
68
|
...js(),
|
|
81
|
-
|
|
82
69
|
// default configuration for TypeScript files
|
|
83
70
|
...ts(),
|
|
84
|
-
|
|
85
71
|
// default configuration for JSON files
|
|
86
72
|
...json(stylisticOptions),
|
|
87
|
-
|
|
88
73
|
// default configuration for YAML files
|
|
89
74
|
...yaml(stylisticOptions),
|
|
90
|
-
|
|
91
75
|
// check for correct license headers
|
|
92
76
|
...(options?.license ? license(options.license) : []),
|
|
93
|
-
|
|
94
77
|
// default configuration for ESLint inline directives
|
|
95
78
|
...directives(),
|
|
96
|
-
|
|
97
79
|
// default configuration for imports/exports
|
|
98
80
|
...imports(languageOptions),
|
|
99
|
-
|
|
100
81
|
// default configuration for native promises
|
|
101
82
|
...promises(),
|
|
102
|
-
|
|
103
83
|
// default configuration for JSDoc
|
|
104
84
|
...jsdoc(),
|
|
105
|
-
|
|
106
85
|
// default configuration for code style checks
|
|
107
86
|
...stylistic(stylisticOptions),
|
|
108
|
-
|
|
109
87
|
// custom rules
|
|
110
88
|
...(options?.rules ? [{ rules: options.rules }] : []),
|
|
111
89
|
];
|
|
@@ -18,12 +18,9 @@
|
|
|
18
18
|
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
22
22
|
// exports ====================================================================
|
|
23
|
-
|
|
24
|
-
/** @type {import("eslint").Rule.RuleModule} */
|
|
25
|
-
export default {
|
|
26
|
-
|
|
23
|
+
export default ESLintUtils.RuleCreator.withoutDocs({
|
|
27
24
|
meta: {
|
|
28
25
|
type: "problem",
|
|
29
26
|
schema: [],
|
|
@@ -34,24 +31,23 @@ export default {
|
|
|
34
31
|
hasSuggestions: true,
|
|
35
32
|
fixable: "code",
|
|
36
33
|
},
|
|
37
|
-
|
|
38
|
-
create
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
34
|
+
defaultOptions: [],
|
|
35
|
+
create: context => ({
|
|
36
|
+
// fail if module contains triple-slash directive "<amd-module>"
|
|
37
|
+
Program(node) {
|
|
38
|
+
const amdComment = node.comments?.find(comment => /^\/\s*<amd-module/.test(comment.value));
|
|
39
|
+
if (amdComment) {
|
|
40
|
+
const deleteDirective = fixer => fixer.removeRange(amdComment.range);
|
|
41
|
+
context.report({
|
|
42
|
+
messageId: "UNEXPECTED_DIRECTIVE",
|
|
43
|
+
loc: amdComment.loc,
|
|
44
|
+
fix: deleteDirective,
|
|
45
|
+
suggest: [{
|
|
46
|
+
messageId: "UNEXPECTED_DIRECTIVE_FIX",
|
|
47
|
+
fix: deleteDirective,
|
|
48
|
+
}],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
+
export interface RuleNoInvalidModulesPackage {
|
|
3
|
+
/**
|
|
4
|
+
* Glob patterns selecting all source files that are part of the package.
|
|
5
|
+
*/
|
|
6
|
+
src: string | string[];
|
|
7
|
+
/**
|
|
8
|
+
* Specifies the names of all packages (keys of the `packages` dictionary)
|
|
9
|
+
* this package depends on.
|
|
10
|
+
*/
|
|
11
|
+
extends?: string | string[];
|
|
12
|
+
/**
|
|
13
|
+
* Set to `true` to mark an optional package that may be missing in an
|
|
14
|
+
* installation. Such a package cannot be imported statically (with
|
|
15
|
+
* `import` statement) from a non-optional package, but can only be loaded
|
|
16
|
+
* dynamically at runtime (by calling `import()`). The rule will mark all
|
|
17
|
+
* static imports of optional code as an error. Default value is `false`.
|
|
18
|
+
*/
|
|
19
|
+
optional?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface RuleNoInvalidModulesOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Maps all alias prefixes to actual paths in the project.
|
|
24
|
+
*/
|
|
25
|
+
alias?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Specifies glob patterns for external modules.
|
|
28
|
+
*/
|
|
29
|
+
external?: string | string[];
|
|
30
|
+
/**
|
|
31
|
+
* Allows to separate the source files into virtual packages.
|
|
32
|
+
*/
|
|
33
|
+
packages?: Record<string, RuleNoInvalidModulesPackage>;
|
|
34
|
+
}
|
|
35
|
+
type RuleOptions = [Required<RuleNoInvalidModulesOptions>];
|
|
36
|
+
type RuleMessageIds = "SOURCE_FILE_NOT_FOUND" | "UNEXPECTED_OPTIONAL_STATIC" | "INVALID_PACKAGE_HIERARCHY";
|
|
37
|
+
declare const _default: ESLintUtils.RuleModule<RuleMessageIds, RuleOptions, ESLintUtils.RuleListener>;
|
|
38
|
+
export default _default;
|