@open-xchange/linter-presets 1.18.5 → 1.18.6
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 +4 -0
- package/dist/eslint/env/react.d.ts +2 -2
- package/dist/eslint/env/react.js +10 -8
- package/docs/eslint/env/react.md +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,13 +4,13 @@ import type { ConfigArg, EnvBaseOptions } from "../shared/env-utils.js";
|
|
|
4
4
|
*/
|
|
5
5
|
export interface EnvReactOptions extends EnvBaseOptions {
|
|
6
6
|
/**
|
|
7
|
-
* Configuration for the rule 'react
|
|
7
|
+
* Configuration for the rule '@eslint-react/rules-of-hooks'.
|
|
8
8
|
*
|
|
9
9
|
* Additional hooks that will be treated as effect hooks, like 'useEffect'.
|
|
10
10
|
*/
|
|
11
11
|
effectHooks?: readonly string[];
|
|
12
12
|
/**
|
|
13
|
-
* Configuration for the rule '@eslint-react/
|
|
13
|
+
* Configuration for the rule '@eslint-react/set-state-in-effect'.
|
|
14
14
|
*
|
|
15
15
|
* Additional hooks that will be treated as state hooks, like 'useState'.
|
|
16
16
|
*/
|
package/dist/eslint/env/react.js
CHANGED
|
@@ -25,11 +25,11 @@ export default function react(envOptions) {
|
|
|
25
25
|
// extend shared plugin settings
|
|
26
26
|
const settings = { ...reactConfig.settings };
|
|
27
27
|
if (envOptions.effectHooks?.length) {
|
|
28
|
-
const additionalEffectHooks =
|
|
29
|
-
mergeSettings(settings, 'react-
|
|
28
|
+
const additionalEffectHooks = `/^(${envOptions.effectHooks.join('|')})$/`;
|
|
29
|
+
mergeSettings(settings, 'react-x', { additionalEffectHooks });
|
|
30
30
|
}
|
|
31
31
|
if (envOptions.stateHooks?.length) {
|
|
32
|
-
const additionalStateHooks =
|
|
32
|
+
const additionalStateHooks = `/^(${envOptions.stateHooks.join('|')})$/`;
|
|
33
33
|
mergeSettings(settings, 'react-x', { additionalStateHooks });
|
|
34
34
|
}
|
|
35
35
|
return [
|
|
@@ -47,23 +47,25 @@ export default function react(envOptions) {
|
|
|
47
47
|
}, {
|
|
48
48
|
// custom overrides
|
|
49
49
|
'@eslint-react/jsx-dollar': 'error',
|
|
50
|
-
'@eslint-react/jsx-no-iife': 'error',
|
|
51
|
-
'@eslint-react/jsx-no-undef': 'error',
|
|
52
50
|
'@eslint-react/jsx-shorthand-boolean': 'error',
|
|
53
51
|
'@eslint-react/jsx-shorthand-fragment': 'error',
|
|
54
52
|
'@eslint-react/no-missing-component-display-name': 'error',
|
|
55
53
|
'@eslint-react/no-missing-context-display-name': 'error',
|
|
56
54
|
'@eslint-react/no-useless-fragment': ['error', { allowEmptyFragment: true }],
|
|
57
55
|
'@eslint-react/prefer-namespace-import': 'error',
|
|
58
|
-
'@eslint-react/prefer-read-only-props': 'error',
|
|
59
56
|
// dom
|
|
60
57
|
'@eslint-react/dom/no-unknown-property': 'error',
|
|
61
58
|
// naming-convention
|
|
62
|
-
'@eslint-react/naming-convention/component-name': 'error',
|
|
63
59
|
'@eslint-react/naming-convention/context-name': 'error',
|
|
64
60
|
}),
|
|
65
61
|
// 'react-hooks' plugin and recommended rules, raise all recommended rules to 'error' level
|
|
66
|
-
createConfig('env.react.react-hooks', envOptions, convertRuleWarningsToErrors(reactHooksPlugin.configs.flat.recommended)
|
|
62
|
+
createConfig('env.react.react-hooks', envOptions, convertRuleWarningsToErrors(reactHooksPlugin.configs.flat.recommended), {
|
|
63
|
+
// disable rules that are also implemented in @eslint-react
|
|
64
|
+
'react-hooks/exhaustive-deps': 'off',
|
|
65
|
+
'react-hooks/rules-of-hooks': 'off',
|
|
66
|
+
'react-hooks/set-state-in-effect': 'off',
|
|
67
|
+
'react-hooks/set-state-in-render': 'off',
|
|
68
|
+
}),
|
|
67
69
|
// 'react-refresh' plugin
|
|
68
70
|
createConfig('env.react.react-refresh', envOptions, reactRefresh.configs.vite()),
|
|
69
71
|
// 'jsx-a11y' plugin
|
package/docs/eslint/env/react.md
CHANGED
|
@@ -21,8 +21,8 @@ function react(options: EnvReactOptions): ConfigArg
|
|
|
21
21
|
| `files` | `Array<string\|string[]>` | _required_ | Glob patterns for source files to be included. Use embedded arrays for AND patterns. |
|
|
22
22
|
| `ignores` | `string[]` | `[]` | Glob patterns for source files matching `files` to be ignored. |
|
|
23
23
|
| `rules` | `RulesConfig` | `{}` | Additional linter rules to be added to the configuration. |
|
|
24
|
-
| `effectHooks` | `string[]` | `[]` | Additional hooks that will be treated as effect hooks, like 'useEffect'. Used by the rule [
|
|
25
|
-
| `stateHooks` | `string[]` | `[]` | Additional hooks that will be treated as state hooks, like 'useState'. Used by the rule [`@eslint-react/
|
|
24
|
+
| `effectHooks` | `string[]` | `[]` | Additional hooks that will be treated as effect hooks, like 'useEffect'. Used by the rule [`@eslint-react/exhaustive-deps`](https://www.eslint-react.xyz/docs/rules/exhaustive-deps). |
|
|
25
|
+
| `stateHooks` | `string[]` | `[]` | Additional hooks that will be treated as state hooks, like 'useState'. Used by the rule [`@eslint-react/set-state-in-effect`](https://www.eslint-react.xyz/docs/rules/set-state-in-effect). |
|
|
26
26
|
|
|
27
27
|
## Example
|
|
28
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/linter-presets",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.6",
|
|
4
4
|
"description": "Configuration presets for ESLint and StyleLint",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@babel/eslint-parser": "^7.28.6",
|
|
27
27
|
"@babel/plugin-proposal-decorators": "^7.29.0",
|
|
28
28
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
|
29
|
-
"@eslint-react/eslint-plugin": "^
|
|
29
|
+
"@eslint-react/eslint-plugin": "^3.0.0",
|
|
30
30
|
"@eslint/compat": "^2.0.3",
|
|
31
31
|
"@eslint/config-helpers": "^0.5.3",
|
|
32
32
|
"@eslint/js": "^9.39.4",
|