Skip to content

Commit

Permalink
[eslint config] [base] [breaking] drop eslint < 7, add eslint 8
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 9, 2021
1 parent eac8cc6 commit f3d3a07
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 145 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
versionsAsRoot: true
type: 'majors'
preset: '^10 || ^12 || ^14 || ^16 || >= 17'
preset: '^12 || ^14 || ^16 || >= 17'

base:
needs: [matrix]
Expand All @@ -25,11 +25,14 @@ jobs:
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 8
- 7
- 6
- 5
package:
- eslint-config-airbnb-base
exclude:
- node-version: 10
eslint: 8
package: eslint-config-airbnb-base

defaults:
run:
Expand Down Expand Up @@ -60,15 +63,15 @@ jobs:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 7
- 6
- 5
# - 6
# - 5
package:
- eslint-config-airbnb
react-hooks:
- ''
- 3
- 2.3
- 1.7
# - 3 # TODO: re-enable these once the react config uses eslint 8
# - 2.3
# - 1.7

defaults:
run:
Expand Down Expand Up @@ -97,9 +100,8 @@ jobs:
fail-fast: false
matrix:
eslint:
- 8
- 7
- 6
- 5
package:
- eslint-config-airbnb-base

Expand Down Expand Up @@ -130,15 +132,15 @@ jobs:
matrix:
eslint:
- 7
- 6
- 5
# - 6
# - 5
package:
- eslint-config-airbnb
react-hooks:
- ''
- 3
- 2.3
- 1.7
# - 3 # TODO: re-enable these once the react config uses eslint 8
# - 2.3
# - 1.7

