@open-xchange/linter-presets 0.11.5 → 0.12.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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## `0.12.0` – 2024-Dec-06
4
+
5
+ - chore: bump dependencies
6
+ - add: (ESLint) more rules for Vue files
7
+
8
+ ## `0.11.6` – 2024-Dec-01
9
+
10
+ - add: (ESLint) enable standard rules in Vue files
11
+
3
12
  ## `0.11.5` – 2024-Nov-29
4
13
 
5
14
  - add: (StyleLint) enable directive `reportUnscopedDisables`
@@ -1,6 +1,6 @@
1
1
  import eslintJs from "@eslint/js";
2
2
  import babelParser from "@babel/eslint-parser";
3
- import { JS_GLOB, SRC_GLOB, extGlob } from "../shared/env-utils.js";
3
+ import { JS_GLOB, SRC_GLOB, VUE_GLOB, extGlob } from "../shared/env-utils.js";
4
4
  import { builtinRestrictedRules } from "../shared/restricted.js";
5
5
  // functions ==================================================================
6
6
  /**
@@ -58,7 +58,7 @@ export default function base(languageConfig) {
58
58
  }] : []),
59
59
  // configure linter rules
60
60
  {
61
- files: SRC_GLOB,
61
+ files: [...SRC_GLOB, ...VUE_GLOB],
62
62
  rules: {
63
63
  // enable all rules recommended by ESLint itself
64
64
  ...eslintJs.configs.recommended.rules,
@@ -1,5 +1,5 @@
1
1
  import commentsPluginConfigs from "@eslint-community/eslint-plugin-eslint-comments/configs";
2
- import { SRC_GLOB } from "../shared/env-utils.js";
2
+ import { SRC_GLOB, VUE_GLOB } from "../shared/env-utils.js";
3
3
  // functions ==================================================================
4
4
  /**
5
5
  * Checks inline linter directives.
@@ -13,7 +13,7 @@ import { SRC_GLOB } from "../shared/env-utils.js";
13
13
  export default function directives() {
14
14
  // register rule implementations and recommended rules
15
15
  return [{
16
- files: SRC_GLOB,
16
+ files: [...SRC_GLOB, ...VUE_GLOB],
17
17
  ...commentsPluginConfigs.recommended,
18
18
  }];
19
19
  }
@@ -1,5 +1,5 @@
1
1
  import type { Linter } from "eslint";
2
- import type { StylisticConfig } from "../shared/env-utils.js";
2
+ import { type StylisticConfig } from "../shared/env-utils.js";
3
3
  /**
4
4
  * Defines standard (opinionated) linter rules for source code style.
5
5
  *
@@ -1,5 +1,6 @@
1
1
  import stylisticPlugin from "@stylistic/eslint-plugin";
2
2
  import migratePlugin from "@stylistic/eslint-plugin-migrate";
3
+ import { getCommaDangleConfig } from "../shared/env-utils.js";
3
4
  // functions ==================================================================
4
5
  /**
5
6
  * Defines standard (opinionated) linter rules for source code style.
@@ -16,7 +17,7 @@ import migratePlugin from "@stylistic/eslint-plugin-migrate";
16
17
  */
