Skip to content

Commit 9d188c9

Browse files
committed
Eslint: upgrade to version 8.0.0
See: - https://eslint.org/blog/2021/10/eslint-v8.0.0-released - https://eslint.org/docs/user-guide/migrating-to-8.0.0 Known unresolved issues (with low impact )that we decided to accept: - mysticatea/eslint-plugin-node#301 Known issues that need to be fixed first: - [x] wait for import-js/eslint-plugin-import#2191 to be released and merged here - [x] wait for gajus/eslint-plugin-flowtype#496 to be released and merged here - [x] wait for testing-library/eslint-plugin-testing-library#462 to be released and merged here - [ ] ~wait for mysticatea/eslint-plugin-node#294 to be released and merged here~ replaced (probably temporarily) with `eslint-plugin-n` which supports Eslint 8 - [x] wait for facebook/react#22248 to be released and merged here - [x] release minor/patch version of Adeira Eslint Config before merging this breaking change - [x] switch `NEXT_VERSION_ERROR` to `ERROR` (#3625)
1 parent 9cfd9ad commit 9d188c9

File tree

13 files changed

+115
-102
lines changed

13 files changed

+115
-102
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"@babel/eslint-parser": "^7.16.5",
1818
"babel-jest": "^27.4.5",
1919
"babel-loader": "^8.2.3",
20-
"eslint": "^7.32.0",
20+
"eslint": "^8.5.0",
21+
"eslint-formatter-codeframe": "^7.32.1",
2122
"flow-bin": "^0.168.0",
2223
"glob": "^7.2.0",
2324
"jest": "^27.4.5",

src/eslint-config-adeira/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
**Breaking changes ahead!**
44

