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 committed by Martin Pitt
parent 31d628cffc
commit 024b1a2b16
2 changed files with 5 additions and 1 deletions

View file

@ -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",

View file

@ -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",