Skip to content

Commit

Permalink
build: Add eslint rules for React hooks
Browse files Browse the repository at this point in the history
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 don't have any hooks yet in our code. This enables the ESLint plugin
to guide us right from the start.
  • Loading branch information
martinpitt committed Oct 18, 2019
1 parent d45b7dd commit 4b10282
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"sourceType": "module"
},
"plugins": ["flowtype", "react", "cockpit", "jsx-a11y"],
"plugins": ["flowtype", "react", "react-hooks", "cockpit", "jsx-a11y"],
"rules": {
"indent": ["error", 4,
{
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@
"eslint-plugin-cockpit": "file:eslint-plugin-cockpit",
"eslint-plugin-flowtype": "^4.2.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.15.1",
"eslint-plugin-react-hooks": "^2.1.2",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"html-webpack-plugin": "^3.2.0",
"htmlparser": "^1.7.7",
"imports-loader": "^0.6.5",
Expand Down

0 comments on commit 4b10282

Please sign in to comment.