From 14d8c47cb4ed5502dac57262538987edb23d6a06 Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Mon, 27 Nov 2017 12:26:09 +0100 Subject: [PATCH] Upgrade tools and add more rules --- .eslintrc.js | 156 ++++++++++++++++++++++++++++----------------------- package.json | 8 +-- yarn.lock | 99 +++++++++++++++++++++----------- 3 files changed, 155 insertions(+), 108 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2692f24c76..4ece48c8fd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,82 +1,96 @@ module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true + env: { + browser: true, + es6: true, + node: true, }, - "parser": "babel-eslint", - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:flowtype/recommended", - "prettier", - "prettier/flowtype", - "prettier/react" + parser: 'babel-eslint', + extends: [ + 'eslint:recommended', + 'plugin:react/recommended', + 'plugin:flowtype/recommended', + 'prettier', + 'prettier/flowtype', + 'prettier/react', ], - "parserOptions": { - "ecmaVersion": "2017", - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "jsx": true + parserOptions: { + ecmaVersion: '2017', + ecmaFeatures: { + experimentalObjectRestSpread: true, + jsx: true, }, - "sourceType": "module" + sourceType: 'module', }, - "plugins": [ - "react", - "flowtype", - "import", - "prettier" - ], - "rules": { - // ES6 Import rules: - "import/no-duplicates": "error", - "import/no-unresolved": "error", - "import/named": "error", - "prettier/prettier": ["error", { singleQuote: true, trailingComma: "es5" }], + plugins: ['react', 'flowtype', 'import', 'prettier'], + rules: { + // Plugin rules: + 'import/no-duplicates': 'error', + 'import/no-unresolved': 'error', + 'import/named': 'error', + 'prettier/prettier': ['error', { singleQuote: true, trailingComma: 'es5' }], + 'react/no-access-state-in-setstate': 'error', + 'react/no-danger': 'error', + 'react/no-did-mount-set-state': 'error', + 'react/no-did-update-set-state': 'error', + 'react/no-will-update-set-state': 'error', + 'react/no-redundant-should-component-update': 'error', + 'react/no-typos': 'error', + // `no-unused-prop-types` is buggy when we use destructuring parameters in + // functions as it misunderstands them as functional components. + // See https://github.com/yannickcr/eslint-plugin-react/issues/1561 + 'react/no-unused-prop-types': 'warn', + 'react/no-unused-state': 'error', + 'react/prefer-stateless-function': 'error', + 'react/prefer-stateless-function': [ + 'error', + { ignorePureComponents: true }, + ], + 'react/jsx-no-bind': 'error', // overriding recommended rules - "no-constant-condition": ["error", { checkLoops: false }], - "no-console": [ "error", { allow: ["log", "warn", "error"] } ], - "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }], + 'no-constant-condition': ['error', { checkLoops: false }], + 'no-console': ['error', { allow: ['log', 'warn', 'error'] }], + 'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], // possible errors - "array-callback-return": "error", - "consistent-return": "error", - "default-case": "error", - "dot-notation": "error", - "eqeqeq": "error", - "for-direction": "error", - "no-alert": "error", - "no-caller": "error", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-implied-eval": "error", - "no-invalid-this": "error", - "no-return-await": "error", - "no-self-compare": "error", - "no-throw-literal": "error", - "no-unmodified-loop-condition": "error", - "no-unused-expressions": "error", - "no-useless-call": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "error", - "no-useless-constructor": "error", - "no-useless-rename": "error", - "no-useless-return": "error", - "no-var": "error", - "no-void": "error", - "no-with": "error", - "prefer-const": "error", - "prefer-promise-reject-errors": "error", - "prefer-rest-params": "error", - "prefer-spread": "error", + 'array-callback-return': 'error', + 'consistent-return': 'error', + 'default-case': 'error', + 'dot-notation': 'error', + eqeqeq: 'error', + 'for-direction': 'error', + 'no-alert': 'error', + 'no-caller': 'error', + 'no-eval': 'error', + 'no-extend-native': 'error', + 'no-extra-bind': 'error', + 'no-extra-label': 'error', + 'no-implied-eval': 'error', + 'no-invalid-this': 'error', + 'no-return-await': 'error', + 'no-self-compare': 'error', + 'no-throw-literal': 'error', + 'no-unmodified-loop-condition': 'error', + 'no-unused-expressions': 'error', + 'no-useless-call': 'error', + 'no-useless-computed-key': 'error', + 'no-useless-concat': 'error', + 'no-useless-constructor': 'error', + 'no-useless-rename': 'error', + 'no-useless-return': 'error', + 'no-var': 'error', + 'no-void': 'error', + 'no-with': 'error', + 'prefer-const': 'error', + 'prefer-promise-reject-errors': 'error', + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + }, + settings: { + react: { + pragma: 'React', + version: '15.0', + flowVersion: '0.54.1', + }, }, - "settings": { - "react": { - "pragma": "React", - "version": "15.0" - } - } }; diff --git a/package.json b/package.json index 0516e9a863..4c093368f7 100644 --- a/package.json +++ b/package.json @@ -107,12 +107,12 @@ "babel-preset-react-hmre": "^1.1.1", "css-loader": "^0.28.7", "devtools-license-check": "^0.5.0", - "eslint": "^4.6.1", + "eslint": "^4.12.0", "eslint-config-prettier": "^2.4.0", - "eslint-plugin-flowtype": "^2.35.1", - "eslint-plugin-import": "^2.7.0", + "eslint-plugin-flowtype": "^2.39.1", + "eslint-plugin-import": "^2.8.0", "eslint-plugin-prettier": "^2.2.0", - "eslint-plugin-react": "^7.4.0", + "eslint-plugin-react": "^7.5.1", "express": "^4.15.4", "fake-indexeddb": "^2.0.3", "file-loader": "^0.11.2", diff --git a/yarn.lock b/yarn.lock index 7cf9e93335..c89ad473d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54,9 +54,9 @@ acorn@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.0.3.tgz#c460df08491463f028ccb82eab3730bf01087b3d" -acorn@^5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" +acorn@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" agent-base@2: version "2.1.1" @@ -80,7 +80,7 @@ ajv@^4.7.0, ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.0.0, ajv@^5.1.5, ajv@^5.2.0: +ajv@^5.0.0, ajv@^5.1.5: version "5.2.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.2.tgz#47c68d69e86f5d953103b0074a9430dc63da5e39" dependencies: @@ -89,6 +89,15 @@ ajv@^5.0.0, ajv@^5.1.5, ajv@^5.2.0: json-schema-traverse "^0.3.0" json-stable-stringify "^1.0.1" +ajv@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.0.tgz#eb2840746e9dc48bd5e063a36e3fd400c5eab5a9" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -1873,6 +1882,12 @@ debug@*, debug@2, debug@2.6.8, debug@^2.2.0, debug@^2.6.3, debug@^2.6.6, debug@^ dependencies: ms "2.0.0" +debug@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + debug@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" @@ -2050,6 +2065,12 @@ doctrine@^2.0.0: esutils "^2.0.2" isarray "^1.0.0" +doctrine@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.2.tgz#68f96ce8efc56cc42651f1faadb4f175273b0075" + dependencies: + esutils "^2.0.2" + dom-converter@~0.1: version "0.1.4" resolved "https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.1.4.tgz#a45ef5727b890c9bffe6d7c876e7b19cb0e17f3b" @@ -2333,15 +2354,15 @@ eslint-module-utils@^2.1.1: debug "^2.6.8" pkg-dir "^1.0.0" -eslint-plugin-flowtype@^2.35.1: - version "2.35.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.35.1.tgz#9ad98181b467a3645fbd2a8d430393cc17a4ea63" +eslint-plugin-flowtype@^2.39.1: + version "2.39.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.39.1.tgz#b5624622a0388bcd969f4351131232dcb9649cd5" dependencies: lodash "^4.15.0" -eslint-plugin-import@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.7.0.tgz#21de33380b9efb55f5ef6d2e210ec0e07e7fa69f" +eslint-plugin-import@^2.8.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz#fa1b6ef31fcb3c501c09859c1b86f1fc5b986894" dependencies: builtin-modules "^1.1.1" contains-path "^0.1.0" @@ -2361,14 +2382,14 @@ eslint-plugin-prettier@^2.2.0: fast-diff "^1.1.1" jest-docblock "^20.0.1" -eslint-plugin-react@^7.4.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.4.0.tgz#300a95861b9729c087d362dd64abcc351a74364a" +eslint-plugin-react@^7.5.1: + version "7.5.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.5.1.tgz#52e56e8d80c810de158859ef07b880d2f56ee30b" dependencies: doctrine "^2.0.0" has "^1.0.1" jsx-ast-utils "^2.0.0" - prop-types "^15.5.10" + prop-types "^15.6.0" eslint-scope@^3.7.1: version "3.7.1" @@ -2377,32 +2398,32 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint@^4.6.1: - version "4.6.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.6.1.tgz#ddc7fc7fd70bf93205b0b3449bb16a1e9e7d4950" +eslint@^4.12.0: + version "4.12.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.12.0.tgz#a7ce78eba8cc8f2443acfbbc870cc31a65135884" dependencies: - ajv "^5.2.0" + ajv "^5.3.0" babel-code-frame "^6.22.0" chalk "^2.1.0" concat-stream "^1.6.0" cross-spawn "^5.1.0" - debug "^2.6.8" - doctrine "^2.0.0" + debug "^3.0.1" + doctrine "^2.0.2" eslint-scope "^3.7.1" - espree "^3.5.0" + espree "^3.5.2" esquery "^1.0.0" estraverse "^4.2.0" esutils "^2.0.2" file-entry-cache "^2.0.0" functional-red-black-tree "^1.0.1" glob "^7.1.2" - globals "^9.17.0" + globals "^11.0.1" ignore "^3.3.3" imurmurhash "^0.1.4" inquirer "^3.0.6" is-resolvable "^1.0.0" js-yaml "^3.9.1" - json-stable-stringify "^1.0.1" + json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" lodash "^4.17.4" minimatch "^3.0.2" @@ -2410,7 +2431,7 @@ eslint@^4.6.1: natural-compare "^1.4.0" optionator "^0.8.2" path-is-inside "^1.0.2" - pluralize "^4.0.0" + pluralize "^7.0.0" progress "^2.0.0" require-uncached "^1.0.3" semver "^5.3.0" @@ -2419,11 +2440,11 @@ eslint@^4.6.1: table "^4.0.1" text-table "~0.2.0" -espree@^3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.0.tgz#98358625bdd055861ea27e2867ea729faf463d8d" +espree@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" dependencies: - acorn "^5.1.1" + acorn "^5.2.1" acorn-jsx "^3.0.0" esprima@^2.6.0, esprima@^2.7.1: @@ -2625,6 +2646,10 @@ fast-diff@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.1.tgz#0aea0e4e605b6a2189f0e936d4b7fbaf1b7cfd9b" +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + fast-levenshtein@~2.0.4: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" @@ -3068,7 +3093,11 @@ global@^4.3.0: min-document "^2.19.0" process "~0.5.1" -globals@^9.17.0, globals@^9.18.0: +globals@^11.0.1: + version "11.0.1" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.0.1.tgz#12a87bb010e5154396acc535e1e43fc753b0e5e8" + +globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -4107,6 +4136,10 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" @@ -5548,9 +5581,9 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" -pluralize@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762" +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" portfinder@^1.0.13, portfinder@^1.0.9: version "1.0.13" @@ -5873,7 +5906,7 @@ prop-types@^15.5.10, prop-types@^15.5.4, prop-types@~15.5.7: fbjs "^0.8.9" loose-envify "^1.3.1" -prop-types@^15.5.7, prop-types@^15.5.8: +prop-types@^15.5.7, prop-types@^15.5.8, prop-types@^15.6.0: version "15.6.0" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856" dependencies: