From ebfe45ea9f3dbe96848a88ea2590ad856a7cf066 Mon Sep 17 00:00:00 2001 From: Yoan VALLET <ext.sopra.yvallet@grandlyon.com> Date: Tue, 1 Dec 2020 22:07:59 +0100 Subject: [PATCH] feat: add eslint-plugin-react-hooks --- .eslintrc.js | 27 ++++++++++++++------------- package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a0392dcbd..ef6a7944b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,27 +1,28 @@ module.exports = { - parser: '@typescript-eslint/parser', // Specifies the ESLint parser + parser: '@typescript-eslint/parser', // Specifies the ESLint parser extends: [ - 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react - 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin - 'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier - 'plugin:prettier/recommended' // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. + 'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react + 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin + 'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier + 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. + 'plugin:react-hooks/recommended', ], parserOptions: { - ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features - sourceType: 'module', // Allows for the use of imports + ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features + sourceType: 'module', // Allows for the use of imports ecmaFeatures: { - jsx: true, // Allows for the parsing of JSX + jsx: true, // Allows for the parsing of JSX }, }, rules: { // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-var-requires": "warn", - "react/prop-types": "warn" + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-var-requires': 'warn', + 'react/prop-types': 'warn', }, settings: { react: { - version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use + version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use }, }, -}; +} diff --git a/package.json b/package.json index dd66e0e95..c4d8f3feb 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "eslint-config-prettier": "^6.7.0", "eslint-plugin-prettier": "^3.1.1", "eslint-plugin-react": "7.14.2", + "eslint-plugin-react-hooks": "^4.2.0", "git-directory-deploy": "1.5.1", "husky": ">=1", "jest-canvas-mock": "^2.3.0", diff --git a/yarn.lock b/yarn.lock index 5eecff53f..467e6f513 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5685,6 +5685,11 @@ eslint-plugin-react-hooks@4.0.4: resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.0.4.tgz#aed33b4254a41b045818cacb047b81e6df27fa58" integrity sha512-equAdEIsUETLFNCmmCkiCGq6rkSK5MoJhXFPFYeUebcjKgBmWWcgVOqZyQC8Bv1BwVCnTq9tBxgJFgAJTWoJtA== +eslint-plugin-react-hooks@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556" + integrity sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ== + eslint-plugin-react@7.12.4: version "7.12.4" resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.12.4.tgz#b1ecf26479d61aee650da612e425c53a99f48c8c" -- GitLab