Skip to content

Commit 8b5b2cb

Browse files
feat(react): add update react rules
1 parent 13260cf commit 8b5b2cb

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"typescript": "5.5.3"
121121
},
122122
"peerDependencies": {
123-
"@eslint-react/eslint-plugin": "^1.5.8",
123+
"@eslint-react/eslint-plugin": "^1.5.27",
124124
"eslint": ">=8.40.0",
125125
"eslint-plugin-react-hooks": "^4.6.0"
126126
},

src/configs/react.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function react(
102102
"react/no-unused-state": "warn",
103103
"react/no-useless-fragment": "warn",
104104
"react/prefer-destructuring-assignment": "warn",
105-
"react/prefer-read-only-props": "off",
105+
"react/prefer-read-only-props": "error",
106106
"react/prefer-shorthand-boolean": "off",
107107
"react/prefer-shorthand-fragment": "warn",
108108

@@ -113,6 +113,8 @@ export async function react(
113113
"react-hooks-extra/ensure-custom-hooks-using-other-hooks": "error",
114114
"react-hooks-extra/ensure-use-callback-has-non-empty-deps": "error",
115115
"react-hooks-extra/ensure-use-memo-has-non-empty-deps": "error",
116+
"react-hooks-extra/no-direct-set-state-in-use-effect": "error",
117+
"react-hooks-extra/no-direct-set-state-in-use-layout-effect": "error",
116118
"react-hooks-extra/prefer-use-state-lazy-initialization": "error",
117119
// recommended rules from @eslint-react/naming-convention
118120
"react-naming-convention/filename-extension": ["warn", "as-needed"],

src/typegen.d.ts

+30
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,16 @@ export interface RuleOptions {
14291429
* @see https://eslint-react.xyz/docs/rules/hooks-extra-ensure-use-memo-has-non-empty-deps
14301430
*/
14311431
'no-autofix/@eslint-react/hooks-extra/ensure-use-memo-has-non-empty-deps'?: Linter.RuleEntry<[]>
1432+
/**
1433+
* disallow direct calls to the 'set' function of 'useState' in 'useEffect'
1434+
* @see https://eslint-react.xyz/docs/rules/hooks-extra-no-direct-set-state-in-use-effect
1435+
*/
1436+
'no-autofix/@eslint-react/hooks-extra/no-direct-set-state-in-use-effect'?: Linter.RuleEntry<[]>
1437+
/**
1438+
* disallow direct calls to the 'set' function of 'useState' in 'useLayoutEffect'
1439+
* @see https://eslint-react.xyz/docs/rules/hooks-extra-no-direct-set-state-in-use-layout-effect
1440+
*/
1441+
'no-autofix/@eslint-react/hooks-extra/no-direct-set-state-in-use-layout-effect'?: Linter.RuleEntry<[]>
14321442
/**
14331443
* disallow function calls in 'useState' that aren't wrapped in an initializer function
14341444
* @see https://eslint-react.xyz/docs/rules/hooks-extra-prefer-use-state-lazy-initialization
@@ -7567,6 +7577,16 @@ export interface RuleOptions {
75677577
* @see https://eslint-react.xyz/docs/rules/hooks-extra-ensure-use-memo-has-non-empty-deps
75687578
*/
75697579
'no-autofix/react-hooks-extra/ensure-use-memo-has-non-empty-deps'?: Linter.RuleEntry<[]>
7580+
/**
7581+
* disallow direct calls to the 'set' function of 'useState' in 'useEffect'
7582+
* @see https://eslint-react.xyz/docs/rules/hooks-extra-no-direct-set-state-in-use-effect
7583+
*/
7584+
'no-autofix/react-hooks-extra/no-direct-set-state-in-use-effect'?: Linter.RuleEntry<[]>
7585+
/**
7586+
* disallow direct calls to the 'set' function of 'useState' in 'useLayoutEffect'
7587+
* @see https://eslint-react.xyz/docs/rules/hooks-extra-no-direct-set-state-in-use-layout-effect
7588+
*/
7589+
'no-autofix/react-hooks-extra/no-direct-set-state-in-use-layout-effect'?: Linter.RuleEntry<[]>
75707590
/**
75717591
* disallow function calls in 'useState' that aren't wrapped in an initializer function
75727592
* @see https://eslint-react.xyz/docs/rules/hooks-extra-prefer-use-state-lazy-initialization
@@ -10746,6 +10766,16 @@ export interface RuleOptions {
1074610766
* @see https://eslint-react.xyz/docs/rules/hooks-extra-ensure-use-memo-has-non-empty-deps
1074710767
*/
1074810768
'react-hooks-extra/ensure-use-memo-has-non-empty-deps'?: Linter.RuleEntry<[]>
10769+
/**
10770+
* disallow direct calls to the 'set' function of 'useState' in 'useEffect'
10771+
* @see https://eslint-react.xyz/docs/rules/hooks-extra-no-direct-set-state-in-use-effect
10772+
*/
10773+
'react-hooks-extra/no-direct-set-state-in-use-effect'?: Linter.RuleEntry<[]>
10774+
/**
10775+
* disallow direct calls to the 'set' function of 'useState' in 'useLayoutEffect'
10776+
* @see https://eslint-react.xyz/docs/rules/hooks-extra-no-direct-set-state-in-use-layout-effect
10777+
*/
10778+
'react-hooks-extra/no-direct-set-state-in-use-layout-effect'?: Linter.RuleEntry<[]>
1074910779
/**
1075010780
* disallow function calls in 'useState' that aren't wrapped in an initializer function
1075110781
* @see https://eslint-react.xyz/docs/rules/hooks-extra-prefer-use-state-lazy-initialization

0 commit comments

Comments
 (0)