17
18
  export default function stylistic(stylisticConfig) {
18
19
  // configuration properties
19
- const { indent, semi, quotes, dangle } = stylisticConfig;
20
+ const { indent, semi, quotes } = stylisticConfig;
20
21
  return [
21
22
  // globally disable all deprecated stylistic core rules
22
23
  stylisticPlugin.configs["disable-legacy"],
@@ -34,7 +35,7 @@ export default function stylistic(stylisticConfig) {
34
35
  "@stylistic/arrow-spacing": "error",
35
36
  "@stylistic/block-spacing": "error",
36
37
  "@stylistic/brace-style": ["error", "1tbs", { allowSingleLine: true }],
37
- "@stylistic/comma-dangle": (dangle === "always") ? ["error", "always-multiline"] : (dangle === "never") ? ["error", "never"] : "off",
38
+ "@stylistic/comma-dangle": getCommaDangleConfig(stylisticConfig),
38
39
  "@stylistic/comma-spacing": "error",
39
40
  "@stylistic/comma-style": "error",
40
41
  "@stylistic/computed-property-spacing": "error",
@@ -99,13 +100,6 @@ export default function stylistic(stylisticConfig) {
99
100
  "@stylistic/yield-star-spacing": "error",
100
101
  },
101
102
  },
102
- // special settings for Vue files
103
- {
104
- files: ["**/*.vue"],
105
- rules: {
106
- "@stylistic/indent": ["error", stylisticConfig.indent.vue],
107
- },
108
- },
109
103
  // "@stylistic/migrate" plugin
110
104
  {
111
105
  // register rule implementations of the plugins
@@ -1,7 +1,7 @@
1
1
  import vuePlugin from "eslint-plugin-vue";
2
2
  import vueParser from "vue-eslint-parser";
3
3
  import tseslint from "typescript-eslint";
4
- import { fixMissingFilesOption } from "../shared/env-utils.js";
4
+ import { fixMissingFilesOption, getCommaDangleConfig } from "../shared/env-utils.js";
5
5
  // functions ==================================================================
6
6
  /**
7
7
  * Creates configuration objects with linter rules for Vue.js.
@@ -37,9 +37,53 @@ export default function vue(languageConfig, stylisticConfig) {
37
37
  // reconfigure plugin rules
38
38
  {
39
39
  rules: {
40
- "vue/html-indent": ["error", stylisticConfig.indent.vue],
40
+ "no-undef": "off",
41
+ "no-unused-vars": "off",
42
+ "no-useless-assignment": "off",
43
+ "vue/block-order": ["error", { order: ["script", "template", "style"] }],
44
+ "vue/component-api-style": "error",
45
+ "vue/define-emits-declaration": "error",
46
+ "vue/define-macros-order": "error",
47
+ "vue/define-props-declaration": "error",
48
+ "vue/eqeqeq": "error",
49
+ "vue/html-button-has-type": "error",
41
50
  "vue/max-attributes-per-line": "off",
51
+ "vue/no-console": "error",
52
+ "vue/no-empty-pattern": "error",
53
+ "vue/no-irregular-whitespace": "error",
54
+ "vue/no-sparse-arrays": "error",
55
+ "vue/no-template-target-blank": "error",
56
+ "vue/no-use-v-else-with-v-for": "error",
57
+ "vue/no-useless-concat": "error",
58
+ "vue/no-useless-v-bind": "error",
59
+ "vue/object-shorthand": "error",
60
+ "vue/padding-line-between-blocks": "error",
61
+ "vue/prefer-define-options": "error",
62
+ "vue/prefer-true-attribute-shorthand": "error",
63
+ "vue/prefer-use-template-ref": "error",
64
+ "vue/require-explicit-slots": "error",
65
+ "vue/require-typed-ref": "error",
42
66
  "vue/singleline-html-element-content-newline": "off",
67
+ // @stylistic extensions
68
+ "vue/array-bracket-spacing": "error",
69
+ "vue/arrow-spacing": "error",
70
+ "vue/block-spacing": "error",
71
+ "vue/brace-style": ["error", "1tbs", { allowSingleLine: true }],
72
+ "vue/comma-dangle": getCommaDangleConfig(stylisticConfig),
73
+ "vue/comma-spacing": "error",
74
+ "vue/comma-style": "error",
75
+ "vue/dot-notation": "error",
76
+ "vue/func-call-spacing": "error",
77
+ "vue/html-indent": ["error", stylisticConfig.indent.vue],
78
+ "vue/key-spacing": ["error", { mode: "minimum" }],
79
+ "vue/keyword-spacing": "error",
80
+ "vue/object-curly-spacing": ["error", "always"],
81
+ "vue/quote-props": ["error", "as-needed"],
82
+ "vue/script-indent": ["error", stylisticConfig.indent.vue, { switchCase: 1 }],
83
+ "vue/space-in-parens": "error",
84
+ "vue/space-infix-ops": "error",
85
+ "vue/space-unary-ops": "error",
86
+ "vue/template-curly-spacing": "error",
43
87
  },
44
88
  },
45
89
  ]);
@@ -23,7 +23,9 @@ export interface EnvNodeSharedSettings {
23
23
  */
24
24
  export interface EnvNodeOptions extends EnvRestrictedOptions {
25
25
  /**
26
- * The module mode used by the linted files. Default value is "module".
26
+ * The module mode used by the linted files.
27
+ *
28
+ * @default "module"
27
29
  */
28
30
  sourceType?: LanguageOptions["sourceType"];
29
31
  /**
@@ -76,15 +76,7 @@ export default function react(envOptions) {
76
76
  },
77
77
  }),
78
78
  // "react-refresh" plugin
79
- createConfig(envOptions, {
80
- // register rule implementations of the plugins
81
- plugins: {
82
- "react-refresh": reactRefreshPlugin,
83
- },
84
- rules: {
85
- "react-refresh/only-export-components": ["error", { allowConstantExport: true }],
86
- },
87
- }),
79
+ createConfig(envOptions, reactRefreshPlugin.configs.vite),
88
80
  // "jsx-a11y" plugin
89
81
  createConfig(envOptions, jsxA11yPlugin.flatConfigs.recommended),
90
82
  // custom rules
@@ -14,7 +14,9 @@ export interface RuleNoInvalidHierarchyPackage {
14
14
  * installation. Such a package cannot be imported statically (with
15
15
  * `import` statement) from a non-optional package, but can only be loaded
16
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`.
17
+ * static imports of optional code as an error.
18
+ *
19
+ * @default false
18
20
  */
19
21
  optional?: boolean;
20
22
  }
@@ -8,7 +8,8 @@ export type DeepRequired<T> = {
8
8
  export interface LanguageOptions {
9
9
  /**
10
10
  * The ECMAScript version to be used in the project (version or year).
11
- * Default value is `latest`.
11
+ *
12
+ * @default "latest"
12
13
  */
13
14
  ecmaVersion?: Linter.EcmaVersion;
14
15
  /**
@@ -17,13 +18,15 @@ export interface LanguageOptions {
17
18
  * - "module": The files will be considered being ES modules.
18
19
  * - "commonjs": The files will be considered being CommonJS modules.
19
20
  *
20
- * Default value is "module".
21
+ * @default "module"
21
22
  */
22
23
  sourceType?: "module" | "commonjs";
23
24
  /**
24
25
  * Whether to support native ES decorators in JavaScript code (via Babel
25
26
  * plugin). Does not affect TypeScript code which uses an own parser aware
26
- * of the decorator syntax. Default value is `false`.
27
+ * of the decorator syntax.
28
+ *
29
+ * @default false
27
30
  */
28
31
  nativeDecorators?: boolean;
29
32
  }
@@ -34,19 +37,26 @@ export type LanguageConfig = DeepRequired<LanguageOptions>;
34
37
  export interface IndentOptions {
35
38
  /**
36
39
  * Indentation size for JavaScript and TypeScript files, including JSX.
37
- * Default value is `4`.
40
+ *
41
+ * @default 4
38
42
  */
39
43
  js?: number;
40
44
  /**
41
- * Indentation size for JSON files. Default value is `4`.
45
+ * Indentation size for JSON files.
46
+ *
47
+ * @default 4
42
48
  */
43
49
  json?: number;
44
50
  /**
45
- * Indentation size for YAML files. Default value is `2`.
51
+ * Indentation size for YAML files.
52
+ *
53
+ * @default 2
46
54
  */
47
55
  yaml?: number;
48
56
  /**
49
- * Indentation size for Vue.js files. Default value is `4`.
57
+ * Indentation size for Vue.js files (script and template blocks).
58
+ *
59
+ * @default 4
50
60
  */
51
61
  vue?: number;
52
62
  }
@@ -66,11 +76,13 @@ export interface StylisticOptions {
66
76
  * - "never": Require to omit semicolons according to ASI rules.
67
77
  * - "off": Semicolons will not be checked.
68
78
  *
69
- * Default value is "always".
79
+ * @default "always"
70
80
  */
71
81
  semi?: "always" | "never" | "off";
72
82
  /**
73
- * The type of the string delimiter character. Default value is "double".
83
+ * The type of the string delimiter character.
84
+ *
85
+ * @default "double"
74
86
  */
75
87
  quotes?: "single" | "double" | "off";
76
88
  /**
@@ -82,7 +94,7 @@ export interface StylisticOptions {
82
94
  * - "never": Dangling commas will be forbidden.
83
95
  * - "off": Dangling commas will not be checked.
84
96
  *
85
- * Default value is "always".
97
+ * @default "always"
86
98
  */
87
99
  dangle?: "always" | "never" | "off";
88
100
  }
@@ -138,6 +150,10 @@ export declare const DTS_GLOB: string[];
138
150
  * Glob array for all source files (JavaScript and TypeScript).
139
151
  */
140
152
  export declare const SRC_GLOB: string[];
153
+ /**
154
+ * Glob array for all VueJS SFC files.
155
+ */
156
+ export declare const VUE_GLOB: string[];
141
157
  /**
142
158
  * Shared options for the core rule `no-unused-vars`, and the plugin rule
143
159
  * `@typescript-eslint/no-unused-vars`.
@@ -243,3 +259,14 @@ export declare function fixMissingFilesOption(configs: Linter.Config[]): Linter.
243
259
  * The converted rules record.
244
260
  */
245
261
  export declare function convertRuleWarningsToErrors(rules: Linter.RulesRecord): Linter.RulesRecord;
262
+ /**
263
+ * Translates the stylistic option `dangle` to the configuration options for
264
+ * "comma-dangle" rules.
265
+ *
266
+ * @param stylisticConfig
267
+ * Resolved stylistic configuration options.
268
+ *
269
+ * @returns
270
+ * The configuration options for "comma-dangle" rules.
271
+ */
272
+ export declare function getCommaDangleConfig(stylisticConfig: StylisticConfig): Linter.RuleEntry;
@@ -27,6 +27,10 @@ export const DTS_GLOB = extGlob(TS_EXTENSIONS.map(ext => "d." + ext));
27
27
  * Glob array for all source files (JavaScript and TypeScript).
28
28
  */
29
29
  export const SRC_GLOB = extGlob(SRC_EXTENSIONS);
30
+ /**
31
+ * Glob array for all VueJS SFC files.
32
+ */
33
+ export const VUE_GLOB = extGlob(["vue"]);
30
34
  /**
31
35
  * Shared options for the core rule `no-unused-vars`, and the plugin rule
32
36
  * `@typescript-eslint/no-unused-vars`.
@@ -161,3 +165,17 @@ export function convertRuleWarningsToErrors(rules) {
161
165
  return [key, value];
162
166
  }));
163
167
  }
168
+ /**
169
+ * Translates the stylistic option `dangle` to the configuration options for
170
+ * "comma-dangle" rules.
171
+ *
172
+ * @param stylisticConfig
173
+ * Resolved stylistic configuration options.
174
+ *
175
+ * @returns
176
+ * The configuration options for "comma-dangle" rules.
177
+ */
178
+ export function getCommaDangleConfig(stylisticConfig) {
179
+ const { dangle } = stylisticConfig;
180
+ return (dangle === "always") ? ["error", "always-multiline"] : (dangle === "never") ? ["error", "never"] : "off";
181
+ }
@@ -49,10 +49,10 @@ export interface EnvRestrictedOption extends EnvRestrictedItems {
49
49
  /**
50
50
  * Whether the environment supports native decorators. In this case, it
51
51
  * will be required to replace TypeScript decorated `private` methods with
52
- * native `#private` methods.
52
+ * native `#private` methods. TypeScript's experimental decorators cannot
53
+ * be used with native `#private` fields.
53
54
  *
54
- * Default value is `false` (TypeScript's experimental decorators cannot be
55
- * used with native `#private` fields).
55
+ * @default false
56
56
  */
57
57
  nativeDecorators?: boolean;
58
58
  /**
@@ -7,7 +7,9 @@ export interface EnvUnitTestOptions extends EnvBaseOptions {
7
7
  /**
8
8
  * Specifies whether to include `eslint-plugin-jest-dom`. Should only be
9
9
  * used, if the package `@testing-library/jest-dom` has been installed in
10
- * the project. Default value is `false`.
10
+ * the project.
11
+ *
12
+ * @default false
11
13
  */
12
14
  jestDom?: boolean;
13
15
  /**
@@ -4,12 +4,15 @@ import type { Config } from "stylelint";
4
4
  */
5
5
  export interface StylisticOptions {
6
6
  /**
7
- * Default indentation size (number of space characters). Default value is
8
- * `4`.
7
+ * Default indentation size (number of space characters).
8
+ *
9
+ * @default 4
9
10
  */
10
11
  indent?: number;
11
12
  /**
12
- * The type of the string delimiter character. Default value is "double".
13
+ * The type of the string delimiter character.
14
+ *
15
+ * @default "double"
13
16
  */
14
17
  quotes?: "single" | "double" | "off";
15
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/linter-presets",
3
- "version": "0.11.5",
3
+ "version": "0.12.0",
4
4
  "description": "Configuration presets for ESLint and StyleLint",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,17 +25,17 @@
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-react/eslint-plugin": "^1.17.1",
29
- "@eslint/compat": "^1.2.3",
30
- "@eslint/js": "^9.15.0",
28
+ "@eslint-react/eslint-plugin": "^1.17.3",
29
+ "@eslint/compat": "^1.2.4",
30
+ "@eslint/js": "^9.16.0",
31
31
  "@eslint/markdown": "^6.2.1",
32
32
  "@stylistic/eslint-plugin": "^2.11.0",
33
33
  "@stylistic/eslint-plugin-migrate": "^2.11.0",
34
34
  "@stylistic/stylelint-config": "^2.0.0",
35
35
  "@stylistic/stylelint-plugin": "^3.1.1",
36
- "@vitest/eslint-plugin": "^1.1.12",
36
+ "@vitest/eslint-plugin": "^1.1.14",
37
37
  "confusing-browser-globals": "^1.0.11",
38
- "eslint-import-resolver-typescript": "^3.6.3",
38
+ "eslint-import-resolver-typescript": "^3.7.0",
39
39
  "eslint-plugin-chai-expect": "^3.1.0",
40
40
  "eslint-plugin-codeceptjs": "^1.3.0",
41
41
  "eslint-plugin-eslint-plugin": "^6.3.2",
@@ -48,29 +48,29 @@
48
48
  "eslint-plugin-license-header": "^0.6.1",
49
49
  "eslint-plugin-n": "^17.14.0",
50
50
  "eslint-plugin-promise": "^7.2.1",
51
- "eslint-plugin-react-hooks": "^5.0.0",
51
+ "eslint-plugin-react-hooks": "^5.1.0",
52
52
  "eslint-plugin-react-hooks-static-deps": "^1.0.7",
53
- "eslint-plugin-react-refresh": "^0.4.14",
54
- "eslint-plugin-testing-library": "^7.0.0",
55
- "eslint-plugin-vue": "^9.31.0",
56
- "eslint-plugin-yml": "^1.15.0",
53
+ "eslint-plugin-react-refresh": "^0.4.16",
54
+ "eslint-plugin-testing-library": "^7.1.0",
55
+ "eslint-plugin-vue": "^9.32.0",
56
+ "eslint-plugin-yml": "^1.16.0",
57
57
  "find-up": "^7.0.0",
58
- "globals": "^15.12.0",
58
+ "globals": "^15.13.0",
59
59
  "picomatch": "^4.0.2",
60
60
  "postcss-html": "^1.7.0",
61
61
  "stylelint-config-standard": "^36.0.1",
62
62
  "stylelint-config-standard-less": "^3.0.1",
63
- "stylelint-config-standard-scss": "^13.1.0",
63
+ "stylelint-config-standard-scss": "^14.0.0",
64
64
  "stylelint-config-standard-vue": "^1.0.0",
65
65
  "stylelint-plugin-license-header": "^1.0.3",
66
- "typescript-eslint": "^8.16.0",
66
+ "typescript-eslint": "^8.17.0",
67
67
  "vue-eslint-parser": "^9.4.3"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/confusing-browser-globals": "^1.0.3",
71
71
  "@types/picomatch": "^3.0.1",
72
- "@typescript-eslint/utils": "^8.16.0",
73
- "eslint": "^9.15.0",
72
+ "@typescript-eslint/utils": "^8.17.0",
73
+ "eslint": "^9.16.0",
74
74
  "jest": "^29.7.0",
75
75
  "rimraf": "^6.0.1",
76
76
  "stylelint": "^16.11.0",
@@ -80,7 +80,7 @@
80
80
  "eslint": "^9.10.0",
81
81
  "jest": "^29.7.0",
82
82
  "postcss": "^8.4.0",
83
- "stylelint": "^16.8.0",
83
+ "stylelint": "^16.11.0",
84
84
  "typescript": "^5.5.0",
85
85
  "vitest": "^2.0.0"
86
86
  },