Skip to content

Commit

Permalink
feat: add recommended config eslint rule (#14762)
Browse files Browse the repository at this point in the history
* feat: add recommended config eslint rule

* add exhaustive-deps to recommended as well
  • Loading branch information
SimenB committed Feb 28, 2020
1 parent ae60caa commit 79a2512
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:
}
```

Or use the recommended config:

```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 @@ -10,6 +10,16 @@
import RuleOfHooks from './RulesOfHooks';
import ExhaustiveDeps from './ExhaustiveDeps';

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

export const rules = {
'rules-of-hooks': RuleOfHooks,
'exhaustive-deps': ExhaustiveDeps,
Expand Down

0 comments on commit 79a2512

Please sign in to comment.