@open-xchange/linter-presets 1.2.37 → 1.4.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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## `1.4.0` – 2025-Jun-19
4
+
5
+ - added: (ESLint) new option "additionalHooks" for `env.react`
6
+
7
+ ## `1.3.0` – 2025-Jun-19
8
+
9
+ - chore: bump dependencies
10
+ - added: (ESLint) support for ES2026 (e.g. parse `using` keyword, `Iterator` global)
11
+ - added: (ESLint) rule `@typescript-eslint/no-unnecessary-type-conversion`
12
+
3
13
  ## `1.2.37` – 2025-Jun-12
4
14
 
5
15
  - chore: bump dependencies
@@ -57,6 +57,7 @@ export default function ts() {
57
57
  "@typescript-eslint/no-redeclare": "error",
58
58
  "@typescript-eslint/no-shadow": ["error", { ignoreOnInitialization: true }],
59
59
  "@typescript-eslint/no-unnecessary-qualifier": "error",
60
+ "@typescript-eslint/no-unnecessary-type-conversion": "error",
60
61
  "@typescript-eslint/no-unnecessary-type-parameters": "off",
61
62
  "@typescript-eslint/no-unused-vars": ["error", NO_UNUSED_VARS_OPTIONS],
62
63
  "@typescript-eslint/parameter-properties": "error",
@@ -38,7 +38,7 @@ export default function vue(languageConfig, stylisticConfig) {
38
38
  ...recommendedConfigs,
39
39
  // raise all recommended rules to "error" level
40
40
  ...recommendedConfigs.map(config => ({
41
- rules: convertRuleWarningsToErrors(config.rules ?? {}),
41
+ rules: convertRuleWarningsToErrors(config.rules),
42
42
  })),
43
43
  // reconfigure plugin rules
44
44
  {
@@ -6,6 +6,30 @@ import type { EnvBaseOptions } from "../shared/env-utils.js";
6
6
  export interface EnvReactOptions extends EnvBaseOptions {
7
7
  /**
8
8
  * Configuration for the rule "react-hooks-static-deps/exhaustive-deps".
9
+ *
10
+ * Additional hooks that will be checked for dependencies, as a dictionary
11
+ * mapping hook names to the parameter index of the callback function to be
12
+ * analyzed.
13
+ *
14
+ * @example
15
+ * additionalHooks: {
16
+ * useCustomHook: 0, // usage: `useCustomHook(callback, [deps])`
17
+ * useOtherHook: 1, // usage: `useOtherHook(value, callback, [deps])`
18
+ * }
19
+ */
20
+ additionalHooks?: Record<string, number>;
21
+ /**
22
+ * Configuration for the rule "react-hooks-static-deps/exhaustive-deps".
23
+ *
24
+ * Additional hooks that return stable values, as a dictionary mapping hook
25
+ * names to the declaration of the stable values the hook will return.
26
+ *
27
+ * @example
28
+ * staticHooks: {
29
+ * useCustomHook: true, // entire return value is stable
30
+ * useOtherHook: [false, true], // second array element is stable
31
+ * useThirdHook: { callback: true }, // property "callback" is stable
32
+ * }
9
33
  */
10
34
  staticHooks?: Record<string, boolean | boolean[] | Record<string, boolean>>;
11
35
  }
@@ -66,17 +66,20 @@ export default function react(envOptions) {
66
66
  plugins: {
67
67
  "react-hooks": reactHooksPlugin,
68
68
  },
69
- // recommended rules
70
- rules: reactHooksPlugin.configs.recommended.rules,
69
+ // recommended rules (raise all recommended rules to "error" level)
70
+ rules: convertRuleWarningsToErrors(reactHooksPlugin.configs.recommended.rules),
71
71
  }),
72
72
  // "react-hooks-static-deps" plugin
73
- envOptions.staticHooks && createConfig(envOptions, {
73
+ (envOptions.additionalHooks ?? envOptions.staticHooks) && createConfig(envOptions, {
74
74
  plugins: {
75
75
  "react-hooks-static-deps": fixupPluginRules(reactHooksStaticDepsPlugin), // https://github.com/stoikio/eslint-plugin-react-hooks-static-deps/issues/1
76
76
  },
77
77
  rules: {
78
78
  "react-hooks/exhaustive-deps": "off",
79
- "react-hooks-static-deps/exhaustive-deps": ["error", { staticHooks: envOptions.staticHooks }],
79
+ "react-hooks-static-deps/exhaustive-deps": ["error", {
80
+ additionalHooks: envOptions.additionalHooks,
81
+ staticHooks: envOptions.staticHooks,
82
+ }],
80
83
  },
81
84
  }),
82
85
  // "react-refresh" plugin
@@ -142,11 +142,11 @@ export declare const TS_EXTENSIONS: string[];
142
142
  */
143
143
  export declare const SRC_EXTENSIONS: string[];
144
144
  /**
145
- * Glob array for JavaScript source files.
145
+ * Glob array for JavaScript source files (including "jsx").
146
146
  */
147
147
  export declare const JS_GLOB: string[];
148
148
  /**
149
- * Glob array for TypeScript source files.
149
+ * Glob array for TypeScript source files (including "tsx").
150
150
  */
151
151
  export declare const TS_GLOB: string[];
152
152
  /**
@@ -273,7 +273,7 @@ export declare function fixMissingFilesOption(configs: Linter.Config[]): Linter.
273
273
  * @returns
274
274
  * The converted rules record.
275
275
  */
276
- export declare function convertRuleWarningsToErrors(rules: Partial<Linter.RulesRecord>): Partial<Linter.RulesRecord>;
276
+ export declare function convertRuleWarningsToErrors(rules: Partial<Linter.RulesRecord> | undefined): Partial<Linter.RulesRecord>;
277
277
  /**
278
278
  * Translates the stylistic option `dangle` to the configuration options for
279
279
  * "comma-dangle" rules.
@@ -12,11 +12,11 @@ export const TS_EXTENSIONS = ["ts", "tsx", "mts", "cts"];
12
12
  */
13
13
  export const SRC_EXTENSIONS = [...JS_EXTENSIONS, ...TS_EXTENSIONS];
14
14
  /**
15
- * Glob array for JavaScript source files.
15
+ * Glob array for JavaScript source files (including "jsx").
16
16
  */
17
17
  export const JS_GLOB = extGlob(JS_EXTENSIONS);
18
18
  /**
19
- * Glob array for TypeScript source files.
19
+ * Glob array for TypeScript source files (including "tsx").
20
20
  */
21
21
  export const TS_GLOB = extGlob(TS_EXTENSIONS);
22
22
  /**
@@ -163,7 +163,7 @@ export function fixMissingFilesOption(configs) {
163
163
  * The converted rules record.
164
164
  */
165
165
  export function convertRuleWarningsToErrors(rules) {
166
- return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
166
+ return rules ? Object.fromEntries(Object.entries(rules).map(([key, value]) => {
167
167
  if (value === "warn") {
168
168
  value = "error";
169
169
  }
@@ -171,7 +171,7 @@ export function convertRuleWarningsToErrors(rules) {
171
171
  value = ["error", ...value.slice(1)];
172
172
  }
173
173
  return [key, value];
174
- }));
174
+ })) : {};
175
175
  }
176
176
  /**
177
177
  * Translates the stylistic option `dangle` to the configuration options for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/linter-presets",
3
- "version": "1.2.37",
3
+ "version": "1.4.0",
4
4
  "description": "Configuration presets for ESLint and StyleLint",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,34 +31,34 @@
31
31
  "@babel/eslint-parser": "^7.27.5",
32
32
  "@babel/plugin-proposal-decorators": "^7.27.1",
33
33
  "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
34
- "@eslint-react/eslint-plugin": "^1.52.1",
34
+ "@eslint-react/eslint-plugin": "^1.52.2",
35
35
  "@eslint/compat": "^1.3.0",
36
- "@eslint/js": "^9.28.0",
36
+ "@eslint/js": "^9.29.0",
37
37
  "@eslint/markdown": "^6.5.0",
38
38
  "@stylistic/eslint-plugin": "^4.4.1",
39
39
  "@stylistic/eslint-plugin-migrate": "^4.4.1",
40
40
  "@stylistic/stylelint-config": "^2.0.0",
41
41
  "@stylistic/stylelint-plugin": "^3.1.2",
42
42
  "@types/picomatch": "^4.0.0",
43
- "@vitest/eslint-plugin": "^1.2.2",
43
+ "@vitest/eslint-plugin": "^1.2.7",
44
44
  "confusing-browser-globals": "^1.0.11",
45
45
  "eslint-plugin-chai-expect": "^3.1.0",
46
46
  "eslint-plugin-codeceptjs": "^1.3.0",
47
47
  "eslint-plugin-depend": "^1.2.0",
48
- "eslint-plugin-eslint-plugin": "^6.4.0",
49
- "eslint-plugin-jest": "^28.13.3",
48
+ "eslint-plugin-eslint-plugin": "^6.5.0",
49
+ "eslint-plugin-jest": "^29.0.1",
50
50
  "eslint-plugin-jest-dom": "^5.5.0",
51
51
  "eslint-plugin-jest-extended": "^3.0.0",
52
- "eslint-plugin-jsdoc": "^50.8.0",
52
+ "eslint-plugin-jsdoc": "^51.0.3",
53
53
  "eslint-plugin-jsonc": "^2.20.1",
54
54
  "eslint-plugin-jsx-a11y": "^6.10.2",
55
55
  "eslint-plugin-license-header": "^0.8.0",
56
- "eslint-plugin-n": "^17.19.0",
56
+ "eslint-plugin-n": "^17.20.0",
57
57
  "eslint-plugin-promise": "^7.2.1",
58
58
  "eslint-plugin-react-hooks": "^5.2.0",
59
59
  "eslint-plugin-react-hooks-static-deps": "^1.0.7",
60
60
  "eslint-plugin-react-refresh": "^0.4.20",
61
- "eslint-plugin-testing-library": "^7.5.2",
61
+ "eslint-plugin-testing-library": "^7.5.3",
62
62
  "eslint-plugin-vue": "^10.2.0",
63
63
  "eslint-plugin-yml": "^1.18.0",
64
64
  "find-up": "^7.0.0",
@@ -70,16 +70,16 @@
70
70
  "stylelint-config-standard-scss": "^15.0.1",
71
71
  "stylelint-config-standard-vue": "^1.0.0",
72
72
  "stylelint-plugin-license-header": "^1.0.3",
73
- "typescript-eslint": "^8.34.0",
73
+ "typescript-eslint": "^8.34.1",
74
74
  "vue-eslint-parser": "^10.1.3"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/confusing-browser-globals": "^1.0.3",
78
78
  "@types/eslint-scope": "^8.3.0",
79
79
  "@types/react": "^19.1.8",
80
- "@typescript-eslint/utils": "^8.34.0",
81
- "eslint": "^9.28.0",
82
- "jest": "^30.0.0",
80
+ "@typescript-eslint/utils": "^8.34.1",
81
+ "eslint": "^9.29.0",
82
+ "jest": "^30.0.1",
83
83
  "jiti": "^2.4.2",
84
84
  "premove": "^4.0.0",
85
85
  "stylelint": "^16.20.0",