@open-xchange/linter-presets 1.3.0 → 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
|
@@ -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
|
}
|
package/dist/eslint/env/react.js
CHANGED
|
@@ -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", {
|
|
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
|
|
@@ -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.
|
|
@@ -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
|