[eslint-plugin-react-hooks] Added meta property (including docs) (#16607)
* [eslint-plugin-react-hooks] Added meta property (including docs) * [eslint-plugin-react-hooks] Fixed typo (`RuleOfHooks` -> `RulesOfHooks`) Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Gabriel McAdams committed
Apr 1, 2020 at 13:13 UTC
3f468448993fed1676eb251f94f1830adbc850e8
3 files changed
+19
-2
packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
+8
@@ -11,6 +11,14 @@
11
12
export default {
13
meta: {
14
+ type: 'suggestion',
15
+ docs: {
16
+ description:
17
+ 'verifies the list of dependencies for Hooks like useEffect and similar',
18
+ category: 'Best Practices',
19
+ recommended: true,
20
+ url: 'https://github.com/facebook/react/issues/14920',
21
+ },
22
fixable: 'code',
23
schema: [
24
{
packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
+9
@@ -106,6 +106,15 @@ function isInsideComponentOrHook(node) {
106
}
107
108
export default {
109
+ meta: {
110
+ type: 'problem',
111
+ docs: {
112
+ description: 'enforces the Rules of Hooks',
113
+ category: 'Possible Errors',
114
+ recommended: true,
115
+ url: 'https://reactjs.org/docs/hooks-rules.html',
116
+ },
117
+ },
118
create(context) {
119
const codePathReactHooksMapStack = [];
120
const codePathSegmentStack = [];
packages/eslint-plugin-react-hooks/src/index.js
+2
-2
@@ -7,7 +7,7 @@
7
8
'use strict';
9
10
-import RuleOfHooks from './RulesOfHooks';
10
+import RulesOfHooks from './RulesOfHooks';
11
import ExhaustiveDeps from './ExhaustiveDeps';
12
13
export const configs = {
@@ -21,6 +21,6 @@ export const configs = {
21
};
22
23
export const rules = {
24
- 'rules-of-hooks': RuleOfHooks,
24
+ 'rules-of-hooks': RulesOfHooks,
25
'exhaustive-deps': ExhaustiveDeps,
26
};