From 024b1a2b165857dddef328605c6426e6c43e1935 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 16 Oct 2019 11:00:17 +0200 Subject: [PATCH] Add eslint rules for React hooks These make components with simple state (only a few variables) easier to read and maintain. See https://reactjs.org/docs/hooks-intro.html for details. Hook are available since React 16.8, and we already depend on 16.10. We can't use hooks in our actual code, as our only `Application` component needs a constructor. But this enables the ESLint plugin to guide developers to the right path if they use hooks. Closes #239 --- .eslintrc.json | 5 ++++- package.json | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index b1fe5d2..e660dc9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -13,7 +13,7 @@ }, "sourceType": "module" }, - "plugins": ["flowtype", "react"], + "plugins": ["flowtype", "react", "react-hooks"], "rules": { "indent": ["error", 4, { @@ -28,6 +28,9 @@ "react/jsx-indent": ["error", 4], "semi": ["error", "always", { "omitLastInOneLineBlock": true }], + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "error", + "camelcase": "off", "comma-dangle": "off", "curly": "off", diff --git a/package.json b/package.json index cc9e88a..8b00bcd 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "eslint-plugin-node": "^10.0.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-react": "^7.14.3", + "eslint-plugin-react-hooks": "^2.1.2", "eslint-plugin-standard": "^4.0.1", "extract-text-webpack-plugin": "^4.0.0-beta.0", "htmlparser": "^1.7.7",