5-
- New rules enabled: `fb-flow/use-indexed-access-type` ([more info](https://flow.org/en/docs/types/indexed-access/)) and `ft-flow/enforce-suppression-code` (warnings or errors in strict mode).
5+
- Eslint version 8 is now required (visit https://eslint.org/blog/2021/10/eslint-v8.0.0-released and other related blog posts for more info).
6+
- New rules enabled: `fb-flow/use-indexed-access-type` ([more info](https://flow.org/en/docs/types/indexed-access/)), `ft-flow/enforce-suppression-code` and `no-unused-private-class-members`.
67
- Many rules that were showing warnings in normal mode but errors in strict mode were converted to normal errors (so there is no difference between normal and strict mode). The best way how to migrate is to temporarily switch to the strict mode and address all the errors before upgrading to this major version.
78
- Switched from [`eslint-plugin-flowtype`](https://github.com/gajus/eslint-plugin-flowtype/tree/449cb99f1b6d3bbbb66f5be55f497667f5b2cb31) to [`eslint-plugin-ft-flow`](https://github.com/flow-typed/eslint-plugin-ft-flow/tree/820e631ce491cdf45821744d4e29f348cf776392) which contains the same set of rules but should be more up to date and maintained. We are going to enable additional rules later. There is a possible minor breaking change (with very simple fix) when suppressing the rules manually, for example:
89

src/eslint-config-adeira/__tests__/__fixtures__/valid-eslint-examples/node/process-exit-as-throw.js

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ class Bar {}
77
// Normally, Eslint would complain because of `consistent-return` error, however,
88
// rule `node/process-exit-as-throw` makes sure this is not the case.
99
// See: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/process-exit-as-throw.md
10+
11+
// TODO: the following `consistent-return` error is incorrect and should be removed once the following
12+
// issue is resolved: https://github.com/mysticatea/eslint-plugin-node/issues/301. We decided to
13+
// accept the low risk for now to ease migration to Eslint 8.
14+
// eslint-disable-next-line consistent-return
1015
export function foo(a: boolean): ?Bar {
1116
if (a) {
1217
return new Bar();

src/eslint-config-adeira/__tests__/__snapshots__/index.test.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ Object {
711711
"no-unsafe-optional-chaining": 2,
712712
"no-unused-expressions": 0,
713713
"no-unused-labels": 1,
714+
"no-unused-private-class-members": 2,
714715
"no-unused-vars": Array [
715716
2,
716717
Object {
@@ -763,6 +764,7 @@ Object {
763764
"prefer-exponentiation-operator": 2,
764765
"prefer-named-capture-group": 2,
765766
"prefer-numeric-literals": 0,
767+
"prefer-object-has-own": 0,
766768
"prefer-object-spread": 2,
767769
"prefer-promise-reject-errors": 1,
768770
"prefer-regex-literals": 2,

src/eslint-config-adeira/__tests__/__snapshots__/presets.test.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ Object {
416416
"no-unsafe-optional-chaining": 2,
417417
"no-unused-expressions": 0,
418418
"no-unused-labels": 1,
419+
"no-unused-private-class-members": 2,
419420
"no-unused-vars": Array [
420421
2,
421422
Object {
@@ -459,6 +460,7 @@ Object {
459460
"prefer-exponentiation-operator": 2,
460461
"prefer-named-capture-group": 2,
461462
"prefer-numeric-literals": 0,
463+
"prefer-object-has-own": 0,
462464
"prefer-object-spread": 2,
463465
"prefer-promise-reject-errors": 1,
464466
"prefer-regex-literals": 2,

src/eslint-config-adeira/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
"snapshot-diff": "^0.9.0"
4343
},
4444
"peerDependencies": {
45-
"eslint": ">=7.24.0 <8.0.0"
45+
"eslint": ">=8.0.0"
4646
}
4747
}

src/eslint-config-adeira/src/presets/base.js

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module.exports = ({
5555
'no-unsafe-finally': ERROR,
5656
'no-unsafe-negation': ERROR,
5757
'no-unsafe-optional-chaining': ERROR,
58+
'no-unused-private-class-members': ERROR,
5859
'require-atomic-updates': ERROR,
5960
'use-isnan': [ERROR, { enforceForSwitchCase: true }],
6061
'valid-jsdoc': OFF,
@@ -268,6 +269,7 @@ module.exports = ({
268269
'prefer-const': [ERROR, { destructuring: 'all' }],
269270
'prefer-destructuring': OFF,
270271
'prefer-numeric-literals': OFF,
272+
'prefer-object-has-own': OFF, // TODO: NEXT_VERSION_ERROR (?) (https://eslint.org/docs/rules/prefer-object-has-own)
271273
'prefer-rest-params': WARN,
272274
'prefer-spread': WARN,
273275
'prefer-template': ERROR,

src/eslint-config-adeira/src/presets/flowtype.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import type { EslintConfig } from '../EslintConfig.flow';
1111
module.exports = ({
1212
plugins: ['eslint-plugin-ft-flow', 'eslint-plugin-fb-flow'],
1313
rules: {
14-
// flowtype (https://github.com/gajus/eslint-plugin-flowtype)
14+
// Flow:
15+
// - https://github.com/flow-typed/eslint-plugin-ft-flow
16+
// - https://github.com/gajus/eslint-plugin-flowtype
1517
'ft-flow/array-style-complex-type': OFF,
1618
'ft-flow/array-style-simple-type': OFF,
1719
'ft-flow/arrow-parens': OFF,

src/eslint-fixtures-tester/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"@adeira/js": "^2.1.1",
1919
"@babel/eslint-parser": "^7.16.5",
2020
"@babel/runtime": "^7.16.5",
21-
"eslint": "^7.32.0",
21+
"eslint": "^8.5.0",
2222
"jest-docblock": "^27.4.0"
2323
},
2424
"peerDependencies": {
25-
"eslint": "^7.32.0"
25+
"eslint": "^8.5.0"
2626
}
2727
}

src/eslint-plugin-adeira/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@adeira/eslint-fixtures-tester": "0.1.0",
2323
"@adeira/flow-types-eslint": "0.0.0",
2424
"@babel/eslint-parser": "^7.16.5",
25-
"eslint": "^7.32.0"
25+
"eslint": "^8.5.0"
2626
},
2727
"peerDependencies": {
2828
"graphql": "^14.0.0 || ^15.0.0"

src/eslint-plugin-sx/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
"@adeira/flow-types-eslint": "0.0.0",
2727
"@babel/code-frame": "^7.16.0",
2828
"@babel/eslint-parser": "^7.16.5",
29-
"eslint": "^7.32.0",
29+
"eslint": "^8.5.0",
3030
"react": "^17.0.2"
3131
},
3232
"peerDependencies": {
3333
"@adeira/sx": "^0.28.0",
34-
"eslint": "^7.32.0"
34+
"eslint": "^8.5.0"
3535
}
3636
}

src/signed-source/src/__tests__/SignedSource.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import os from 'os';
55
import SignedSource from '../SignedSource';
66

77
test('signFile', () => {
8-
expect(SignedSource.signFile(`# ${SignedSource.getSigningToken()}\ntest 1`)).toEqual(
8+
expect(SignedSource.signFile(`# ${SignedSource.getSigningToken()}\ntest 1`)).toBe(
99
`# @generated SignedSource<<d9b7b52f54978f54b84a0fd48145e470>>${os.EOL}test 1`,
1010
);
1111

12-
expect(SignedSource.signFile(`# ${SignedSource.getSigningToken()}\ntest 2`)).toEqual(
12+
expect(SignedSource.signFile(`# ${SignedSource.getSigningToken()}\ntest 2`)).toBe(
1313
`# @generated SignedSource<<4c0c1ae4f5863c72731b2f543e830fd5>>${os.EOL}test 2`,
1414
);
1515

@@ -18,7 +18,7 @@ test('signFile', () => {
1818
SignedSource.signFile(
1919
`# @generated SignedSource<<eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee>>\nalready signed test`,
2020
),
21-
).toEqual(`# @generated SignedSource<<54e8ffafff15a19f858d95c9a13d5b1d>>\nalready signed test`);
21+
).toBe(`# @generated SignedSource<<54e8ffafff15a19f858d95c9a13d5b1d>>\nalready signed test`);
2222

2323
expect(() =>
2424
SignedSource.signFile(`signature missing, no sign token`),

0 commit comments

Comments
 (0)