From 7ecf55fc9d8b171601ac9e9fbc2a2b7354f0e13a Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Fri, 8 Feb 2019 07:04:29 -0800 Subject: [PATCH] Enforce rules-of-hooks via eslint Summary: allow-large-files Enforce rules-of-hooks in React Native via the eslint-plugin-react-hooks plugin. See https://reactjs.org/docs/hooks-rules.html Reviewed By: rickhanlonii Differential Revision: D13998695 fbshipit-source-id: 48f1cde18c7112ce91d5087461875bcd0b50bf4f --- .eslintrc | 5 +++++ package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/.eslintrc b/.eslintrc index 9c8a0f9d8..1d8cf81a9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,6 +12,7 @@ "flowtype", "prettier", "react", + "react-hooks", "react-native", "jest", ], @@ -240,6 +241,10 @@ "react/self-closing-comp": 1, "react/wrap-multilines": 0, + // React-Hooks Plugin + // The following rules are made available via `eslint-plugin-react-hooks` + "react-hooks/rules-of-hooks": "error", + // React-Native Plugin // The following rules are made available via `eslint-plugin-react-native` diff --git a/package.json b/package.json index 265cc584e..f1d100cb4 100644 --- a/package.json +++ b/package.json @@ -223,6 +223,7 @@ "eslint-plugin-jest": "21.8.0", "eslint-plugin-prettier": "2.6.0", "eslint-plugin-react": "7.8.2", + "eslint-plugin-react-hooks": "^1.0.1", "eslint-plugin-react-native": "3.5.0", "flow-bin": "^0.92.0", "jest": "24.0.0-alpha.6", diff --git a/yarn.lock b/yarn.lock index c6ae89636..a0f4ae3d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2627,6 +2627,11 @@ eslint-plugin-prettier@2.6.0: fast-diff "^1.1.1" jest-docblock "^21.0.0" +eslint-plugin-react-hooks@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.0.1.tgz#76b6fb4edafab02eab0090078977687157605dd9" + integrity sha512-yNhvY7EFBp0mq0Bt8BHoS57GwJ4e1qSYdvDFSfPnjmiSmyGUfQFQGcQs4K0JQFDGopWkURWq58psbUJIhWZ2Kg== + eslint-plugin-react-native-globals@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/eslint-plugin-react-native-globals/-/eslint-plugin-react-native-globals-0.1.2.tgz#ee1348bc2ceb912303ce6bdbd22e2f045ea86ea2"