@open-xchange/linter-presets 1.5.1 → 1.6.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 +10 -0
- package/README.md +17 -23
- package/dist/eslint/core/base.js +122 -0
- package/dist/eslint/{config → core}/directives.js +6 -5
- package/dist/eslint/core/js.js +32 -0
- package/dist/eslint/core/jsdoc.js +59 -0
- package/dist/eslint/core/json.js +39 -0
- package/dist/eslint/{config → core}/license.js +13 -12
- package/dist/eslint/{config → core}/packages.d.ts +1 -1
- package/dist/eslint/{config → core}/packages.js +14 -11
- package/dist/eslint/core/promises.js +31 -0
- package/dist/eslint/core/regexp.d.ts +11 -0
- package/dist/eslint/core/regexp.js +21 -0
- package/dist/eslint/core/stylistic.js +121 -0
- package/dist/eslint/{config → core}/ts.js +10 -6
- package/dist/eslint/core/vue.js +98 -0
- package/dist/eslint/{config → core}/yaml.js +12 -12
- package/dist/eslint/env/browser.js +5 -5
- package/dist/eslint/env/codecept.js +5 -5
- package/dist/eslint/env/decorators.js +3 -3
- package/dist/eslint/env/eslint.js +4 -4
- package/dist/eslint/env/jest.js +7 -7
- package/dist/eslint/env/node.js +5 -5
- package/dist/eslint/env/project.js +4 -4
- package/dist/eslint/env/react.js +8 -8
- package/dist/eslint/env/tsconfig.js +4 -4
- package/dist/eslint/env/vitest.js +6 -6
- package/dist/eslint/index.d.ts +8 -4
- package/dist/eslint/index.js +63 -52
- package/dist/eslint/shared/env-utils.d.ts +30 -28
- package/dist/eslint/shared/env-utils.js +22 -26
- package/dist/eslint/shared/restricted.d.ts +4 -1
- package/dist/eslint/shared/restricted.js +14 -10
- package/dist/eslint/shared/unittest.d.ts +4 -1
- package/dist/eslint/shared/unittest.js +9 -6
- package/dist/stylelint/index.d.ts +2 -1
- package/dist/stylelint/index.js +3 -1
- package/dist/utils/{index.d.ts → resolver.d.ts} +1 -1
- package/dist/utils/{index.js → resolver.js} +1 -1
- package/dist/utils/utils.d.ts +31 -0
- package/dist/utils/utils.js +40 -0
- package/docs/eslint/README.md +83 -23
- package/docs/eslint/env/browser.md +12 -8
- package/docs/eslint/env/codecept.md +12 -8
- package/docs/eslint/env/decorators.md +12 -8
- package/docs/eslint/env/eslint.md +12 -8
- package/docs/eslint/env/jest.md +12 -8
- package/docs/eslint/env/node.md +12 -8
- package/docs/eslint/env/project.md +34 -22
- package/docs/eslint/env/react.md +12 -8
- package/docs/eslint/env/tsconfig.md +12 -9
- package/docs/eslint/env/vitest.md +12 -8
- package/docs/stylelint/README.md +45 -13
- package/package.json +20 -14
- package/dist/eslint/config/base.js +0 -120
- package/dist/eslint/config/js.js +0 -31
- package/dist/eslint/config/jsdoc.js +0 -56
- package/dist/eslint/config/json.js +0 -39
- package/dist/eslint/config/promises.js +0 -27
- package/dist/eslint/config/stylistic.js +0 -117
- package/dist/eslint/config/vue.js +0 -97
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/docs/utils/README.md +0 -30
- /package/dist/eslint/{config → core}/base.d.ts +0 -0
- /package/dist/eslint/{config → core}/directives.d.ts +0 -0
- /package/dist/eslint/{config → core}/js.d.ts +0 -0
- /package/dist/eslint/{config → core}/jsdoc.d.ts +0 -0
- /package/dist/eslint/{config → core}/json.d.ts +0 -0
- /package/dist/eslint/{config → core}/license.d.ts +0 -0
- /package/dist/eslint/{config → core}/markdown.d.ts +0 -0
- /package/dist/eslint/{config → core}/markdown.js +0 -0
- /package/dist/eslint/{config → core}/promises.d.ts +0 -0
- /package/dist/eslint/{config → core}/stylistic.d.ts +0 -0
- /package/dist/eslint/{config → core}/ts.d.ts +0 -0
- /package/dist/eslint/{config → core}/vue.d.ts +0 -0
- /package/dist/eslint/{config → core}/yaml.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## `1.6.0` – 2025-Jul-16
|
|
4
|
+
|
|
5
|
+
- changed: dedicated package exports `/eslint` and `/stylelint`
|
|
6
|
+
- changed: (ESLint) replaced `configure` function with `defineConfig` function
|
|
7
|
+
- changed: (StyleLint) replaced `configure` function with `defineConfig` function
|
|
8
|
+
- changed: replaced `resolver` function with `createResolver` function (exported from both sub packages)
|
|
9
|
+
- added: (ESLint) new plugin `eslint-plugin-regexp`
|
|
10
|
+
- added: (ESLint) disable `no-duplicate-imports` rule in `.d.ts` files
|
|
11
|
+
- chore: bump dependencies
|
|
12
|
+
|
|
3
13
|
## `1.5.1` – 2025-Jul-03
|
|
4
14
|
|
|
5
15
|
- chore: bump dependencies
|
package/README.md
CHANGED
|
@@ -4,49 +4,43 @@ This package provides configuration presets for [ESLint](https://eslint.org/) an
|
|
|
4
4
|
|
|
5
5
|
## ESLint
|
|
6
6
|
|
|
7
|
-
The module `eslint` exports a `
|
|
7
|
+
The module `eslint` exports a `defineConfig` function for setting up the entire project (e.g. TypeScript files, JSON files, license headers, etc.), and a set of environment presets that apply more ESLint plugins and rules to a specific subset of the project (e.g. browser code, unit test code, etc.).
|
|
8
8
|
|
|
9
9
|
Usage example:
|
|
10
10
|
|
|
11
|
-
```
|
|
12
|
-
// eslint.config.
|
|
13
|
-
import {
|
|
11
|
+
```ts
|
|
12
|
+
// eslint.config.ts
|
|
13
|
+
import { defineConfig, env } from "@open-xchange/linter-presets/eslint";
|
|
14
14
|
|
|
15
|
-
export default
|
|
15
|
+
export default defineConfig(
|
|
16
16
|
|
|
17
|
-
// global project configuration
|
|
18
|
-
|
|
17
|
+
// required parameter: global project configuration
|
|
18
|
+
{ /* config options */ },
|
|
19
19
|
|
|
20
20
|
// add environments
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
env.browser({ files: ["src/**/*.js"], /* ... */ }),
|
|
22
|
+
env.vitest({ files: ["test/**/*.js"], /* ... */ }),
|
|
23
23
|
|
|
24
24
|
// add custom configurations
|
|
25
25
|
{ /* ... */ },
|
|
26
|
-
|
|
26
|
+
);
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
See the [`eslint` module documentation](./
|
|
29
|
+
See the [`eslint` module documentation](./docs/eslint/README.md) for more details.
|
|
30
30
|
|
|
31
31
|
## StyleLint
|
|
32
32
|
|
|
33
|
-
The module `stylelint` exports a `
|
|
33
|
+
The module `stylelint` exports a `defineConfig` function for setting up the entire project (e.g. CSS files, SCSS files, license headers, etc.).
|
|
34
34
|
|
|
35
35
|
Usage example:
|
|
36
36
|
|
|
37
|
-
```
|
|
37
|
+
```ts
|
|
38
38
|
// stylelint.config.js
|
|
39
|
-
import {
|
|
39
|
+
import { defineConfig } from "@open-xchange/linter-presets/stylelint";
|
|
40
40
|
|
|
41
|
-
export default
|
|
41
|
+
export default defineConfig({
|
|
42
42
|
/* config options */
|
|
43
|
-
})
|
|
43
|
+
});
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
See the [`stylelint` module documentation](./
|
|
47
|
-
|
|
48
|
-
## Utils
|
|
49
|
-
|
|
50
|
-
The module `utils` exports utility functions to be used in ESLint and StyleLint configuration files.
|
|
51
|
-
|
|
52
|
-
See the [`utils` module documentation](./doc/utils/README.md) for more details.
|
|
46
|
+
See the [`stylelint` module documentation](./docs/stylelint/README.md) for more details.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import eslintJs from "@eslint/js";
|
|
2
|
+
import { SRC_GLOB, VUE_GLOB, NO_IMPLICIT_COERCION_OPTIONS, extGlob, createConfigArray } from "../shared/env-utils.js";
|
|
3
|
+
import { builtinRestrictedRules } from "../shared/restricted.js";
|
|
4
|
+
// functions ==================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Defines standard module settings and additional rules targeting JavaScript
|
|
7
|
+
* _and_ TypeScript source files.
|
|
8
|
+
*
|
|
9
|
+
* Wraps the following packages:
|
|
10
|
+
* - `@eslint/js`
|
|
11
|
+
*
|
|
12
|
+
* @param languageConfig
|
|
13
|
+
* Resolved configuration options.
|
|
14
|
+
*
|
|
15
|
+
* @returns
|
|
16
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
17
|
+
*/
|
|
18
|
+
export default function base(languageConfig) {
|
|
19
|
+
// returns language options for specific file extensions
|
|
20
|
+
const languageOptions = (sourceType, ...extensions) => {
|
|
21
|
+
const { ecmaVersion } = languageConfig;
|
|
22
|
+
return {
|
|
23
|
+
name: `base:language-options:${sourceType}:${extensions.join(",")}`,
|
|
24
|
+
files: extGlob(extensions),
|
|
25
|
+
languageOptions: { ecmaVersion, sourceType },
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
return createConfigArray(
|
|
29
|
+
// global linter configuration
|
|
30
|
+
{
|
|
31
|
+
name: "base:linter-options",
|
|
32
|
+
linterOptions: {
|
|
33
|
+
// report unused inline linter directives in source code
|
|
34
|
+
reportUnusedDisableDirectives: "error",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
// ECMA version and module type for ES modules
|
|
38
|
+
languageOptions("module", "mjs", "mts"),
|
|
39
|
+
// ECMA version and module type for CommonJS modules
|
|
40
|
+
languageOptions("commonjs", "cjs", "cts"),
|
|
41
|
+
// ECMA version and module type for *.js and *.ts files
|
|
42
|
+
languageOptions(languageConfig.sourceType, "js", "jsx", "ts", "tsx"),
|
|
43
|
+
// configure linter rules
|
|
44
|
+
{
|
|
45
|
+
name: "base:rules",
|
|
46
|
+
files: [...SRC_GLOB, ...VUE_GLOB],
|
|
47
|
+
rules: {
|
|
48
|
+
// enable all rules recommended by ESLint itself
|
|
49
|
+
...eslintJs.configs.recommended.rules,
|
|
50
|
+
// possible problems
|
|
51
|
+
"no-cond-assign": ["error", "except-parens"],
|
|
52
|
+
"no-constant-binary-expression": "error",
|
|
53
|
+
"no-constructor-return": "error",
|
|
54
|
+
"no-control-regex": "off",
|
|
55
|
+
"no-duplicate-imports": ["error", { allowSeparateTypeImports: true }],
|
|
56
|
+
"no-new-native-nonconstructor": "error",
|
|
57
|
+
"no-new-symbol": "off", // disabled in favour of "no-new-native-nonconstructor"
|
|
58
|
+
"no-promise-executor-return": ["error", { allowVoid: true }],
|
|
59
|
+
"no-self-compare": "error",
|
|
60
|
+
"no-template-curly-in-string": "error",
|
|
61
|
+
"no-unassigned-vars": "error",
|
|
62
|
+
"no-unreachable-loop": "error",
|
|
63
|
+
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
|
|
64
|
+
"no-unused-private-class-members": "error",
|
|
65
|
+
"require-atomic-updates": "error",
|
|
66
|
+
// suggestions
|
|
67
|
+
"block-scoped-var": "error",
|
|
68
|
+
curly: "error",
|
|
69
|
+
eqeqeq: "error",
|
|
70
|
+
"grouped-accessor-pairs": "error",
|
|
71
|
+
"new-cap": "error",
|
|
72
|
+
"no-alert": "error",
|
|
73
|
+
"no-caller": "error",
|
|
74
|
+
"no-console": "error",
|
|
75
|
+
"no-else-return": "error",
|
|
76
|
+
"no-empty": "off",
|
|
77
|
+
"no-empty-static-block": "error",
|
|
78
|
+
"no-eval": "error",
|
|
79
|
+
"no-extend-native": "error",
|
|
80
|
+
"no-extra-bind": "error",
|
|
81
|
+
"no-extra-label": "error",
|
|
82
|
+
"no-implicit-coercion": ["error", NO_IMPLICIT_COERCION_OPTIONS],
|
|
83
|
+
"no-implied-eval": "error",
|
|
84
|
+
"no-iterator": "error",
|
|
85
|
+
"no-label-var": "error",
|
|
86
|
+
"no-labels": "error",
|
|
87
|
+
"no-lone-blocks": "error",
|
|
88
|
+
"no-lonely-if": "error",
|
|
89
|
+
"no-multi-str": "error",
|
|
90
|
+
"no-new": "error",
|
|
91
|
+
"no-new-func": "error",
|
|
92
|
+
"no-new-wrappers": "error",
|
|
93
|
+
"no-object-constructor": "error",
|
|
94
|
+
"no-octal-escape": "error",
|
|
95
|
+
"no-proto": "error",
|
|
96
|
+
"no-return-assign": ["error", "except-parens"],
|
|
97
|
+
"no-script-url": "error",
|
|
98
|
+
"no-sequences": ["error", { allowInParentheses: false }],
|
|
99
|
+
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
100
|
+
"no-unused-expressions": "error",
|
|
101
|
+
"no-useless-assignment": "error",
|
|
102
|
+
"no-useless-call": "error",
|
|
103
|
+
"no-useless-computed-key": "error",
|
|
104
|
+
"no-useless-concat": "error",
|
|
105
|
+
"no-useless-rename": "error",
|
|
106
|
+
"no-useless-return": "error",
|
|
107
|
+
"no-var": "error",
|
|
108
|
+
"object-shorthand": "error",
|
|
109
|
+
"operator-assignment": "error",
|
|
110
|
+
"prefer-arrow-callback": "error",
|
|
111
|
+
"prefer-const": ["error", { destructuring: "all", ignoreReadBeforeAssign: true }],
|
|
112
|
+
"prefer-numeric-literals": "error",
|
|
113
|
+
"prefer-regex-literals": "error",
|
|
114
|
+
"prefer-rest-params": "error",
|
|
115
|
+
"prefer-spread": "error",
|
|
116
|
+
radix: "error",
|
|
117
|
+
"symbol-description": "error",
|
|
118
|
+
// built-in restricted items
|
|
119
|
+
...builtinRestrictedRules(),
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import commentsPluginConfigs from "@eslint-community/eslint-plugin-eslint-comments/configs";
|
|
2
|
-
import { SRC_GLOB, VUE_GLOB } from "../shared/env-utils.js";
|
|
2
|
+
import { SRC_GLOB, VUE_GLOB, createConfigArray } from "../shared/env-utils.js";
|
|
3
3
|
// functions ==================================================================
|
|
4
4
|
/**
|
|
5
5
|
* Checks inline linter directives.
|
|
@@ -12,8 +12,9 @@ import { SRC_GLOB, VUE_GLOB } from "../shared/env-utils.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export default function directives() {
|
|
14
14
|
// register rule implementations and recommended rules
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
return createConfigArray({
|
|
16
|
+
name: "directives:recommended",
|
|
17
|
+
files: [...SRC_GLOB, ...VUE_GLOB],
|
|
18
|
+
...commentsPluginConfigs.recommended,
|
|
19
|
+
});
|
|
19
20
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { JS_GLOB, NO_UNUSED_VARS_OPTIONS, createConfigArray } from "../shared/env-utils.js";
|
|
2
|
+
// functions ==================================================================
|
|
3
|
+
/**
|
|
4
|
+
* Defines additional standard rules targeting JavaScript but _not_ TypeScript
|
|
5
|
+
* source files.
|
|
6
|
+
*
|
|
7
|
+
* @returns
|
|
8
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
9
|
+
*/
|
|
10
|
+
export default function js() {
|
|
11
|
+
return createConfigArray({
|
|
12
|
+
name: "js:recommended",
|
|
13
|
+
files: JS_GLOB,
|
|
14
|
+
rules: {
|
|
15
|
+
// possible problems
|
|
16
|
+
"no-loss-of-precision": "off",
|
|
17
|
+
"no-unused-vars": ["error", NO_UNUSED_VARS_OPTIONS],
|
|
18
|
+
// suggestions
|
|
19
|
+
"default-param-last": "error",
|
|
20
|
+
"dot-notation": "error",
|
|
21
|
+
"no-array-constructor": "error",
|
|
22
|
+
"no-invalid-this": "error",
|
|
23
|
+
"no-loop-func": "error",
|
|
24
|
+
"no-redeclare": "error",
|
|
25
|
+
"no-shadow": ["error", { ignoreOnInitialization: true }],
|
|
26
|
+
"no-throw-literal": "error",
|
|
27
|
+
"no-useless-constructor": "error",
|
|
28
|
+
"prefer-promise-reject-errors": "error",
|
|
29
|
+
"require-await": "error",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
2
|
+
import { TS_GLOB, SRC_GLOB, createConfigArray } from "../shared/env-utils.js";
|
|
3
|
+
// functions ==================================================================
|
|
4
|
+
/**
|
|
5
|
+
* Checks the JSDoc comments in source files.
|
|
6
|
+
*
|
|
7
|
+
* Wraps the following packages:
|
|
8
|
+
* - `eslint-plugin-jsdoc`
|
|
9
|
+
*
|
|
10
|
+
* @returns
|
|
11
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
12
|
+
*/
|
|
13
|
+
export default function jsdoc() {
|
|
14
|
+
return createConfigArray(
|
|
15
|
+
// register rule implementations and recommended rules
|
|
16
|
+
{
|
|
17
|
+
name: "jsdoc:recommended",
|
|
18
|
+
files: SRC_GLOB,
|
|
19
|
+
...jsdocPlugin.configs["flat/recommended-error"],
|
|
20
|
+
},
|
|
21
|
+
// general configuration
|
|
22
|
+
{
|
|
23
|
+
name: "jsdoc:settings",
|
|
24
|
+
settings: {
|
|
25
|
+
jsdoc: {
|
|
26
|
+
tagNamePreference: {
|
|
27
|
+
// disallowed tags for ES6 keywords `const`, `class`, `extends`
|
|
28
|
+
augments: false,
|
|
29
|
+
class: false,
|
|
30
|
+
const: false,
|
|
31
|
+
constant: false,
|
|
32
|
+
constructor: false,
|
|
33
|
+
extends: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
// overrides for TypeScript files
|
|
39
|
+
{
|
|
40
|
+
name: "jsdoc:typescript",
|
|
41
|
+
files: TS_GLOB,
|
|
42
|
+
rules: {
|
|
43
|
+
...jsdocPlugin.configs["flat/recommended-typescript-error"].rules,
|
|
44
|
+
"jsdoc/check-param-names": ["error", { allowExtraTrailingParamDocs: true }], // overload signatures
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
// configure plugin rules
|
|
48
|
+
{
|
|
49
|
+
name: "jsdoc:rules",
|
|
50
|
+
files: SRC_GLOB,
|
|
51
|
+
rules: {
|
|
52
|
+
"jsdoc/check-template-names": "error",
|
|
53
|
+
"jsdoc/require-asterisk-prefix": "error",
|
|
54
|
+
"jsdoc/require-template": ["error", { requireSeparateTemplates: true }],
|
|
55
|
+
"jsdoc/require-throws": "error",
|
|
56
|
+
"jsdoc/tag-lines": "off",
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import jsonPlugin from "eslint-plugin-jsonc";
|
|
2
|
+
import { createConfigArray, fixMissingFilesOption } from "../shared/env-utils.js";
|
|
3
|
+
// functions ==================================================================
|
|
4
|
+
/**
|
|
5
|
+
* Defines standard linting rules for JSON files.
|
|
6
|
+
*
|
|
7
|
+
* Wraps the following packages:
|
|
8
|
+
* - `eslint-plugin-jsonc`
|
|
9
|
+
*
|
|
10
|
+
* @param stylisticConfig
|
|
11
|
+
* Resolved configuration options.
|
|
12
|
+
*
|
|
13
|
+
* @returns
|
|
14
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
15
|
+
*/
|
|
16
|
+
export default function json(stylisticConfig) {
|
|
17
|
+
// add missing "files" property in configurations with rules (otherwise, plugin conflicts with "@eslint/markdown")
|
|
18
|
+
return fixMissingFilesOption(createConfigArray(
|
|
19
|
+
// register rule implementations and recommended rules
|
|
20
|
+
jsonPlugin.configs["flat/recommended-with-json"],
|
|
21
|
+
// reconfigure plugin rules
|
|
22
|
+
{
|
|
23
|
+
name: "json:rules",
|
|
24
|
+
rules: {
|
|
25
|
+
"jsonc/array-bracket-spacing": "error",
|
|
26
|
+
"jsonc/comma-style": "error",
|
|
27
|
+
"jsonc/indent": ["error", stylisticConfig.indent.json],
|
|
28
|
+
"jsonc/key-spacing": ["error", { mode: "minimum" }],
|
|
29
|
+
"jsonc/no-irregular-whitespace": "error",
|
|
30
|
+
"jsonc/no-octal-escape": "error",
|
|
31
|
+
},
|
|
32
|
+
}, {
|
|
33
|
+
name: "json:tsconfig",
|
|
34
|
+
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
35
|
+
rules: {
|
|
36
|
+
"jsonc/no-comments": "off",
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import licensePlugin from "eslint-plugin-license-header";
|
|
2
|
-
import { SRC_GLOB } from "../shared/env-utils.js";
|
|
2
|
+
import { SRC_GLOB, createConfigArray } from "../shared/env-utils.js";
|
|
3
3
|
// functions ==================================================================
|
|
4
4
|
/**
|
|
5
5
|
* Checks the existence of license headers in source files.
|
|
@@ -14,15 +14,16 @@ import { SRC_GLOB } from "../shared/env-utils.js";
|
|
|
14
14
|
* An array of configuration objects to be added to the flat configuration.
|
|
15
15
|
*/
|
|
16
16
|
export default function license(path) {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
17
|
+
return createConfigArray({
|
|
18
|
+
name: "license:recommended",
|
|
19
|
+
files: SRC_GLOB,
|
|
20
|
+
// register rule implementations of the plugin
|
|
21
|
+
plugins: {
|
|
22
|
+
"license-header": licensePlugin,
|
|
23
|
+
},
|
|
24
|
+
// configure plugin rules
|
|
25
|
+
rules: {
|
|
26
|
+
"license-header/header": ["error", path],
|
|
27
|
+
},
|
|
28
|
+
});
|
|
28
29
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as dependPlugin from "eslint-plugin-depend";
|
|
2
|
+
import { createConfigArray } from "../shared/env-utils.js";
|
|
2
3
|
// functions ==================================================================
|
|
3
4
|
/**
|
|
4
5
|
* Defines linting rules for outdated or unneeded external dependencies.
|
|
@@ -13,16 +14,18 @@ import * as dependPlugin from "eslint-plugin-depend";
|
|
|
13
14
|
* An array of configuration objects to be added to the flat configuration.
|
|
14
15
|
*/
|
|
15
16
|
export default function packages(packagesConfig) {
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
return createConfigArray(
|
|
18
|
+
// register rule implementations and recommended rules
|
|
19
|
+
{
|
|
20
|
+
name: "packages:recommended",
|
|
21
|
+
...dependPlugin.configs["flat/recommended"],
|
|
22
|
+
}, {
|
|
23
|
+
name: "packages:rules",
|
|
24
|
+
rules: {
|
|
25
|
+
"depend/ban-dependencies": ["error", {
|
|
26
|
+
modules: packagesConfig.banned,
|
|
27
|
+
allowed: packagesConfig.allowed,
|
|
28
|
+
}],
|
|
26
29
|
},
|
|
27
|
-
|
|
30
|
+
});
|
|
28
31
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import promisePlugin from "eslint-plugin-promise";
|
|
2
|
+
import { createConfigArray } from "../shared/env-utils.js";
|
|
3
|
+
// functions ==================================================================
|
|
4
|
+
/**
|
|
5
|
+
* Checks for correct usage of native promises.
|
|
6
|
+
*
|
|
7
|
+
* Wraps the following packages:
|
|
8
|
+
* - `eslint-plugin-promise`
|
|
9
|
+
*
|
|
10
|
+
* @returns
|
|
11
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
12
|
+
*/
|
|
13
|
+
export default function promises() {
|
|
14
|
+
return createConfigArray(
|
|
15
|
+
// register rule implementations and recommended rules
|
|
16
|
+
{
|
|
17
|
+
name: "promises:recommended",
|
|
18
|
+
...promisePlugin.configs["flat/recommended"],
|
|
19
|
+
},
|
|
20
|
+
// reconfigure plugin rules
|
|
21
|
+
{
|
|
22
|
+
name: "promises:rules",
|
|
23
|
+
rules: {
|
|
24
|
+
"promise/always-return": ["error", { ignoreLastCallback: true }],
|
|
25
|
+
"promise/no-callback-in-promise": "off",
|
|
26
|
+
"promise/no-nesting": "error", // warning => error
|
|
27
|
+
"promise/no-return-in-finally": "error",
|
|
28
|
+
"promise/valid-params": "error", // warning => error
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Checks the regular expressions in source files.
|
|
4
|
+
*
|
|
5
|
+
* Wraps the following packages:
|
|
6
|
+
* - `eslint-plugin-regexp`
|
|
7
|
+
*
|
|
8
|
+
* @returns
|
|
9
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
10
|
+
*/
|
|
11
|
+
export default function regexp(): Linter.Config[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as regexpPlugin from "eslint-plugin-regexp";
|
|
2
|
+
import { SRC_GLOB, createConfigArray } from "../shared/env-utils.js";
|
|
3
|
+
// functions ==================================================================
|
|
4
|
+
/**
|
|
5
|
+
* Checks the regular expressions in source files.
|
|
6
|
+
*
|
|
7
|
+
* Wraps the following packages:
|
|
8
|
+
* - `eslint-plugin-regexp`
|
|
9
|
+
*
|
|
10
|
+
* @returns
|
|
11
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
12
|
+
*/
|
|
13
|
+
export default function regexp() {
|
|
14
|
+
return createConfigArray(
|
|
15
|
+
// register rule implementations and recommended rules
|
|
16
|
+
{
|
|
17
|
+
name: "regexp:recommended",
|
|
18
|
+
files: SRC_GLOB,
|
|
19
|
+
...regexpPlugin.configs["flat/recommended"],
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import stylisticPlugin from "@stylistic/eslint-plugin";
|
|
2
|
+
import migratePlugin from "@stylistic/eslint-plugin-migrate";
|
|
3
|
+
import { createConfigArray, getCommaDangleConfig } from "../shared/env-utils.js";
|
|
4
|
+
// functions ==================================================================
|
|
5
|
+
/**
|
|
6
|
+
* Defines standard (opinionated) linter rules for source code style.
|
|
7
|
+
*
|
|
8
|
+
* Wraps the following packages:
|
|
9
|
+
* - `@stylistic/eslint-plugin`
|
|
10
|
+
* - `@stylistic/eslint-plugin-migrate`
|
|
11
|
+
*
|
|
12
|
+
* @param stylisticConfig
|
|
13
|
+
* Resolved configuration options.
|
|
14
|
+
*
|
|
15
|
+
* @returns
|
|
16
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
17
|
+
*/
|
|
18
|
+
export default function stylistic(stylisticConfig) {
|
|
19
|
+
// configuration properties
|
|
20
|
+
const { indent, semi, quotes } = stylisticConfig;
|
|
21
|
+
return createConfigArray(
|
|
22
|
+
// globally disable all deprecated stylistic core rules
|
|
23
|
+
{
|
|
24
|
+
name: "stylistic:disable-legacy",
|
|
25
|
+
...stylisticPlugin.configs["disable-legacy"],
|
|
26
|
+
},
|
|
27
|
+
// "@stylistic" plugin
|
|
28
|
+
{
|
|
29
|
+
name: "stylistic:recommended",
|
|
30
|
+
// do not lint markdown files
|
|
31
|
+
ignores: ["**/*.md"],
|
|
32
|
+
// register rule implementations of the plugins
|
|
33
|
+
plugins: {
|
|
34
|
+
"@stylistic": stylisticPlugin,
|
|
35
|
+
},
|
|
36
|
+
// configure plugin rules
|
|
37
|
+
rules: {
|
|
38
|
+
"@stylistic/array-bracket-spacing": "error",
|
|
39
|
+
"@stylistic/arrow-spacing": "error",
|
|
40
|
+
"@stylistic/block-spacing": "error",
|
|
41
|
+
"@stylistic/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
42
|
+
"@stylistic/comma-dangle": getCommaDangleConfig(stylisticConfig),
|
|
43
|
+
"@stylistic/comma-spacing": "error",
|
|
44
|
+
"@stylistic/comma-style": "error",
|
|
45
|
+
"@stylistic/computed-property-spacing": "error",
|
|
46
|
+
"@stylistic/eol-last": "error",
|
|
47
|
+
"@stylistic/function-call-spacing": "error",
|
|
48
|
+
"@stylistic/generator-star-spacing": "error",
|
|
49
|
+
"@stylistic/indent": ["error", indent.js, { SwitchCase: 1, MemberExpression: "off", flatTernaryExpressions: true }],
|
|
50
|
+
"@stylistic/indent-binary-ops": ["error", indent.js],
|
|
51
|
+
"@stylistic/jsx-child-element-spacing": "error",
|
|
52
|
+
"@stylistic/jsx-curly-brace-presence": "error",
|
|
53
|
+
"@stylistic/jsx-curly-spacing": "error",
|
|
54
|
+
"@stylistic/jsx-equals-spacing": "error",
|
|
55
|
+
"@stylistic/jsx-function-call-newline": "error",
|
|
56
|
+
"@stylistic/jsx-indent": ["error", indent.js, { checkAttributes: true, indentLogicalExpressions: true }],
|
|
57
|
+
"@stylistic/jsx-indent-props": ["error", indent.js],
|
|
58
|
+
"@stylistic/jsx-one-expression-per-line": "off",
|
|
59
|
+
"@stylistic/jsx-pascal-case": "error",
|
|
60
|
+
"@stylistic/jsx-quotes": "error",
|
|
61
|
+
"@stylistic/jsx-self-closing-comp": "error",
|
|
62
|
+
"@stylistic/jsx-wrap-multilines": "error",
|
|
63
|
+
"@stylistic/key-spacing": ["error", { mode: "minimum" }],
|
|
64
|
+
"@stylistic/keyword-spacing": "error",
|
|
65
|
+
"@stylistic/linebreak-style": "error",
|
|
66
|
+
"@stylistic/member-delimiter-style": "error",
|
|
67
|
+
"@stylistic/new-parens": "error",
|
|
68
|
+
"@stylistic/no-extra-semi": "error",
|
|
69
|
+
"@stylistic/no-floating-decimal": "error",
|
|
70
|
+
"@stylistic/no-mixed-operators": ["error", {
|
|
71
|
+
groups: [
|
|
72
|
+
// allow to mix arithmetic operators
|
|
73
|
+
// ["+", "-", "*", "/", "%", "**"],
|
|
74
|
+
["&", "|", "^", "~", "<<", ">>", ">>>"],
|
|
75
|
+
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
76
|
+
["&&", "||"],
|
|
77
|
+
["in", "instanceof"],
|
|
78
|
+
],
|
|
79
|
+
allowSamePrecedence: true,
|
|
80
|
+
}],
|
|
81
|
+
"@stylistic/no-multiple-empty-lines": ["error", { max: 2 }],
|
|
82
|
+
"@stylistic/no-tabs": "error",
|
|
83
|
+
"@stylistic/no-trailing-spaces": "error",
|
|
84
|
+
"@stylistic/no-whitespace-before-property": "error",
|
|
85
|
+
"@stylistic/object-curly-spacing": ["error", "always"],
|
|
86
|
+
"@stylistic/quote-props": ["error", "as-needed"],
|
|
87
|
+
"@stylistic/quotes": (quotes === "off") ? "off" : ["error", quotes, { avoidEscape: true }],
|
|
88
|
+
"@stylistic/rest-spread-spacing": "error",
|
|
89
|
+
"@stylistic/semi": (semi === "off") ? "off" : ["error", semi],
|
|
90
|
+
"@stylistic/semi-spacing": "error",
|
|
91
|
+
"@stylistic/semi-style": "error",
|
|
92
|
+
"@stylistic/space-before-blocks": "error",
|
|
93
|
+
"@stylistic/space-before-function-paren": ["error", { anonymous: "always", named: "never", asyncArrow: "always" }],
|
|
94
|
+
"@stylistic/space-in-parens": "error",
|
|
95
|
+
"@stylistic/space-infix-ops": "error",
|
|
96
|
+
"@stylistic/space-unary-ops": "error",
|
|
97
|
+
"@stylistic/switch-colon-spacing": "error",
|
|
98
|
+
"@stylistic/template-curly-spacing": "error",
|
|
99
|
+
"@stylistic/template-tag-spacing": "error",
|
|
100
|
+
"@stylistic/type-annotation-spacing": "error",
|
|
101
|
+
"@stylistic/type-generic-spacing": "error",
|
|
102
|
+
"@stylistic/type-named-tuple-spacing": "error",
|
|
103
|
+
"@stylistic/wrap-iife": "error",
|
|
104
|
+
"@stylistic/yield-star-spacing": "error",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
// "@stylistic/migrate" plugin
|
|
108
|
+
{
|
|
109
|
+
name: "stylistic:migrate",
|
|
110
|
+
// register rule implementations of the plugins
|
|
111
|
+
plugins: {
|
|
112
|
+
"@stylistic/migrate": migratePlugin,
|
|
113
|
+
},
|
|
114
|
+
// configure plugin rules
|
|
115
|
+
rules: {
|
|
116
|
+
"@stylistic/migrate/migrate-js": "error",
|
|
117
|
+
"@stylistic/migrate/migrate-ts": "error",
|
|
118
|
+
"@stylistic/migrate/migrate-jsx": "error",
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|