Skip to content

Commit

Permalink
Add the eslint-plugin-react-hooks plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 4, 2019
1 parent f3b3978 commit 51ecc0b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module.exports = {
}
},
plugins: [
'react'
'react',
'react-hooks'
],
settings: {
react: {
Expand Down Expand Up @@ -142,6 +143,13 @@ module.exports = {
logical: 'ignore',
prop: 'ignore'
}
]
],

'react-hooks/rules-of-hooks': 'error',

// TODO: Make this an `error`.
// The rule needs to be more stable first, see:
// https://github.com/facebook/react/issues/14920
'react-hooks/exhaustive-deps': 'warn'
}
};
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@
"simple"
],
"devDependencies": {
"ava": "^1.1.0",
"eslint": "^5.12.0",
"eslint-plugin-react": "^7.12.3",
"ava": "^1.2.1",
"eslint": "^5.15.0",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.4.0",
"is-plain-obj": "^1.0.0",
"temp-write": "^3.1.0"
},
"peerDependencies": {
"eslint": ">=5",
"eslint-plugin-react": ">=7.12.3"
"eslint-plugin-react": ">=7.12.3",
"eslint-plugin-react-hooks": ">=1.4.0"
}
}
24 changes: 18 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## Install

```
$ npm install --save-dev eslint-config-xo eslint-config-xo-react eslint-plugin-react
$ npm install --save-dev eslint-config-xo eslint-config-xo-react eslint-plugin-react eslint-plugin-react-hooks
```


Expand All @@ -18,7 +18,10 @@ Add some ESLint config to your package.json:
{
"name": "my-awesome-project",
"eslintConfig": {
"extends": ["xo", "xo-react"]
"extends": [
"xo",
"xo-react"
]
}
}
```
Expand All @@ -27,23 +30,32 @@ Or to .eslintrc:

```json
{
"extends": ["xo", "xo-react"]
"extends": [
"xo",
"xo-react"
]
}
```

Use the `space` sub-config if you want 2 space indentation instead of tabs:

```json
{
"extends": ["xo", "xo-react/space"]
"extends": [
"xo",
"xo-react/space"
]
}
```

You can also mix it with a [XO](https://github.com/xojs/xo) sub-config:

```json
{
"extends": ["xo/esnext", "xo-react"]
"extends": [
"xo/esnext",
"xo-react"
]
}
```

Expand All @@ -53,7 +65,7 @@ You can also mix it with a [XO](https://github.com/xojs/xo) sub-config:
### Use with XO

```
$ npm install --save-dev eslint-config-xo-react eslint-plugin-react
$ npm install --save-dev eslint-config-xo-react eslint-plugin-react eslint-plugin-react-hooks
```

```json
Expand Down

0 comments on commit 51ecc0b

Please sign in to comment.