From b7f794ffa61c288ec132b57ede055f49c503c3a7 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 14 Jul 2019 17:59:12 +0200 Subject: [PATCH] Added ESLint for error detection --- .eslintrc.js | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 ++ 2 files changed, 80 insertions(+) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..fe21cf8 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,78 @@ +module.exports = { + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "parserOptions": { + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + } + }, + "plugins": [ + "react" + ], + "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: "^_" } ], + "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/jsx-uses-react": ["error"], + "react/jsx-uses-vars": ["error"], + /* 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" ], + } +}; diff --git a/package.json b/package.json index e0a8fbe..15ff907 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,8 @@ "webpack": "^4.27.1" }, "devDependencies": { + "eslint": "^6.0.1", + "eslint-plugin-react": "^7.14.2", "gulp-watch": "^5.0.1", "livereactload": "^4.0.0-beta.2", "mocha": "^6.1.4"