Skip to content

Commit

Permalink
✨ Add react-hook rules (#9)
Browse files Browse the repository at this point in the history
* Add react-hooks rules

* Bump version
  • Loading branch information
arelstone authored Nov 2, 2021
1 parent 37ab17e commit fc3c16f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = {
'import',
'eslint-plugin-react',
'@typescript-eslint',
'no-unused-react-component-methods'
'no-unused-react-component-methods',
'react-hooks'
],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down Expand Up @@ -98,6 +99,8 @@ module.exports = {
"format": ["UPPER_CASE", "strictCamelCase"],
"modifiers": ["const", "global"]
}
]
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paralenz/eslint-config-typescript-react",
"version": "0.0.8",
"version": "1.0.0",
"description": "Paralenz eslint configuration for typescript and React",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -36,6 +36,7 @@
"eslint-plugin-no-unused-react-component-methods": "^1.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-native": "^3.10.0",
"eslint-plugin-standard": "^5.0.0",
"standard": "^16.0.3"
Expand Down
7 changes: 7 additions & 0 deletions tests/react-hooks/exhaustive-deps.error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useEffect } from "react"

export const useMyHook = (state: any) => {
useEffect(()=>{
console.log(state)
}, [])
}
7 changes: 7 additions & 0 deletions tests/react-hooks/exhaustive-deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useEffect } from "react"

export const useMyHook = (state: any) => {
useEffect(()=>{
console.log(state)
}, [state])
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,11 @@ eslint-plugin-promise@~4.2.1:
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz"
integrity sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==

eslint-plugin-react-hooks@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556"
integrity sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ==

eslint-plugin-react-native-globals@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-native-globals/-/eslint-plugin-react-native-globals-0.1.2.tgz"
Expand Down

0 comments on commit fc3c16f

Please sign in to comment.