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
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
{