From 59e4c33f713a96c1a57b27ca67da7f00b9c32d8a Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 24 Aug 2019 21:27:54 +0200 Subject: [PATCH] Add React-specific configuration separately --- index.js | 16 +--------- react.js | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 react.js diff --git a/index.js b/index.js index 184121c..0a3ce8b 100644 --- a/index.js +++ b/index.js @@ -8,15 +8,8 @@ module.exports = { "node": true }, "parserOptions": { - "ecmaVersion": 2019, - "ecmaFeatures": { - "jsx": true - } + "ecmaVersion": 2019 }, - "plugins": [ - "react", - "react-hooks" - ], "rules": { /* Things that should effectively be syntax errors. */ "indent": [ "error", "tab", { @@ -66,13 +59,6 @@ module.exports = { "no-loop-func": [ "error" ], "no-implicit-globals": [ "error" ], "strict": [ "error", "global" ], - /* Make JSX not cause 'unused variable' errors. */ - "react/react-in-jsx-scope": [ "error" ], - "react/jsx-uses-react": [ "error" ], - "react/jsx-uses-vars": [ "error" ], - /* Hooks-specific rules, as recommended by https://reactjs.org/docs/hooks-rules.html */ - "react-hooks/rules-of-hooks": "error", - "react-hooks/exhaustive-deps": "warn", /* Development code that should be removed before deployment. */ "no-console": [ "warn" ], "no-constant-condition": [ "warn" ], diff --git a/react.js b/react.js new file mode 100644 index 0000000..1ef2e78 --- /dev/null +++ b/react.js @@ -0,0 +1,90 @@ +"use strict"; + +/* FIXME: Remove duplication */ + +module.exports = { + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaVersion": 2019, + "ecmaFeatures": { + "jsx": true + } + }, + "plugins": [ + "react", + "react-hooks" + ], + "rules": { + /* Things that should effectively be syntax errors. */ + "indent": [ "error", "tab", { + SwitchCase: 1 + }], + "linebreak-style": [ "error", "unix" ], + "semi": [ "error", "always" ], + /* Things that are always mistakes. */ + "getter-return": [ "error" ], + "no-compare-neg-zero": [ "error" ], + "no-dupe-args": [ "error" ], + "no-dupe-keys": [ "error" ], + "no-duplicate-case": [ "error" ], + "no-empty": [ "error" ], + "no-empty-character-class": [ "error" ], + "no-ex-assign": [ "error" ], + "no-extra-semi": [ "error" ], + "no-func-assign": [ "error" ], + "no-invalid-regexp": [ "error" ], + "no-irregular-whitespace": [ "error" ], + "no-obj-calls": [ "error" ], + "no-sparse-arrays": [ "error" ], + "no-undef": [ "error" ], + "no-unreachable": [ "error" ], + "no-unsafe-finally": [ "error" ], + "use-isnan": [ "error" ], + "valid-typeof": [ "error" ], + "curly": [ "error" ], + "no-caller": [ "error" ], + "no-fallthrough": [ "error" ], + "no-extra-bind": [ "error" ], + "no-extra-label": [ "error" ], + "array-callback-return": [ "error" ], + "prefer-promise-reject-errors": [ "error" ], + "no-with": [ "error" ], + "no-useless-concat": [ "error" ], + "no-unused-labels": [ "error" ], + "no-unused-expressions": [ "error" ], + "no-unused-vars": [ "error" , { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_" + } ], + "no-return-assign": [ "error" ], + "no-self-assign": [ "error" ], + "no-new-wrappers": [ "error" ], + "no-redeclare": [ "error" ], + "no-loop-func": [ "error" ], + "no-implicit-globals": [ "error" ], + "strict": [ "error", "global" ], + /* Make JSX not cause 'unused variable' errors. */ + "react/react-in-jsx-scope": [ "error" ], + "react/jsx-uses-react": [ "error" ], + "react/jsx-uses-vars": [ "error" ], + /* Hooks-specific rules, as recommended by https://reactjs.org/docs/hooks-rules.html */ + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "warn", + /* Development code that should be removed before deployment. */ + "no-console": [ "warn" ], + "no-constant-condition": [ "warn" ], + "no-debugger": [ "warn" ], + "no-alert": [ "warn" ], + "no-warning-comments": [ "warn", { + terms: ["fixme"] + }], + /* Common mistakes that can *occasionally* be intentional. */ + "no-template-curly-in-string": [ "warn" ], + "no-unsafe-negation": [ "warn" ], + } +};