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
This commit is contained in:
Martin Pitt 2019-10-16 11:00:17 +02:00
parent 31d628cffc
commit 98b69f4f97
2 changed files with 5 additions and 1 deletions

View file

@ -13,7 +13,7 @@
}, },
"sourceType": "module" "sourceType": "module"
}, },
"plugins": ["flowtype", "react"], "plugins": ["flowtype", "react", "react-hooks"],
"rules": { "rules": {
"indent": ["error", 4, "indent": ["error", 4,
{ {
@ -28,6 +28,9 @@
"react/jsx-indent": ["error", 4], "react/jsx-indent": ["error", 4],
"semi": ["error", "always", { "omitLastInOneLineBlock": true }], "semi": ["error", "always", { "omitLastInOneLineBlock": true }],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"camelcase": "off", "camelcase": "off",
"comma-dangle": "off", "comma-dangle": "off",
"curly": "off", "curly": "off",

View file

@ -31,6 +31,7 @@
"eslint-plugin-node": "^10.0.0", "eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.14.3", "eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^2.1.2",
"eslint-plugin-standard": "^4.0.1", "eslint-plugin-standard": "^4.0.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0", "extract-text-webpack-plugin": "^4.0.0-beta.0",
"htmlparser": "^1.7.7", "htmlparser": "^1.7.7",