diff --git a/index.js b/index.js index 700d742..db12a1e 100644 --- a/index.js +++ b/index.js @@ -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', @@ -98,6 +99,8 @@ module.exports = { "format": ["UPPER_CASE", "strictCamelCase"], "modifiers": ["const", "global"] } - ] + ], + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "error" } } diff --git a/package.json b/package.json index 04e3af4..56904c5 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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" diff --git a/tests/react-hooks/exhaustive-deps.error.ts b/tests/react-hooks/exhaustive-deps.error.ts new file mode 100644 index 0000000..006305a --- /dev/null +++ b/tests/react-hooks/exhaustive-deps.error.ts @@ -0,0 +1,7 @@ +import { useEffect } from "react" + +export const useMyHook = (state: any) => { + useEffect(()=>{ + console.log(state) + }, []) +} \ No newline at end of file diff --git a/tests/react-hooks/exhaustive-deps.ts b/tests/react-hooks/exhaustive-deps.ts new file mode 100644 index 0000000..a66a892 --- /dev/null +++ b/tests/react-hooks/exhaustive-deps.ts @@ -0,0 +1,7 @@ +import { useEffect } from "react" + +export const useMyHook = (state: any) => { + useEffect(()=>{ + console.log(state) + }, [state]) +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 979e656..af17524 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"