@open-xchange/linter-presets 1.5.1 → 1.6.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +17 -23
  3. package/dist/eslint/core/base.js +122 -0
  4. package/dist/eslint/{config → core}/directives.js +6 -5
  5. package/dist/eslint/core/js.js +32 -0
  6. package/dist/eslint/core/jsdoc.js +59 -0
  7. package/dist/eslint/core/json.js +39 -0
  8. package/dist/eslint/{config → core}/license.js +13 -12
  9. package/dist/eslint/{config → core}/packages.d.ts +1 -1
  10. package/dist/eslint/{config → core}/packages.js +14 -11
  11. package/dist/eslint/core/promises.js +31 -0
  12. package/dist/eslint/core/regexp.d.ts +11 -0
  13. package/dist/eslint/core/regexp.js +21 -0
  14. package/dist/eslint/core/stylistic.js +120 -0
  15. package/dist/eslint/{config → core}/ts.js +10 -6
  16. package/dist/eslint/core/vue.js +98 -0
  17. package/dist/eslint/{config → core}/yaml.js +12 -12
  18. package/dist/eslint/env/browser.js +5 -5
  19. package/dist/eslint/env/codecept.js +5 -5
  20. package/dist/eslint/env/decorators.js +3 -3
  21. package/dist/eslint/env/eslint.js +4 -4
  22. package/dist/eslint/env/jest.js +7 -7
  23. package/dist/eslint/env/node.js +5 -5
  24. package/dist/eslint/env/project.js +4 -4
  25. package/dist/eslint/env/react.js +8 -8
  26. package/dist/eslint/env/tsconfig.js +4 -4
  27. package/dist/eslint/env/vitest.js +6 -6
  28. package/dist/eslint/index.d.ts +8 -4
  29. package/dist/eslint/index.js +63 -52
  30. package/dist/eslint/shared/env-utils.d.ts +30 -28
  31. package/dist/eslint/shared/env-utils.js +22 -26
  32. package/dist/eslint/shared/restricted.d.ts +4 -1
  33. package/dist/eslint/shared/restricted.js +14 -10
  34. package/dist/eslint/shared/unittest.d.ts +4 -1
  35. package/dist/eslint/shared/unittest.js +9 -6
  36. package/dist/stylelint/index.d.ts +2 -1
  37. package/dist/stylelint/index.js +3 -1
  38. package/dist/utils/{index.d.ts → resolver.d.ts} +1 -1
  39. package/dist/utils/{index.js → resolver.js} +1 -1
  40. package/dist/utils/utils.d.ts +31 -0
  41. package/dist/utils/utils.js +40 -0
  42. package/docs/eslint/README.md +83 -23
  43. package/docs/eslint/env/browser.md +12 -8
  44. package/docs/eslint/env/codecept.md +12 -8
  45. package/docs/eslint/env/decorators.md +12 -8
  46. package/docs/eslint/env/eslint.md +12 -8
  47. package/docs/eslint/env/jest.md +12 -8
  48. package/docs/eslint/env/node.md +12 -8
  49. package/docs/eslint/env/project.md +34 -22
  50. package/docs/eslint/env/react.md +12 -8
  51. package/docs/eslint/env/tsconfig.md +12 -9
  52. package/docs/eslint/env/vitest.md +12 -8
  53. package/docs/stylelint/README.md +45 -13
  54. package/package.json +20 -14
  55. package/dist/eslint/config/base.js +0 -120
  56. package/dist/eslint/config/js.js +0 -31
  57. package/dist/eslint/config/jsdoc.js +0 -56
  58. package/dist/eslint/config/json.js +0 -39
  59. package/dist/eslint/config/promises.js +0 -27
  60. package/dist/eslint/config/stylistic.js +0 -117
  61. package/dist/eslint/config/vue.js +0 -97
  62. package/dist/index.d.ts +0 -3
  63. package/dist/index.js +0 -3
  64. package/docs/utils/README.md +0 -30
  65. /package/dist/eslint/{config → core}/base.d.ts +0 -0
  66. /package/dist/eslint/{config → core}/directives.d.ts +0 -0
  67. /package/dist/eslint/{config → core}/js.d.ts +0 -0
  68. /package/dist/eslint/{config → core}/jsdoc.d.ts +0 -0
  69. /package/dist/eslint/{config → core}/json.d.ts +0 -0
  70. /package/dist/eslint/{config → core}/license.d.ts +0 -0
  71. /package/dist/eslint/{config → core}/markdown.d.ts +0 -0
  72. /package/dist/eslint/{config → core}/markdown.js +0 -0
  73. /package/dist/eslint/{config → core}/promises.d.ts +0 -0
  74. /package/dist/eslint/{config → core}/stylistic.d.ts +0 -0
  75. /package/dist/eslint/{config → core}/ts.d.ts +0 -0
  76. /package/dist/eslint/{config → core}/vue.d.ts +0 -0
  77. /package/dist/eslint/{config → core}/yaml.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## `1.6.1` – 2025-Jul-16
4
+
5
+ - removed: (ESLint) deprecated rule `@stylistic/jsx-indent`
6
+
7
+ ## `1.6.0` – 2025-Jul-16
8
+
9
+ - changed: dedicated package exports `/eslint` and `/stylelint`
10
+ - changed: (ESLint) replaced `configure` function with `defineConfig` function
11
+ - changed: (StyleLint) replaced `configure` function with `defineConfig` function
12
+ - changed: replaced `resolver` function with `createResolver` function (exported from both sub packages)
13
+ - added: (ESLint) new plugin `eslint-plugin-regexp`
14
+ - added: (ESLint) disable `no-duplicate-imports` rule in `.d.ts` files
15
+ - chore: bump dependencies
16
+
3
17
  ## `1.5.1` – 2025-Jul-03
