diff --git a/.travis.yml b/.travis.yml index c070fb0..0b1218f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,9 @@ cache: npm notifications: email: false node_js: + - 10.12 - 10 + - 12.0 - 12 - 14 - node diff --git a/best-practices.js b/best-practices.js index 9b2a3e6..8e644e3 100644 --- a/best-practices.js +++ b/best-practices.js @@ -1,5 +1,6 @@ module.exports = { extends: './non-rules-config.js', + plugins: ['node'], rules: { 'accessor-pairs': 'error', 'array-callback-return': 'error', @@ -8,6 +9,7 @@ module.exports = { complexity: ['error', 14], 'consistent-return': 'error', 'default-case': 'error', + 'default-case-last': 'error', 'default-param-last': 'off', 'dot-notation': 'error', eqeqeq: 'off', @@ -98,16 +100,15 @@ module.exports = { ], // CommonJS - 'callback-return': 'off', // see known limitations: http://eslint.org/docs/rules/callback-return it's just annoying... - 'global-require': 'warn', // sometimes this is ok. We shouldn't break a build - 'handle-callback-err': 'error', - 'no-buffer-constructor': 'error', - 'no-mixed-requires': ['error', {grouping: true, allowCall: false}], - 'no-new-require': 'error', - 'no-path-concat': 'error', - 'no-process-env': 'off', - 'no-process-exit': 'error', - 'no-restricted-modules': 'off', - 'no-sync': 'off', + 'node/callback-return': 'off', // see known limitations: http://eslint.org/docs/rules/callback-return it's just annoying... + 'node/global-require': 'warn', // sometimes this is ok. We shouldn't break a build + 'node/handle-callback-err': 'error', + 'node/no-mixed-requires': ['error', {grouping: true, allowCall: false}], + 'node/no-new-require': 'error', + 'node/no-path-concat': 'error', + 'node/no-process-env': 'off', + 'node/no-process-exit': 'error', + 'node/no-restricted-modules': 'off', + 'node/no-sync': 'off', }, } diff --git a/deprecated-rules.js b/deprecated-rules.js index 66985bb..543af14 100644 --- a/deprecated-rules.js +++ b/deprecated-rules.js @@ -1,13 +1,30 @@ +const {mapDeprecatedRules} = require('./utils') + module.exports = { extends: './non-rules-config.js', - rules: { - 'lines-around-directive': 'off', - 'newline-after-var': 'off', - 'newline-before-return': 'off', - 'no-catch-shadow': 'off', - 'no-native-reassign': 'off', - 'no-negated-in-lhs': 'off', - 'require-jsdoc': 'off', - 'valid-jsdoc': 'off', - }, + rules: mapDeprecatedRules([ + 'callback-return', + 'global-require', + 'handle-callback-err', + 'id-blacklist', + 'indent-legacy', + 'lines-around-directive', + 'newline-after-var', + 'newline-before-return', + 'no-buffer-constructor', + 'no-catch-shadow', + 'no-mixed-requires', + 'no-native-reassign', + 'no-negated-in-lhs', + 'no-new-require', + 'no-path-concat', + 'no-process-env', + 'no-process-exit', + 'no-restricted-modules', + 'no-spaced-func', + 'no-sync', + 'prefer-reflect', + 'require-jsdoc', + 'valid-jsdoc', + ]), } diff --git a/es6/best-practices.js b/es6/best-practices.js index 1cbf485..ef304fc 100644 --- a/es6/best-practices.js +++ b/es6/best-practices.js @@ -3,6 +3,7 @@ module.exports = { rules: { 'no-class-assign': 'error', 'no-duplicate-imports': 'error', + 'no-restricted-exports': 'off', // not applicable for a config preset (should be configured only in projects) 'no-restricted-imports': 'off', // not applicable for a config preset (should be configured only in projects) 'no-useless-computed-key': 'error', 'no-useless-constructor': 'error', diff --git a/es6/deprecated-rules.js b/es6/deprecated-rules.js index 5e67c23..21e13db 100644 --- a/es6/deprecated-rules.js +++ b/es6/deprecated-rules.js @@ -1,13 +1,14 @@ +const {mapDeprecatedRules} = require('../utils') + module.exports = { extends: './non-rules-config.js', - rules: { - 'prefer-reflect': 'off', - 'babel/array-bracket-spacing': 'off', - 'babel/arrow-parens': 'off', - 'babel/flow-object-type': 'off', - 'babel/func-params-comma-dangle': 'off', - 'babel/generator-star-spacing': 'off', - 'babel/no-await-in-loop': 'off', - 'babel/object-shorthand': 'off', - }, + rules: mapDeprecatedRules([ + 'babel/array-bracket-spacing', + 'babel/arrow-parens', + 'babel/flow-object-type', + 'babel/func-params-comma-dangle', + 'babel/generator-star-spacing', + 'babel/no-await-in-loop', + 'babel/object-shorthand', + ]), } diff --git a/import/deprecated-rules.js b/import/deprecated-rules.js index 810f25b..5692de4 100644 --- a/import/deprecated-rules.js +++ b/import/deprecated-rules.js @@ -1,6 +1,6 @@ +const {mapDeprecatedRules} = require('../utils') + module.exports = { extends: './non-rules-config.js', - rules: { - 'import/imports-first': 'off', - }, + rules: mapDeprecatedRules(['import/imports-first']), } diff --git a/jest.js b/jest.js index da43652..775563b 100644 --- a/jest.js +++ b/jest.js @@ -33,6 +33,7 @@ module.exports = { ].filter(Boolean), rules: { 'jest/consistent-test-it': 'off', + 'jest/no-done-callback': 'error', 'jest/expect-expect': 'off', 'jest/lowercase-name': 'off', 'jest/no-alias-methods': 'off', diff --git a/package.json b/package.json index 2ffb97e..a38e0d2 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,10 @@ "eslint-import-resolver-webpack": "^0.12.2", "eslint-plugin-babel": "^5.3.1", "eslint-plugin-import": "^2.22.0", - "eslint-plugin-jest": "^23.20.0", + "eslint-plugin-jest": "^24.0.2", "eslint-plugin-jest-dom": "^3.2.3", "eslint-plugin-jsx-a11y": "^6.3.1", + "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.20.6", "eslint-plugin-react-hooks": "^4.1.2", "eslint-plugin-testing-library": "^3.9.0", @@ -49,12 +50,12 @@ "webpack": "^4.44.2" }, "peerDependencies": { - "eslint": ">=6" + "eslint": "^7.0.0" }, "devDependencies": { "@testing-library/dom": "^7.24.2", "@testing-library/jest-dom": "^5.11.4", - "eslint": "^6.8.0", + "eslint": "^7.9.0", "eslint-find-rules": "^3.6.1", "kcd-scripts": "^6.3.0", "npm-run-all": "^4.1.5", @@ -69,7 +70,7 @@ "dist" ], "engines": { - "node": ">=10", + "node": "^10.12.0 || >=12.0.0", "npm": ">=6", "yarn": ">=1" } diff --git a/possible-errors.js b/possible-errors.js index a290a14..a3562d4 100644 --- a/possible-errors.js +++ b/possible-errors.js @@ -24,16 +24,20 @@ module.exports = { 'no-inner-declarations': 'error', 'no-invalid-regexp': 'error', 'no-irregular-whitespace': 'error', + 'no-loss-of-precision': 'error', 'no-misleading-character-class': 'off', 'no-obj-calls': 'error', + 'no-promise-executor-return': 'error', 'no-prototype-builtins': 'off', 'no-regex-spaces': 'error', 'no-setter-return': 'error', 'no-sparse-arrays': 'error', 'no-template-curly-in-string': 'error', 'no-unreachable': 'error', + 'no-unreachable-loop': 'error', 'no-unsafe-finally': 'error', 'no-unsafe-negation': 'error', + 'no-useless-backreference': 'error', 'require-atomic-updates': 'off', 'use-isnan': 'error', 'valid-typeof': 'error', diff --git a/stylistic.js b/stylistic.js index 4b0778a..e0486bf 100644 --- a/stylistic.js +++ b/stylistic.js @@ -8,7 +8,7 @@ module.exports = { 'func-name-matching': 'error', 'func-names': 'error', 'func-style': 'off', - 'id-blacklist': 'error', + 'id-denylist': 'error', 'id-length': 'off', // when using short composable functions, using single-letter variables is fine 'id-match': [ 'error', diff --git a/utils.js b/utils.js new file mode 100644 index 0000000..ec90e72 --- /dev/null +++ b/utils.js @@ -0,0 +1,10 @@ +const mapDeprecatedRules = deprecatedRules => + deprecatedRules.reduce( + (allRules, rule) => ({ + ...allRules, + [rule]: 'off', + }), + {}, + ) + +module.exports = {mapDeprecatedRules}