Add eslint-plugin-react-hooks

This commit is contained in:
Nicolas Gallagher
2020-02-04 12:50:52 -08:00
parent fc443c5abd
commit 2724ca0293
5 changed files with 22 additions and 11 deletions
+7 -2
View File
@@ -22,7 +22,8 @@
], ],
"plugins": [ "plugins": [
"promise", "promise",
"react" "react",
"react-hooks"
], ],
"env": { "env": {
"es6": true, "es6": true,
@@ -160,6 +161,10 @@
"react/self-closing-comp": 2, "react/self-closing-comp": 2,
"react/sort-comp": 0, "react/sort-comp": 0,
"react/sort-prop-types": 2, "react/sort-prop-types": 2,
"react/wrap-multilines": 0 "react/wrap-multilines": 0,
// react-hooks
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
} }
} }
+1
View File
@@ -48,6 +48,7 @@
"eslint-config-prettier": "^6.4.0", "eslint-config-prettier": "^6.4.0",
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.16.0", "eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.3.0",
"flow-bin": "^0.109.0", "flow-bin": "^0.109.0",
"glob": "^7.1.4", "glob": "^7.1.4",
"husky": "^3.0.8", "husky": "^3.0.8",
@@ -8,19 +8,19 @@ export default function StateChanges() {
currentState: AppState.currentState currentState: AppState.currentState
}); });
const handleChange = nextState => {
updateState(previousState => ({
...previousState,
[nextState]: previousState[nextState] + 1
}));
};
React.useEffect(() => { React.useEffect(() => {
const handleChange = nextState => {
updateState(previousState => ({
...previousState,
[nextState]: previousState[nextState] + 1
}));
};
AppState.addEventListener('change', handleChange); AppState.addEventListener('change', handleChange);
return () => { return () => {
AppState.removeEventListener('change', handleChange); AppState.removeEventListener('change', handleChange);
}; };
}, [handleChange]); }, []);
return ( return (
<View> <View>
+1 -1
View File
@@ -70,6 +70,6 @@ export default function usePlatformMethods(
} }
}; };
}, },
[classList, hostRef, ref, style] [classList, hostRef, style]
); );
} }
+5
View File
@@ -7006,6 +7006,11 @@ eslint-plugin-promise@^4.2.1:
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz#845fd8b2260ad8f82564c1222fce44ad71d9418a" resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-4.2.1.tgz#845fd8b2260ad8f82564c1222fce44ad71d9418a"
integrity sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw== integrity sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==
eslint-plugin-react-hooks@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-2.3.0.tgz#53e073961f1f5ccf8dd19558036c1fac8c29d99a"
integrity sha512-gLKCa52G4ee7uXzdLiorca7JIQZPPXRAQDXV83J4bUEeUuc5pIEyZYAZ45Xnxe5IuupxEqHS+hUhSLIimK1EMw==
eslint-plugin-react@^7.16.0: eslint-plugin-react@^7.16.0:
version "7.16.0" version "7.16.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.16.0.tgz#9928e4f3e2122ed3ba6a5b56d0303ba3e41d8c09" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.16.0.tgz#9928e4f3e2122ed3ba6a5b56d0303ba3e41d8c09"