@open-xchange/linter-presets 0.9.0 → 0.10.1
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/dist/eslint/config/base.d.ts +3 -3
- package/dist/eslint/config/base.js +6 -6
- package/dist/eslint/config/imports.d.ts +3 -3
- package/dist/eslint/config/imports.js +3 -3
- package/dist/eslint/config/json.d.ts +3 -3
- package/dist/eslint/config/json.js +7 -8
- package/dist/eslint/config/stylistic.d.ts +3 -3
- package/dist/eslint/config/stylistic.js +13 -6
- package/dist/eslint/config/vue.d.ts +15 -0
- package/dist/eslint/config/vue.js +42 -0
- package/dist/eslint/config/yaml.d.ts +3 -3
- package/dist/eslint/config/yaml.js +7 -8
- package/dist/eslint/env/vitest.js +1 -0
- package/dist/eslint/index.js +18 -9
- package/dist/eslint/shared/env-utils.d.ts +43 -5
- package/dist/eslint/shared/env-utils.js +15 -0
- package/doc/eslint/README.md +11 -6
- package/package.json +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## `0.10.1` – 2024-Nov-15
|
|
4
|
+
|
|
5
|
+
- chore: bump dependencies
|
|
6
|
+
|
|
7
|
+
## `0.10.0` – 2024-Nov-14
|
|
8
|
+
|
|
9
|
+
- add: (ESLint) support for Vue.js files (`eslint-plugin-vue`)
|
|
10
|
+
- change: (ESlint) default value of `ecmaVersion` set to `latest`
|
|
11
|
+
- change: (ESlint) custom indentation per file type (default `2` for YAML and Vue)
|
|
12
|
+
|
|
3
13
|
## `0.9.0` – 2024-Nov-08
|
|
4
14
|
|
|
5
15
|
- change: (ESLint) allow static class initialization blocks
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import { type
|
|
2
|
+
import { type LanguageConfig } from "../shared/env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Defines standard module settings and additional rules targeting JavaScript
|
|
5
5
|
* _and_ TypeScript source files.
|
|
@@ -7,10 +7,10 @@ import { type LanguageOptions } from "../shared/env-utils.js";
|
|
|
7
7
|
* Wraps the following packages:
|
|
8
8
|
* - `@eslint/js`
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
10
|
+
* @param languageConfig
|
|
11
11
|
* Resolved configuration options.
|
|
12
12
|
*
|
|
13
13
|
* @returns
|
|
14
14
|
* An array of configuration objects to be added to the flat configuration.
|
|
15
15
|
*/
|
|
16
|
-
export default function base(
|
|
16
|
+
export default function base(languageConfig: LanguageConfig): Linter.Config[];
|
|
@@ -10,16 +10,16 @@ import { builtinRestrictedRules } from "../shared/restricted.js";
|
|
|
10
10
|
* Wraps the following packages:
|
|
11
11
|
* - `@eslint/js`
|
|
12
12
|
*
|
|
13
|
-
* @param
|
|
13
|
+
* @param languageConfig
|
|
14
14
|
* Resolved configuration options.
|
|
15
15
|
*
|
|
16
16
|
* @returns
|
|
17
17
|
* An array of configuration objects to be added to the flat configuration.
|
|
18
18
|
*/
|
|
19
|
-
export default function base(
|
|
19
|
+
export default function base(languageConfig) {
|
|
20
20
|
// returns language options for specific file extensions
|
|
21
21
|
const languageOptions = (sourceType, ...extensions) => {
|
|
22
|
-
const { ecmaVersion } =
|
|
22
|
+
const { ecmaVersion } = languageConfig;
|
|
23
23
|
return {
|
|
24
24
|
files: extGlob(extensions),
|
|
25
25
|
languageOptions: { ecmaVersion, sourceType },
|
|
@@ -38,9 +38,9 @@ export default function base(options) {
|
|
|
38
38
|
// ECMA version and module type for CommonJS modules
|
|
39
39
|
languageOptions("commonjs", "cjs", "cts"),
|
|
40
40
|
// ECMA version and module type for *.js and *.ts files
|
|
41
|
-
languageOptions(
|
|
41
|
+
languageOptions(languageConfig.sourceType, "js", "jsx", "ts", "tsx"),
|
|
42
42
|
// ECMA decorators via Babel plugin
|
|
43
|
-
...(
|
|
43
|
+
...(languageConfig.nativeDecorators ? [{
|
|
44
44
|
files: JS_GLOB,
|
|
45
45
|
languageOptions: {
|
|
46
46
|
parser: babelParser,
|
|
@@ -129,7 +129,7 @@ export default function base(options) {
|
|
|
129
129
|
radix: "error",
|
|
130
130
|
"symbol-description": "error",
|
|
131
131
|
// built-in restricted items
|
|
132
|
-
...builtinRestrictedRules(
|
|
132
|
+
...builtinRestrictedRules(languageConfig),
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LanguageConfig } from "../shared/env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Adds linter rules for `import` and `export` statements.
|
|
5
5
|
*
|
|
6
6
|
* Wraps the following packages:
|
|
7
7
|
* - `eslint-plugin-import`
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param languageConfig
|
|
10
10
|
* Resolved configuration options.
|
|
11
11
|
*
|
|
12
12
|
* @returns
|
|
13
13
|
* An array of configuration objects to be added to the flat configuration.
|
|
14
14
|
*/
|
|
15
|
-
export default function importConfig(
|
|
15
|
+
export default function importConfig(languageConfig: LanguageConfig): Linter.Config[];
|
|
@@ -7,15 +7,15 @@ import { fixupPluginRules } from "@eslint/compat";
|
|
|
7
7
|
* Wraps the following packages:
|
|
8
8
|
* - `eslint-plugin-import`
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
10
|
+
* @param languageConfig
|
|
11
11
|
* Resolved configuration options.
|
|
12
12
|
*
|
|
13
13
|
* @returns
|
|
14
14
|
* An array of configuration objects to be added to the flat configuration.
|
|
15
15
|
*/
|
|
16
|
-
export default function importConfig(
|
|
16
|
+
export default function importConfig(languageConfig) {
|
|
17
17
|
// configuration properties
|
|
18
|
-
const { ecmaVersion, sourceType } =
|
|
18
|
+
const { ecmaVersion, sourceType } = languageConfig;
|
|
19
19
|
// extensions of ES module files
|
|
20
20
|
const jsExtensions = (sourceType === "module") ? [".js", ".mjs"] : [".mjs"];
|
|
21
21
|
const tsExtensions = (sourceType === "module") ? [".ts", ".mts"] : [".mts"];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import type
|
|
2
|
+
import { type StylisticConfig } from "../shared/env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Defines standard linting rules for JSON files.
|
|
5
5
|
*
|
|
6
6
|
* Wraps the following packages:
|
|
7
7
|
* - `eslint-plugin-jsonc`
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param stylisticConfig
|
|
10
10
|
* Resolved configuration options.
|
|
11
11
|
*
|
|
12
12
|
* @returns
|
|
13
13
|
* An array of configuration objects to be added to the flat configuration.
|
|
14
14
|
*/
|
|
15
|
-
export default function json(
|
|
15
|
+
export default function json(stylisticConfig: StylisticConfig): Linter.Config[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import jsonPlugin from "eslint-plugin-jsonc";
|
|
2
|
+
import { fixMissingFilesOption } from "../shared/env-utils.js";
|
|
2
3
|
// functions ==================================================================
|
|
3
4
|
/**
|
|
4
5
|
* Defines standard linting rules for JSON files.
|
|
@@ -6,14 +7,15 @@ import jsonPlugin from "eslint-plugin-jsonc";
|
|
|
6
7
|
* Wraps the following packages:
|
|
7
8
|
* - `eslint-plugin-jsonc`
|
|
8
9
|
*
|
|
9
|
-
* @param
|
|
10
|
+
* @param stylisticConfig
|
|
10
11
|
* Resolved configuration options.
|
|
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 json(
|
|
16
|
-
|
|
16
|
+
export default function json(stylisticConfig) {
|
|
17
|
+
// add missing "files" property in configurations with rules (otherwise, plugin conflicts with "@eslint/markdown")
|
|
18
|
+
return fixMissingFilesOption([
|
|
17
19
|
// register rule implementations and recommended rules
|
|
18
20
|
...jsonPlugin.configs["flat/recommended-with-json"],
|
|
19
21
|
// reconfigure plugin rules
|
|
@@ -21,7 +23,7 @@ export default function json(options) {
|
|
|
21
23
|
rules: {
|
|
22
24
|
"jsonc/array-bracket-spacing": "error",
|
|
23
25
|
"jsonc/comma-style": "error",
|
|
24
|
-
"jsonc/indent": ["error",
|
|
26
|
+
"jsonc/indent": ["error", stylisticConfig.indent.json],
|
|
25
27
|
"jsonc/key-spacing": ["error", { mode: "minimum" }],
|
|
26
28
|
"jsonc/no-irregular-whitespace": "error",
|
|
27
29
|
"jsonc/no-octal-escape": "error",
|
|
@@ -33,8 +35,5 @@ export default function json(options) {
|
|
|
33
35
|
"jsonc/no-comments": "off",
|
|
34
36
|
},
|
|
35
37
|
},
|
|
36
|
-
];
|
|
37
|
-
// add missing "files" property in configurations with rules (otherwise, plugin conflicts with "@eslint/markdown")
|
|
38
|
-
const files = configs.find(config => config.files)?.files;
|
|
39
|
-
return configs.map(config => (!config.files && config.rules) ? { ...config, files } : config);
|
|
38
|
+
]);
|
|
40
39
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import type {
|
|
2
|
+
import type { StylisticConfig } from "../shared/env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Defines standard (opinionated) linter rules for source code style.
|
|
5
5
|
*
|
|
@@ -7,10 +7,10 @@ import type { StylisticOptions } from "../shared/env-utils.js";
|
|
|
7
7
|
* - `@stylistic/eslint-plugin`
|
|
8
8
|
* - `@stylistic/eslint-plugin-migrate`
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
10
|
+
* @param stylisticConfig
|
|
11
11
|
* Resolved configuration options.
|
|
12
12
|
*
|
|
13
13
|
* @returns
|
|
14
14
|
* An array of configuration objects to be added to the flat configuration.
|
|
15
15
|
*/
|
|
16
|
-
export default function stylistic(
|
|
16
|
+
export default function stylistic(stylisticConfig: StylisticConfig): Linter.Config[];
|
|
@@ -8,15 +8,15 @@ import migratePlugin from "@stylistic/eslint-plugin-migrate";
|
|
|
8
8
|
* - `@stylistic/eslint-plugin`
|
|
9
9
|
* - `@stylistic/eslint-plugin-migrate`
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param stylisticConfig
|
|
12
12
|
* Resolved configuration options.
|
|
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 stylistic(
|
|
17
|
+
export default function stylistic(stylisticConfig) {
|
|
18
18
|
// configuration properties
|
|
19
|
-
const { indent, semi, quotes, dangle } =
|
|
19
|
+
const { indent, semi, quotes, dangle } = stylisticConfig;
|
|
20
20
|
return [
|
|
21
21
|
// globally disable all deprecated stylistic core rules
|
|
22
22
|
stylisticPlugin.configs["disable-legacy"],
|
|
@@ -41,14 +41,14 @@ export default function stylistic(options) {
|
|
|
41
41
|
"@stylistic/eol-last": "error",
|
|
42
42
|
"@stylistic/function-call-spacing": "error",
|
|
43
43
|
"@stylistic/generator-star-spacing": "error",
|
|
44
|
-
"@stylistic/indent": ["error", indent, { SwitchCase: 1, MemberExpression: "off", flatTernaryExpressions: true }],
|
|
45
|
-
"@stylistic/indent-binary-ops": ["error", indent],
|
|
44
|
+
"@stylistic/indent": ["error", indent.js, { SwitchCase: 1, MemberExpression: "off", flatTernaryExpressions: true }],
|
|
45
|
+
"@stylistic/indent-binary-ops": ["error", indent.js],
|
|
46
46
|
"@stylistic/jsx-child-element-spacing": "error",
|
|
47
47
|
"@stylistic/jsx-curly-brace-presence": "error",
|
|
48
48
|
"@stylistic/jsx-curly-spacing": "error",
|
|
49
49
|
"@stylistic/jsx-equals-spacing": "error",
|
|
50
50
|
"@stylistic/jsx-function-call-newline": "error",
|
|
51
|
-
"@stylistic/jsx-indent-props": ["error", indent],
|
|
51
|
+
"@stylistic/jsx-indent-props": ["error", indent.js],
|
|
52
52
|
"@stylistic/jsx-one-expression-per-line": "off",
|
|
53
53
|
"@stylistic/jsx-pascal-case": "error",
|
|
54
54
|
"@stylistic/jsx-quotes": "error",
|
|
@@ -98,6 +98,13 @@ export default function stylistic(options) {
|
|
|
98
98
|
"@stylistic/yield-star-spacing": "error",
|
|
99
99
|
},
|
|
100
100
|
},
|
|
101
|
+
// special settings for Vue files
|
|
102
|
+
{
|
|
103
|
+
files: ["**/*.vue"],
|
|
104
|
+
rules: {
|
|
105
|
+
"@stylistic/indent": ["error", stylisticConfig.indent.vue],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
101
108
|
// "@stylistic/migrate" plugin
|
|
102
109
|
{
|
|
103
110
|
// register rule implementations of the plugins
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
import { type LanguageConfig } from "../shared/env-utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates configuration objects with linter rules for Vue.js.
|
|
5
|
+
*
|
|
6
|
+
* Wraps the following packages:
|
|
7
|
+
* - `eslint-plugin-vue`
|
|
8
|
+
*
|
|
9
|
+
* @param languageConfig
|
|
10
|
+
* Resolved language configuration options.
|
|
11
|
+
*
|
|
12
|
+
* @returns
|
|
13
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
14
|
+
*/
|
|
15
|
+
export default function vue(languageConfig: LanguageConfig): Linter.Config[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import vuePlugin from "eslint-plugin-vue";
|
|
2
|
+
import vueParser from "vue-eslint-parser";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import { fixMissingFilesOption } from "../shared/env-utils.js";
|
|
5
|
+
// functions ==================================================================
|
|
6
|
+
/**
|
|
7
|
+
* Creates configuration objects with linter rules for Vue.js.
|
|
8
|
+
*
|
|
9
|
+
* Wraps the following packages:
|
|
10
|
+
* - `eslint-plugin-vue`
|
|
11
|
+
*
|
|
12
|
+
* @param languageConfig
|
|
13
|
+
* Resolved language configuration options.
|
|
14
|
+
*
|
|
15
|
+
* @returns
|
|
16
|
+
* An array of configuration objects to be added to the flat configuration.
|
|
17
|
+
*/
|
|
18
|
+
export default function vue(languageConfig) {
|
|
19
|
+
// add missing "files" property in configurations with rules (otherwise, plugin conflicts with "@eslint/markdown")
|
|
20
|
+
return fixMissingFilesOption([
|
|
21
|
+
// use TypeScript parser for Vue files
|
|
22
|
+
{
|
|
23
|
+
languageOptions: {
|
|
24
|
+
parser: vueParser,
|
|
25
|
+
parserOptions: {
|
|
26
|
+
parser: tseslint.parser,
|
|
27
|
+
sourceType: "module",
|
|
28
|
+
ecmaVersion: languageConfig.ecmaVersion,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
// register rule implementations and recommended rules
|
|
33
|
+
...vuePlugin.configs["flat/recommended"],
|
|
34
|
+
// reconfigure plugin rules
|
|
35
|
+
{
|
|
36
|
+
rules: {
|
|
37
|
+
"vue/singleline-html-element-content-newline": "off",
|
|
38
|
+
"vue/max-attributes-per-line": "off",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
-
import type
|
|
2
|
+
import { type StylisticConfig } from "../shared/env-utils.js";
|
|
3
3
|
/**
|
|
4
4
|
* Defines standard linting rules for YAML files.
|
|
5
5
|
*
|
|
6
6
|
* Wraps the following packages:
|
|
7
7
|
* - `eslint-plugin-yml`
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param stylisticConfig
|
|
10
10
|
* Resolved configuration options.
|
|
11
11
|
*
|
|
12
12
|
* @returns
|
|
13
13
|
* An array of configuration objects to be added to the flat configuration.
|
|
14
14
|
*/
|
|
15
|
-
export default function yaml(
|
|
15
|
+
export default function yaml(stylisticConfig: StylisticConfig): Linter.Config[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import yamlPlugin from "eslint-plugin-yml";
|
|
2
|
+
import { fixMissingFilesOption } from "../shared/env-utils.js";
|
|
2
3
|
// functions ==================================================================
|
|
3
4
|
/**
|
|
4
5
|
* Defines standard linting rules for YAML files.
|
|
@@ -6,26 +7,24 @@ import yamlPlugin from "eslint-plugin-yml";
|
|
|
6
7
|
* Wraps the following packages:
|
|
7
8
|
* - `eslint-plugin-yml`
|
|
8
9
|
*
|
|
9
|
-
* @param
|
|
10
|
+
* @param stylisticConfig
|
|
10
11
|
* Resolved configuration options.
|
|
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 yaml(
|
|
16
|
-
|
|
16
|
+
export default function yaml(stylisticConfig) {
|
|
17
|
+
// add missing "files" property in configurations with rules (otherwise, plugin conflicts with "@eslint/markdown")
|
|
18
|
+
return fixMissingFilesOption([
|
|
17
19
|
// register rule implementations and recommended rules
|
|
18
20
|
...yamlPlugin.configs["flat/recommended"],
|
|
19
21
|
// reconfigure plugin rules
|
|
20
22
|
{
|
|
21
23
|
rules: {
|
|
22
|
-
"yml/indent": ["error",
|
|
24
|
+
"yml/indent": ["error", stylisticConfig.indent.yaml],
|
|
23
25
|
"yml/key-spacing": ["error", { mode: "minimum" }],
|
|
24
26
|
"yml/require-string-key": "error",
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
|
-
];
|
|
28
|
-
// add missing "files" property in configurations with rules (otherwise, plugin conflicts with "@eslint/markdown")
|
|
29
|
-
const files = configs.find(config => config.files)?.files;
|
|
30
|
-
return configs.map(config => (!config.files && config.rules) ? { ...config, files } : config);
|
|
29
|
+
]);
|
|
31
30
|
}
|
package/dist/eslint/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import base from "./config/base.js";
|
|
2
2
|
import js from "./config/js.js";
|
|
3
3
|
import ts from "./config/ts.js";
|
|
4
|
+
import vue from "./config/vue.js";
|
|
4
5
|
import json from "./config/json.js";
|
|
5
6
|
import yaml from "./config/yaml.js";
|
|
6
7
|
import markdown from "./config/markdown.js";
|
|
@@ -55,33 +56,41 @@ export function configure(options) {
|
|
|
55
56
|
...(options?.ignores ?? []),
|
|
56
57
|
];
|
|
57
58
|
// resolve language configuration options
|
|
58
|
-
const
|
|
59
|
-
ecmaVersion:
|
|
59
|
+
const languageConfig = {
|
|
60
|
+
ecmaVersion: "latest",
|
|
60
61
|
sourceType: "module",
|
|
61
62
|
nativeDecorators: false,
|
|
62
63
|
...options?.language,
|
|
63
64
|
};
|
|
64
65
|
// resolve stylistic configuration options
|
|
65
|
-
const
|
|
66
|
-
indent: 4,
|
|
66
|
+
const stylisticConfig = {
|
|
67
67
|
semi: "always",
|
|
68
68
|
quotes: "double",
|
|
69
69
|
dangle: "always",
|
|
70
70
|
...options?.stylistic,
|
|
71
|
+
indent: {
|
|
72
|
+
js: 4,
|
|
73
|
+
json: 4,
|
|
74
|
+
yaml: 2,
|
|
75
|
+
vue: 2,
|
|
76
|
+
...options?.stylistic?.indent,
|
|
77
|
+
},
|
|
71
78
|
};
|
|
72
79
|
return [
|
|
73
80
|
// ignore certain files and folders
|
|
74
81
|
{ ignores },
|
|
75
82
|
// module types and standard rules for all JS/TS source files
|
|
76
|
-
...base(
|
|
83
|
+
...base(languageConfig),
|
|
77
84
|
// default configuration for JavaScript files
|
|
78
85
|
...js(),
|
|
79
86
|
// default configuration for TypeScript files
|
|
80
87
|
...ts(),
|
|
88
|
+
// default configuration for Vue.js files
|
|
89
|
+
...vue(languageConfig),
|
|
81
90
|
// default configuration for JSON files
|
|
82
|
-
...json(
|
|
91
|
+
...json(stylisticConfig),
|
|
83
92
|
// default configuration for YAML files
|
|
84
|
-
...yaml(
|
|
93
|
+
...yaml(stylisticConfig),
|
|
85
94
|
// default configuration for Markdown files
|
|
86
95
|
...markdown(),
|
|
87
96
|
// check for correct license headers
|
|
@@ -89,13 +98,13 @@ export function configure(options) {
|
|
|
89
98
|
// default configuration for ESLint inline directives
|
|
90
99
|
...directives(),
|
|
91
100
|
// default configuration for imports/exports
|
|
92
|
-
...imports(
|
|
101
|
+
...imports(languageConfig),
|
|
93
102
|
// default configuration for native promises
|
|
94
103
|
...promises(),
|
|
95
104
|
// default configuration for JSDoc
|
|
96
105
|
...jsdoc(),
|
|
97
106
|
// default configuration for code style checks
|
|
98
|
-
...stylistic(
|
|
107
|
+
...stylistic(stylisticConfig),
|
|
99
108
|
// custom rules
|
|
100
109
|
...(options?.rules ? [{ rules: options.rules }] : []),
|
|
101
110
|
];
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Linter } from "eslint";
|
|
2
|
+
export type DeepRequired<T> = {
|
|
3
|
+
[key in keyof T]-?: DeepRequired<T[key]>;
|
|
4
|
+
};
|
|
2
5
|
/**
|
|
3
6
|
* Configuration options for language and project setup.
|
|
4
7
|
*/
|
|
5
8
|
export interface LanguageOptions {
|
|
6
9
|
/**
|
|
7
10
|
* The ECMAScript version to be used in the project (version or year).
|
|
8
|
-
* Default value is `
|
|
11
|
+
* Default value is `latest`.
|
|
9
12
|
*/
|
|
10
13
|
ecmaVersion?: Linter.EcmaVersion;
|
|
11
14
|
/**
|
|
@@ -24,16 +27,38 @@ export interface LanguageOptions {
|
|
|
24
27
|
*/
|
|
25
28
|
nativeDecorators?: boolean;
|
|
26
29
|
}
|
|
30
|
+
export type LanguageConfig = DeepRequired<LanguageOptions>;
|
|
31
|
+
/**
|
|
32
|
+
* Configuration options for code indentation.
|
|
33
|
+
*/
|
|
34
|
+
export interface IndentOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Indentation size for JavaScript and TypeScript files, including JSX.
|
|
37
|
+
* Default value is `4`.
|
|
38
|
+
*/
|
|
39
|
+
js?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Indentation size for JSON files. Default value is `4`.
|
|
42
|
+
*/
|
|
43
|
+
json?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Indentation size for YAML files. Default value is `2`.
|
|
46
|
+
*/
|
|
47
|
+
yaml?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Indentation size for Vue.js files. Default value is `2`.
|
|
50
|
+
*/
|
|
51
|
+
vue?: number;
|
|
52
|
+
}
|
|
27
53
|
/**
|
|
28
54
|
* Configuration options for code style.
|
|
29
55
|
*/
|
|
30
56
|
export interface StylisticOptions {
|
|
31
57
|
/**
|
|
32
|
-
* Default indentation
|
|
33
|
-
*
|
|
34
|
-
* Default value is `4`.
|
|
58
|
+
* Default indentation sizes (number of space characters) for various file
|
|
59
|
+
* types. See `IndentOptions` for default values.
|
|
35
60
|
*/
|
|
36
|
-
indent?:
|
|
61
|
+
indent?: IndentOptions;
|
|
37
62
|
/**
|
|
38
63
|
* Specifies how to treat semicolons.
|
|
39
64
|
*
|
|
@@ -61,6 +86,7 @@ export interface StylisticOptions {
|
|
|
61
86
|
*/
|
|
62
87
|
dangle?: "always" | "never" | "off";
|
|
63
88
|
}
|
|
89
|
+
export type StylisticConfig = DeepRequired<StylisticOptions>;
|
|
64
90
|
/**
|
|
65
91
|
* Shared options for an environment preset with included and excluded files.
|
|
66
92
|
*/
|
|
@@ -195,3 +221,15 @@ export declare function createConfig(envOptions: EnvFilesOptions, flatConfig: Li
|
|
|
195
221
|
* custom rule settings, otherwise `undefined`.
|
|
196
222
|
*/
|
|
197
223
|
export declare function customRules(envOptions: EnvBaseOptions, rules?: Linter.RulesRecord): Linter.Config | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Finds the first configuration object with a "files" property, and copies
|
|
226
|
+
* this property into all other configurations objects with language options or
|
|
227
|
+
* rules but lacking the "files" property.
|
|
228
|
+
*
|
|
229
|
+
* @param configs
|
|
230
|
+
* The configuration objects to be fixed.
|
|
231
|
+
*
|
|
232
|
+
* @returns
|
|
233
|
+
* The fixed configuration options.
|
|
234
|
+
*/
|
|
235
|
+
export declare function fixMissingFilesOption(configs: Linter.Config[]): Linter.Config[];
|
|
@@ -126,3 +126,18 @@ export function customRules(envOptions, rules) {
|
|
|
126
126
|
rules: { ...rules, ...envOptions.rules },
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Finds the first configuration object with a "files" property, and copies
|
|
131
|
+
* this property into all other configurations objects with language options or
|
|
132
|
+
* rules but lacking the "files" property.
|
|
133
|
+
*
|
|
134
|
+
* @param configs
|
|
135
|
+
* The configuration objects to be fixed.
|
|
136
|
+
*
|
|
137
|
+
* @returns
|
|
138
|
+
* The fixed configuration options.
|
|
139
|
+
*/
|
|
140
|
+
export function fixMissingFilesOption(configs) {
|
|
141
|
+
const files = configs.find(config => config.files)?.files;
|
|
142
|
+
return files ? configs.map(config => (!config.files && (config.languageOptions || config.rules)) ? { ...config, files } : config) : configs;
|
|
143
|
+
}
|
package/doc/eslint/README.md
CHANGED
|
@@ -13,9 +13,10 @@ Generates standard configuration targeting the source files in the entire projec
|
|
|
13
13
|
| JavaScript and TypeScript files (including `.jsx` and `.tsx`) | ESLint core rules |
|
|
14
14
|
| JavaScript files only (including `.jsx`) | ESLint core rules |
|
|
15
15
|
| TypeScript files with type-aware rules (including `.tsx`) | [typescript-eslint](https://typescript-eslint.io/) |
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
16
|
+
| [Vue.js](https://vuejs.org) files (`.vue`) | [eslint-plugin-vue](https://eslint.vuejs.org) |
|
|
17
|
+
| JSON files (`.json`) | [eslint-plugin-jsonc](https://ota-meshi.github.io/eslint-plugin-jsonc/) |
|
|
18
|
+
| YAML files (`.yaml`, `.yml`) | [eslint-plugin-yml](https://ota-meshi.github.io/eslint-plugin-yml/) |
|
|
19
|
+
| Markdown files (`.md`) | [@eslint/markdown](https://github.com/eslint/markdown) |
|
|
19
20
|
| License headers | [eslint-plugin-license-header](https://github.com/nikku/eslint-plugin-license-header) |
|
|
20
21
|
| ESLint inline directives | [@eslint-community/eslint-plugin-eslint-comments](https://github.com/eslint-community/eslint-plugin-eslint-comments) |
|
|
21
22
|
| Module imports | [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) |
|
|
@@ -36,11 +37,15 @@ function configure(options?: ConfigureOptions): Linter.Config[]
|
|
|
36
37
|
| `ignores` | `string[]` | `[]` | Glob patterns with all files and folders to be ignored by ESLint. This package already defines a few standard ignore globs (see below). |
|
|
37
38
|
| `license` | `string` | `""` | Full path to the template file containing the license header to be used in all source files. |
|
|
38
39
|
| `language` | `LanguageOptions` | | Configuration options for language and project setup. |
|
|
39
|
-
| `language.ecmaVersion` | `number` | `
|
|
40
|
+
| `language.ecmaVersion` | `number\|"latest"` | `latest` | The ECMAScript version to be used in the project (version or year). |
|
|
40
41
|
| `language.sourceType` | `"module"\|"commonjs"` | `"module"` | Specifies how to treat `.js`, `.jsx`, `.ts`, and `.tsx` files. |
|
|
41
42
|
| `language.nativeDecorators` | `boolean` | `false` | Whether to support native ES decorators in JavaScript code (via Babel plugin). Does not affect TypeScript code which uses an own parser aware of the decorator syntax. |
|
|
42
43
|
| `stylistic` | `StylisticOptions` | | Configuration options for code style. |
|
|
43
|
-
| `stylistic.indent` | `
|
|
44
|
+
| `stylistic.indent` | `IndentOptions` | `{}` | Indentation size (number of space characters) per file type. |
|
|
45
|
+
| `stylistic.indent.js` | `number` | `4` | JavaScript and TypeScript files (including `.jsx`, `.tsx`). |
|
|
46
|
+
| `stylistic.indent.json` | `number` | `4` | JSON files (`.json`). |
|
|
47
|
+
| `stylistic.indent.yaml` | `number` | `2` | YAML files (`.yaml`, `.yml`). |
|
|
48
|
+
| `stylistic.indent.vue` | `number` | `2` | Vue.js files (`.vue`). |
|
|
44
49
|
| `stylistic.semi` | `"always"\|"never"\|"off"` | `"always"` | Specifies whether to require semicolons following all statements (`"always"`), or to force to omit semicolons if possible according to ASI rules (`"never"`). |
|
|
45
50
|
| `stylistic.quotes` | `"single"\|"double"\|"off"` | `"double"` | The type of the string delimiter character. |
|
|
46
51
|
| `stylistic.dangle` | `"always"\|"never"\|"off"` | `"always"` | Specifies how to treat dangling commas in multiline lists. |
|
|
@@ -86,7 +91,7 @@ The names of the environment presets are linked to detailed descriptions.
|
|
|
86
91
|
| - | - |
|
|
87
92
|
| [`env.node`](./env/node.md) | Modules running in NodeJS. |
|
|
88
93
|
| [`env.browser`](./env/browser.md) | Modules running in browsers. |
|
|
89
|
-
| [`env.react`](./env/react.md) | Modules using [React](https://react.dev/)
|
|
94
|
+
| [`env.react`](./env/react.md) | Modules using [React](https://react.dev/). |
|
|
90
95
|
| [`env.jest`](./env/jest.md) | Unit tests with [Jest](https://jestjs.io/). |
|
|
91
96
|
| [`env.vitest`](./env/vitest.md) | Unit tests with [Vitest](https://vitest.dev/). |
|
|
92
97
|
| [`env.codecept`](./env/codecept.md) | E2E tests with [CodeceptJS](https://codecept.io/). |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/linter-presets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Configuration presets for ESLint and StyleLint",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": "
|
|
11
|
+
"node": ">=20.18"
|
|
12
12
|
},
|
|
13
13
|
"packageManager": "yarn@4.5.1",
|
|
14
14
|
"type": "module",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"@babel/eslint-parser": "^7.25.9",
|
|
26
26
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
27
27
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
28
|
-
"@eslint/compat": "^1.2.
|
|
28
|
+
"@eslint/compat": "^1.2.3",
|
|
29
29
|
"@eslint/js": "^9.14.0",
|
|
30
30
|
"@eslint/markdown": "^6.2.1",
|
|
31
31
|
"@stylistic/eslint-plugin": "^2.10.1",
|
|
32
32
|
"@stylistic/eslint-plugin-migrate": "^2.10.1",
|
|
33
33
|
"@stylistic/stylelint-config": "^2.0.0",
|
|
34
34
|
"@stylistic/stylelint-plugin": "^3.1.1",
|
|
35
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
35
|
+
"@vitest/eslint-plugin": "^1.1.10",
|
|
36
36
|
"confusing-browser-globals": "^1.0.11",
|
|
37
37
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
38
38
|
"eslint-plugin-chai-expect": "^3.1.0",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"eslint-plugin-import": "^2.31.0",
|
|
42
42
|
"eslint-plugin-jest": "^28.9.0",
|
|
43
43
|
"eslint-plugin-jest-dom": "^5.4.0",
|
|
44
|
-
"eslint-plugin-jsdoc": "^50.
|
|
45
|
-
"eslint-plugin-jsonc": "^2.
|
|
44
|
+
"eslint-plugin-jsdoc": "^50.5.0",
|
|
45
|
+
"eslint-plugin-jsonc": "^2.18.1",
|
|
46
46
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
47
47
|
"eslint-plugin-jsx-expressions": "^1.3.2",
|
|
48
48
|
"eslint-plugin-license-header": "^0.6.1",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"eslint-plugin-react-hooks-static-deps": "^1.0.7",
|
|
54
54
|
"eslint-plugin-react-refresh": "^0.4.14",
|
|
55
55
|
"eslint-plugin-testing-library": "^6.4.0",
|
|
56
|
+
"eslint-plugin-vue": "^9.31.0",
|
|
56
57
|
"eslint-plugin-yml": "^1.15.0",
|
|
57
58
|
"find-up": "^7.0.0",
|
|
58
59
|
"globals": "^15.12.0",
|
|
@@ -61,12 +62,13 @@
|
|
|
61
62
|
"stylelint-config-standard-less": "^3.0.1",
|
|
62
63
|
"stylelint-config-standard-scss": "^13.1.0",
|
|
63
64
|
"stylelint-plugin-license-header": "^1.0.3",
|
|
64
|
-
"typescript-eslint": "^8.
|
|
65
|
+
"typescript-eslint": "^8.14.0",
|
|
66
|
+
"vue-eslint-parser": "^9.4.3"
|
|
65
67
|
},
|
|
66
68
|
"devDependencies": {
|
|
67
69
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
68
70
|
"@types/picomatch": "^3.0.1",
|
|
69
|
-
"@typescript-eslint/utils": "^8.
|
|
71
|
+
"@typescript-eslint/utils": "^8.14.0",
|
|
70
72
|
"eslint": "^9.14.0",
|
|
71
73
|
"jest": "^29.7.0",
|
|
72
74
|
"rimraf": "^6.0.1",
|