Commit 29100041 authored by Robert Knight's avatar Robert Knight

Add ESLint plugin to check React hooks usage

Usage of "hooks" has to follow certain rules [1]. This adds the official
ESLint plugin to check for this.

All the checks are marked as errors following the "no warnings, only
errors" principle. ESLint suppressions can be used to ignore any cases
where we decide not to follow a "rule".

[1] https://reactjs.org/docs/hooks-rules.html
parent 05f003d3
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
"rules": { "rules": {
"mocha/no-exclusive-tests": "error", "mocha/no-exclusive-tests": "error",
"no-var": "error", "no-var": "error",
"indent": "off" "indent": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error"
}, },
"parserOptions": { "parserOptions": {
"ecmaVersion": 2018, "ecmaVersion": 2018,
...@@ -19,7 +21,8 @@ ...@@ -19,7 +21,8 @@
}, },
"plugins": [ "plugins": [
"mocha", "mocha",
"react" "react",
"react-hooks"
], ],
"settings": { "settings": {
"react": { "react": {
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
"eslint-config-hypothesis": "^1.0.0", "eslint-config-hypothesis": "^1.0.0",
"eslint-plugin-mocha": "^5.2.1", "eslint-plugin-mocha": "^5.2.1",
"eslint-plugin-react": "^7.12.4", "eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.6.0",
"exorcist": "^1.0.1", "exorcist": "^1.0.1",
"express": "^4.14.1", "express": "^4.14.1",
"extend": "^3.0.2", "extend": "^3.0.2",
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
}, },
"rules": { "rules": {
"no-console": "off", "no-console": "off",
"react-hooks/rules-of-hooks": "off"
}, },
"parserOptions": { "parserOptions": {
"ecmaVersion": 2018 "ecmaVersion": 2018
......
...@@ -3724,6 +3724,11 @@ eslint-plugin-mocha@^5.2.1: ...@@ -3724,6 +3724,11 @@ eslint-plugin-mocha@^5.2.1:
dependencies: dependencies:
ramda "^0.26.1" ramda "^0.26.1"
eslint-plugin-react-hooks@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.6.0.tgz#348efcda8fb426399ac7b8609607c7b4025a6f5f"
integrity sha512-lHBVRIaz5ibnIgNG07JNiAuBUeKhEf8l4etNx5vfAEwqQ5tcuK3jV9yjmopPgQDagQb7HwIuQVsE3IVcGrRnag==
eslint-plugin-react@^7.12.4: eslint-plugin-react@^7.12.4:
version "7.12.4" version "7.12.4"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.12.4.tgz#b1ecf26479d61aee650da612e425c53a99f48c8c" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.12.4.tgz#b1ecf26479d61aee650da612e425c53a99f48c8c"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment