Skip to content

Commit f3d3a07

Browse files
committed
[eslint config] [base] [breaking] drop eslint < 7, add eslint 8
1 parent eac8cc6 commit f3d3a07

File tree

9 files changed

+237
-145
lines changed

9 files changed

+237
-145
lines changed

.github/workflows/node.yml

+17-15
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
with:
1414
versionsAsRoot: true
1515
type: 'majors'
16-
preset: '^10 || ^12 || ^14 || ^16 || >= 17'
16+
preset: '^12 || ^14 || ^16 || >= 17'
1717

1818
base:
1919
needs: [matrix]
@@ -25,11 +25,14 @@ jobs:
2525
matrix:
2626
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
2727
eslint:
28+
- 8
2829
- 7
29-
- 6
30-
- 5
3130
package:
3231
- eslint-config-airbnb-base
32+
exclude:
33+
- node-version: 10
34+
eslint: 8
35+
package: eslint-config-airbnb-base
3336

3437
defaults:
3538
run:
@@ -60,15 +63,15 @@ jobs:
6063
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
6164
eslint:
6265
- 7
63-
- 6
64-
- 5
66+
# - 6
67+
# - 5
6568
package:
6669
- eslint-config-airbnb
6770
react-hooks:
6871
- ''
69-
- 3
70-
- 2.3
71-
- 1.7
72+
# - 3 # TODO: re-enable these once the react config uses eslint 8
73+
# - 2.3
74+
# - 1.7
7275

7376
defaults:
7477
run:
@@ -97,9 +100,8 @@ jobs:
97100
fail-fast: false
98101
matrix:
99102
eslint:
103+
- 8
100104
- 7
101-
- 6
102-
- 5
103105
package:
104106
- eslint-config-airbnb-base
105107

@@ -130,15 +132,15 @@ jobs:
130132
matrix:
131133
eslint:
132134
- 7
133-
- 6
134-
- 5
135+
# - 6
136+
# - 5
135137
package:
136138
- eslint-config-airbnb
137139
react-hooks:
138140
- ''
139-
- 3
140-
- 2.3
141-
- 1.7
141+
# - 3 # TODO: re-enable these once the react config uses eslint 8
142+
# - 2.3
143+
# - 1.7
142144

143145
defaults:
144146
run:

packages/eslint-config-airbnb-base/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,19 @@
7272
"babel-preset-airbnb": "^4.5.0",
7373
"babel-tape-runner": "^3.0.0",
7474
"eclint": "^2.8.1",
75-
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
76-
"eslint-find-rules": "^3.6.1",
75+
"eslint": "^7.32.0 || ^8.2.0",
76+
"eslint-find-rules": "^4.0.0",
7777
"eslint-plugin-import": "^2.25.2",
7878
"in-publish": "^2.0.1",
79-
"safe-publish-latest": "^1.1.4",
79+
"safe-publish-latest": "^2.0.0",
8080
"tape": "^5.3.1"
8181
},
8282
"peerDependencies": {
83-
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
83+
"eslint": "^7.32.0 || ^8.2.0",
8484
"eslint-plugin-import": "^2.25.2"
8585
},
8686
"engines": {
87-
"node": ">= 6"
87+
"node": "^10.12.0 || >=12.0.0"
8888
},
8989
"dependencies": {
9090
"confusing-browser-globals": "^1.0.10",

packages/eslint-config-airbnb-base/rules/best-practices.js

+8-12
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ module.exports = {
3636

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

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

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

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

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

8380
// Disallow returning value in constructor
8481
// https://eslint.org/docs/rules/no-constructor-return
85-
// TODO: enable, semver-major
86-
'no-constructor-return': 'off',
82+
'no-constructor-return': 'error',
8783

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

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

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

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

388384
// require use of the second argument for parseInt()
389385
// https://eslint.org/docs/rules/radix

packages/eslint-config-airbnb-base/rules/errors.js

+13-16
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ module.exports = {
4040

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

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

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

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

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

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

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

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

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

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

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

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

152146
// disallow use of optional chaining in contexts where the undefined value is not allowed
153147
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
154-
// TODO: enable, semver-minor, once eslint v7.15 is required (which is major)
155-
'no-unsafe-optional-chaining': ['off', { disallowArithmeticOperators: true }],
148+
'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
149+
150+
// Disallow Unused Private Class Members
151+
// https://eslint.org/docs/rules/no-unused-private-class-members
152+
// TODO: enable once eslint 7 is dropped (which is semver-major)
153+
'no-unused-private-class-members': 'off',
156154

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

162159
// disallow negation of the left operand of an in expression
163160
// deprecated in favor of no-unsafe-negation

packages/eslint-config-airbnb-base/rules/es6.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ module.exports = {
6262

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

packages/eslint-config-airbnb-base/rules/imports.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ module.exports = {
253253

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

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

270269
// Use this rule to prevent importing packages through relative paths.
271270
// https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
272-
// TODO: enable, semver-major
273-
'import/no-relative-packages': 'off',
271+
'import/no-relative-packages': 'error',
274272
},
275273
};

packages/eslint-config-airbnb-base/rules/style.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ module.exports = {
8080
'eol-last': ['error', 'always'],
8181

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

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

111-
// Blacklist certain identifiers to prevent them being used
112-
// https://eslint.org/docs/rules/id-blacklist
113-
// TODO: semver-major, remove once eslint v7.4+ is required
114-
'id-blacklist': 'off',
115-
116110
// disallow specified identifiers
117111
// https://eslint.org/docs/rules/id-denylist
118112
'id-denylist': 'off',
@@ -444,8 +438,7 @@ module.exports = {
444438

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

450443
// Prefer use of an object spread over Object.assign
451444
// https://eslint.org/docs/rules/prefer-object-spread

0 commit comments

Comments
 (0)