chore: lint for state hooks (#31088)

This commit is contained in:
Stephen Zhou 2026-01-16 11:58:28 +08:00 committed by GitHub
parent 4bff0cd0ab
commit 7aab4529e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 385 additions and 439 deletions

View File

@ -26,7 +26,8 @@ export default antfu(
'react-hooks/preserve-manual-memoization': 'warn',
'react-hooks/purity': 'warn',
'react-hooks/refs': 'warn',
'react-hooks/set-state-in-effect': 'warn',
// prefer react-hooks-extra/no-direct-set-state-in-use-effect
'react-hooks/set-state-in-effect': 'off',
'react-hooks/set-state-in-render': 'warn',
'react-hooks/static-components': 'warn',
'react-hooks/unsupported-syntax': 'warn',
@ -53,6 +54,14 @@ export default antfu(
},
},
},
{
files: ['**/*.ts', '**/*.tsx'],
settings: {
'react-x': {
additionalStateHooks: '/^use\\w*State(?:s)?|useAtom$/u',
},
},
},
// downgrade some rules from error to warn for gradual adoption
// we should fix these in following pull requests
{

View File

@ -153,9 +153,9 @@
"zustand": "^5.0.9"
},
"devDependencies": {
"@antfu/eslint-config": "^6.7.3",
"@antfu/eslint-config": "^7.0.1",
"@chromatic-com/storybook": "^4.1.1",
"@eslint-react/eslint-plugin": "^2.3.13",
"@eslint-react/eslint-plugin": "^2.7.0",
"@mdx-js/loader": "^3.1.1",
"@mdx-js/react": "^3.1.1",
"@next/bundle-analyzer": "15.5.9",
@ -190,7 +190,7 @@
"@types/semver": "^7.7.1",
"@types/sortablejs": "^1.15.8",
"@types/uuid": "^10.0.0",
"@typescript-eslint/parser": "^8.50.0",
"@typescript-eslint/parser": "^8.53.0",
"@typescript/native-preview": "^7.0.0-dev",
"@vitejs/plugin-react": "^5.1.2",
"@vitest/coverage-v8": "4.0.16",
@ -202,7 +202,7 @@
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.26",
"eslint-plugin-sonarjs": "^3.0.5",
"eslint-plugin-storybook": "^10.1.10",
"eslint-plugin-storybook": "^10.1.11",
"eslint-plugin-tailwindcss": "^3.18.2",
"husky": "^9.1.7",
"jsdom": "^27.3.0",
@ -225,7 +225,6 @@
},
"pnpm": {
"overrides": {
"@eslint/plugin-kit@<0.3.4": "0.3.4",
"@monaco-editor/loader": "1.5.0",
"@nolyfill/safe-buffer": "npm:safe-buffer@^5.2.1",
"array-includes": "npm:@nolyfill/array-includes@^1",
@ -276,7 +275,6 @@
]
},
"resolutions": {
"@eslint/plugin-kit": "~0.3",
"@types/react": "~19.2.7",
"@types/react-dom": "~19.2.3",
"brace-expansion": "~2.0",

File diff suppressed because it is too large Load Diff