4
18
 
5
19
  - 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 `configure` 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.).
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
- ```js
12
- // eslint.config.js
13
- import { eslint } from "@open-xchange/linter-presets"
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
- ...eslint.configure({ /* config options */ }),
17
+ // required parameter: global project configuration
18
+ { /* config options */ },
19
19
 
20
20
  // add environments
21
- ...eslint.env.browser({ files: ["src/**/*.js"], /* ... */ }),
22
- ...eslint.env.vitest({ files: ["test/**/*.js"], /* ... */ }),
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](./doc/eslint/README.md) for more details.
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 `configure` function for setting up the entire project (e.g. CSS files, SCSS files, license headers, etc.).
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
- ```js
37
+ ```ts
38
38
  // stylelint.config.js
39
- import { stylelint } from "@open-xchange/linter-presets"
39
+ import { defineConfig } from "@open-xchange/linter-presets/stylelint";
40
40
 
41
- export default stylelint.configure({
41
+ export default defineConfig({
42
42
  /* config options */
43
- })
43
+ });
44
44
  ```
45
45
 
46
- See the [`stylelint` module documentation](./doc/stylelint/README.md) for more details.
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
- files: [...SRC_GLOB, ...VUE_GLOB],
17
- ...commentsPluginConfigs.recommended,
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
- files: SRC_GLOB,
19
- // register rule implementations of the plugin
20
- plugins: {
21
- "license-header": licensePlugin,
22
- },
23
- // configure plugin rules
24
- rules: {
25
- "license-header/header": ["error", path],
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,5 +1,5 @@
1
1
  import type { Linter } from "eslint";
2
- import type { PackagesConfig } from "../shared/env-utils.js";
2
+ import { type PackagesConfig } from "../shared/env-utils.js";
3
3
  /**
4
4
  * Defines linting rules for outdated or unneeded external dependencies.
5
5
  *
@@ -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
- // register rule implementations and recommended rules
18
- dependPlugin.configs["flat/recommended"],
19
- {
20
- rules: {
21
- "depend/ban-dependencies": ["error", {
22
- modules: packagesConfig.banned,
23
- allowed: packagesConfig.allowed,
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,120 @@
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-props": ["error", indent.js],
57
+ "@stylistic/jsx-one-expression-per-line": "off",
58
+ "@stylistic/jsx-pascal-case": "error",
59
+ "@stylistic/jsx-quotes": "error",
60
+ "@stylistic/jsx-self-closing-comp": "error",
61
+ "@stylistic/jsx-wrap-multilines": "error",
62
+ "@stylistic/key-spacing": ["error", { mode: "minimum" }],
63
+ "@stylistic/keyword-spacing": "error",
64
+ "@stylistic/linebreak-style": "error",
65
+ "@stylistic/member-delimiter-style": "error",
66
+ "@stylistic/new-parens": "error",
67
+ "@stylistic/no-extra-semi": "error",
68
+ "@stylistic/no-floating-decimal": "error",
69
+ "@stylistic/no-mixed-operators": ["error", {
70
+ groups: [
71
+ // allow to mix arithmetic operators
72
+ // ["+", "-", "*", "/", "%", "**"],
73
+ ["&", "|", "^", "~", "<<", ">>", ">>>"],
74
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
75
+ ["&&", "||"],
76
+ ["in", "instanceof"],
77
+ ],
78
+ allowSamePrecedence: true,
79
+ }],
80
+ "@stylistic/no-multiple-empty-lines": ["error", { max: 2 }],
81
+ "@stylistic/no-tabs": "error",
82
+ "@stylistic/no-trailing-spaces": "error",
83
+ "@stylistic/no-whitespace-before-property": "error",
84
+ "@stylistic/object-curly-spacing": ["error", "always"],
85
+ "@stylistic/quote-props": ["error", "as-needed"],
86
+ "@stylistic/quotes": (quotes === "off") ? "off" : ["error", quotes, { avoidEscape: true }],
87
+ "@stylistic/rest-spread-spacing": "error",
88
+ "@stylistic/semi": (semi === "off") ? "off" : ["error", semi],
89
+ "@stylistic/semi-spacing": "error",
90
+ "@stylistic/semi-style": "error",
91
+ "@stylistic/space-before-blocks": "error",
92
+ "@stylistic/space-before-function-paren": ["error", { anonymous: "always", named: "never", asyncArrow: "always" }],
93
+ "@stylistic/space-in-parens": "error",
94
+ "@stylistic/space-infix-ops": "error",
95
+ "@stylistic/space-unary-ops": "error",
96
+ "@stylistic/switch-colon-spacing": "error",
97
+ "@stylistic/template-curly-spacing": "error",
98
+ "@stylistic/template-tag-spacing": "error",
99
+ "@stylistic/type-annotation-spacing": "error",
100
+ "@stylistic/type-generic-spacing": "error",
101
+ "@stylistic/type-named-tuple-spacing": "error",
102
+ "@stylistic/wrap-iife": "error",
103
+ "@stylistic/yield-star-spacing": "error",
104
+ },
105
+ },
106
+ // "@stylistic/migrate" plugin
107
+ {
108
+ name: "stylistic:migrate",
109
+ // register rule implementations of the plugins
110
+ plugins: {
111
+ "@stylistic/migrate": migratePlugin,
112
+ },
113
+ // configure plugin rules
114
+ rules: {
115
+ "@stylistic/migrate/migrate-js": "error",
116
+ "@stylistic/migrate/migrate-ts": "error",
117
+ "@stylistic/migrate/migrate-jsx": "error",
118
+ },
119
+ });
120
+ }