Skip to content

Commit

Permalink
Add recommended config for eslint-plugin-react-hooks (#16872)
Browse files Browse the repository at this point in the history
Now the extending `plugin:react-hooks/recommended` adds this plugin and
configures both of its rules.
  • Loading branch information
silvenon committed Feb 5, 2020
1 parent 613cbd3 commit 20ef9a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/eslint-plugin-react-hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ Then add it to your ESLint configuration:
}
```

You can achieve the configuratin above by simply extending the recommended configuration:

```js
{
"extends": [
// ...
"plugin:react-hooks/recommended"
]
}
```

## Valid and Invalid Examples

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.
Expand Down
10 changes: 10 additions & 0 deletions packages/eslint-plugin-react-hooks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ export const rules = {
'rules-of-hooks': RuleOfHooks,
'exhaustive-deps': ExhaustiveDeps,
};

export const configs = {
recommended: {
plugins: ['react-hooks'],
rules: {
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
};

0 comments on commit 20ef9a7

Please sign in to comment.