Skip to content

Commit 79a2512

Browse files
authored
feat: add recommended config eslint rule (#14762)
* feat: add recommended config eslint rule * add exhaustive-deps to recommended as well
1 parent ae60caa commit 79a2512

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/eslint-plugin-react-hooks/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ Then add it to your ESLint configuration:
3434
}
3535
```
3636

37+
Or use the recommended config:
38+
39+
```js
40+
{
41+
"extends": [
42+
// ...
43+
"plugin:react-hooks/recommended"
44+
]
45+
}
46+
```
47+
3748
## Valid and Invalid Examples
3849

3950
Please refer to the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html) documentation and the [Hooks FAQ](https://reactjs.org/docs/hooks-faq.html#what-exactly-do-the-lint-rules-enforce) to learn more about this rule.

packages/eslint-plugin-react-hooks/src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
import RuleOfHooks from './RulesOfHooks';
1111
import ExhaustiveDeps from './ExhaustiveDeps';
1212

13+
export const configs = {
14+
recommended: {
15+
plugins: ['react-hooks'],
16+
rules: {
17+
'react-hooks/rules-of-hooks': 'error',
18+
'react-hooks/exhaustive-deps': 'warn',
19+
},
20+
},
21+
};
22+
1323
export const rules = {
1424
'rules-of-hooks': RuleOfHooks,
1525
'exhaustive-deps': ExhaustiveDeps,

0 commit comments

Comments
 (0)