defaults:
run:
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-find-rules": "^3.6.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.0.0",
"eslint-plugin-import": "^2.25.2",
"in-publish": "^2.0.1",
"safe-publish-latest": "^1.1.4",
"safe-publish-latest": "^2.0.0",
"tape": "^5.3.1"
},
"peerDependencies": {
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.25.2"
},
"engines": {
"node": ">= 6"
"node": "^10.12.0 || >=12.0.0"
},
"dependencies": {
"confusing-browser-globals": "^1.0.10",
Expand Down
20 changes: 8 additions & 12 deletions packages/eslint-config-airbnb-base/rules/best-practices.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ module.exports = {

// Enforce default clauses in switch statements to be last
// https://eslint.org/docs/rules/default-case-last
// TODO: enable, semver-minor, when eslint v7 is required (which is a major)
'default-case-last': 'off',
'default-case-last': 'error',

// https://eslint.org/docs/rules/default-param-last
// TODO: enable, semver-minor, when eslint v6.4 is required (which is a major)
'default-param-last': 'off',
'default-param-last': 'error',

// encourages use of dot notation whenever possible
// https://eslint.org/docs/rules/dot-notation
Expand All @@ -57,8 +55,7 @@ module.exports = {

// Require grouped accessor pairs in object literals and classes
// https://eslint.org/docs/rules/grouped-accessor-pairs
// TODO: enable in next major, altho the guide forbids getters/setters anyways
'grouped-accessor-pairs': 'off',
'grouped-accessor-pairs': 'error',

// make sure for-in loops have an if statement
// https://eslint.org/docs/rules/guard-for-in
Expand All @@ -82,8 +79,7 @@ module.exports = {

// Disallow returning value in constructor
// https://eslint.org/docs/rules/no-constructor-return
// TODO: enable, semver-major
'no-constructor-return': 'off',
'no-constructor-return': 'error',

// disallow division operators explicitly at beginning of regular expression
// https://eslint.org/docs/rules/no-div-regex
Expand Down Expand Up @@ -213,8 +209,7 @@ module.exports = {

// Disallow \8 and \9 escape sequences in string literals
// https://eslint.org/docs/rules/no-nonoctal-decimal-escape
// todo: semver-major: enable when v7.14 is required
'no-nonoctal-decimal-escape': 'off',
'no-nonoctal-decimal-escape': 'error',

// disallow use of (old style) octal literals
// https://eslint.org/docs/rules/no-octal
Expand Down Expand Up @@ -382,8 +377,9 @@ module.exports = {
'prefer-named-capture-group': 'off',

// https://eslint.org/docs/rules/prefer-regex-literals
// TODO; enable, semver-minor, once eslint v6.4 is required (which is a major)
'prefer-regex-literals': 'off',
'prefer-regex-literals': ['error', {
disallowRedundantWrapping: true,
}],

// require use of the second argument for parseInt()
// https://eslint.org/docs/rules/radix
Expand Down
29 changes: 13 additions & 16 deletions packages/eslint-config-airbnb-base/rules/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ module.exports = {

// Disallow duplicate conditions in if-else-if chains
// https://eslint.org/docs/rules/no-dupe-else-if
// TODO: enable, semver-major
'no-dupe-else-if': 'off',
'no-dupe-else-if': 'error',

// disallow duplicate keys when creating object literals
'no-dupe-keys': 'error',
Expand Down Expand Up @@ -79,8 +78,7 @@ module.exports = {
'no-func-assign': 'error',

// https://eslint.org/docs/rules/no-import-assign
// TODO: enable, semver-minor, once eslint v6.4 is required (which is a major)
'no-import-assign': 'off',
'no-import-assign': 'error',

// disallow function or variable declarations in nested blocks
'no-inner-declarations': 'error',
Expand All @@ -93,8 +91,7 @@ module.exports = {

// Disallow Number Literals That Lose Precision
// https://eslint.org/docs/rules/no-loss-of-precision
// TODO: enable, semver-minor, once eslint v7.1 is required (which is major)
'no-loss-of-precision': 'off',
'no-loss-of-precision': 'error',

// Disallow characters which are made with multiple code points in character class syntax
// https://eslint.org/docs/rules/no-misleading-character-class
Expand All @@ -105,8 +102,7 @@ module.exports = {

// Disallow returning values from Promise executor functions
// https://eslint.org/docs/rules/no-promise-executor-return
// TODO: enable, semver-minor, once eslint v7.3 is required (which is major)
'no-promise-executor-return': 'off',
'no-promise-executor-return': 'error',

// disallow use of Object.prototypes builtins directly
// https://eslint.org/docs/rules/no-prototype-builtins
Expand All @@ -117,8 +113,7 @@ module.exports = {

// Disallow returning values from setters
// https://eslint.org/docs/rules/no-setter-return
// TODO: enable, semver-major (altho the guide forbids getters/setters already)
'no-setter-return': 'off',
'no-setter-return': 'error',

// disallow sparse arrays
'no-sparse-arrays': 'error',
Expand All @@ -136,8 +131,7 @@ module.exports = {

// Disallow loops with a body that allows only one iteration
// https://eslint.org/docs/rules/no-unreachable-loop
// TODO: enable, semver-minor, once eslint v7.3 is required (which is major)
'no-unreachable-loop': ['off', {
'no-unreachable-loop': ['error', {
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
}],

Expand All @@ -151,13 +145,16 @@ module.exports = {

// disallow use of optional chaining in contexts where the undefined value is not allowed
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
// TODO: enable, semver-minor, once eslint v7.15 is required (which is major)
'no-unsafe-optional-chaining': ['off', { disallowArithmeticOperators: true }],
'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],

// Disallow Unused Private Class Members
// https://eslint.org/docs/rules/no-unused-private-class-members
// TODO: enable once eslint 7 is dropped (which is semver-major)
'no-unused-private-class-members': 'off',

// Disallow useless backreferences in regular expressions
// https://eslint.org/docs/rules/no-useless-backreference
// TODO: enable, semver-minor, once eslint v7 is required (which is major)
'no-useless-backreference': 'off',
'no-useless-backreference': 'error',

// disallow negation of the left operand of an in expression
// deprecated in favor of no-unsafe-negation
Expand Down
5 changes: 2 additions & 3 deletions packages/eslint-config-airbnb-base/rules/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ module.exports = {

// Disallow specified names in exports
// https://eslint.org/docs/rules/no-restricted-exports
// TODO enable, semver-minor, once eslint v7 is required (which is major)
'no-restricted-exports': ['off', {
'no-restricted-exports': ['error', {
restrictedNamedExports: [
'default', // use `export default` to provide a default export
'then', // this will cause tons of confusion when your module is dynamically `import()`ed
'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
],
}],

Expand Down
8 changes: 3 additions & 5 deletions packages/eslint-config-airbnb-base/rules/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module.exports = {

// Reports modules without any exports, or with unused exports
// https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
// TODO: enable, semver-major
// TODO: enable once it supports CJS
'import/no-unused-modules': ['off', {
ignoreExports: [],
missingExports: true,
Expand All @@ -262,14 +262,12 @@ module.exports = {

// Reports the use of import declarations with CommonJS exports in any module except for the main module.
// https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
// TODO: enable, semver-major
'import/no-import-module-exports': ['off', {
'import/no-import-module-exports': ['error', {
exceptions: [],
}],

// Use this rule to prevent importing packages through relative paths.
// https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
// TODO: enable, semver-major
'import/no-relative-packages': 'off',
'import/no-relative-packages': 'error',
},
};
11 changes: 2 additions & 9 deletions packages/eslint-config-airbnb-base/rules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ module.exports = {
'eol-last': ['error', 'always'],

// https://eslint.org/docs/rules/function-call-argument-newline
// TODO: enable, semver-minor, once eslint v6.2 is required (which is a major)
'function-call-argument-newline': ['off', 'consistent'],
'function-call-argument-newline': ['error', 'consistent'],

// enforce spacing between functions and their invocations
// https://eslint.org/docs/rules/func-call-spacing
Expand All @@ -108,11 +107,6 @@ module.exports = {
// https://eslint.org/docs/rules/function-paren-newline
'function-paren-newline': ['error', semver.satisfies(eslintPkg.version, '>= 6') ? 'multiline-arguments' : 'consistent'],

// Blacklist certain identifiers to prevent them being used
// https://eslint.org/docs/rules/id-blacklist
// TODO: semver-major, remove once eslint v7.4+ is required
'id-blacklist': 'off',

// disallow specified identifiers
// https://eslint.org/docs/rules/id-denylist
'id-denylist': 'off',
Expand Down Expand Up @@ -444,8 +438,7 @@ module.exports = {

// Disallow the use of Math.pow in favor of the ** operator
// https://eslint.org/docs/rules/prefer-exponentiation-operator
// TODO: enable, semver-major when eslint 5 is dropped
'prefer-exponentiation-operator': 'off',
'prefer-exponentiation-operator': 'error',

// Prefer use of an object spread over Object.assign
// https://eslint.org/docs/rules/prefer-object-spread
Expand Down
Loading

0 comments on commit f3d3a07

Please sign in to comment.