Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint: upgrade to version 8.0.0 #3274

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"@babel/eslint-parser": "^7.16.5",
"babel-jest": "^27.4.5",
"babel-loader": "^8.2.3",
"eslint": "^7.32.0",
"eslint": "^8.5.0",
"eslint-formatter-codeframe": "^7.32.1",
"flow-bin": "^0.168.0",
"glob": "^7.2.0",
"jest": "^27.4.5",
Expand Down
3 changes: 2 additions & 1 deletion src/eslint-config-adeira/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

**Breaking changes ahead!**

- 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).
- 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).
- 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`.
- 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.
- 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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class Bar {}
// Normally, Eslint would complain because of `consistent-return` error, however,
// rule `node/process-exit-as-throw` makes sure this is not the case.
// See: https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/process-exit-as-throw.md

// TODO: the following `consistent-return` error is incorrect and should be removed once the following
// issue is resolved: https://github.com/mysticatea/eslint-plugin-node/issues/301. We decided to
// accept the low risk for now to ease migration to Eslint 8.
// eslint-disable-next-line consistent-return
export function foo(a: boolean): ?Bar {
if (a) {
return new Bar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ Object {
"no-unsafe-optional-chaining": 2,
"no-unused-expressions": 0,
"no-unused-labels": 1,
"no-unused-private-class-members": 2,
"no-unused-vars": Array [
2,
Object {
Expand Down Expand Up @@ -763,6 +764,7 @@ Object {
"prefer-exponentiation-operator": 2,
"prefer-named-capture-group": 2,
"prefer-numeric-literals": 0,
"prefer-object-has-own": 0,
"prefer-object-spread": 2,
"prefer-promise-reject-errors": 1,
"prefer-regex-literals": 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ Object {
"no-unsafe-optional-chaining": 2,
"no-unused-expressions": 0,
"no-unused-labels": 1,
"no-unused-private-class-members": 2,
"no-unused-vars": Array [
2,
Object {
Expand Down Expand Up @@ -459,6 +460,7 @@ Object {
"prefer-exponentiation-operator": 2,
"prefer-named-capture-group": 2,
"prefer-numeric-literals": 0,
"prefer-object-has-own": 0,
"prefer-object-spread": 2,
"prefer-promise-reject-errors": 1,
"prefer-regex-literals": 2,
Expand Down
2 changes: 1 addition & 1 deletion src/eslint-config-adeira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"snapshot-diff": "^0.9.0"
},
"peerDependencies": {
"eslint": ">=7.24.0 <8.0.0"
"eslint": ">=8.0.0"
}
}
2 changes: 2 additions & 0 deletions src/eslint-config-adeira/src/presets/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = ({
'no-unsafe-finally': ERROR,
'no-unsafe-negation': ERROR,
'no-unsafe-optional-chaining': ERROR,
'no-unused-private-class-members': ERROR,
'require-atomic-updates': ERROR,
'use-isnan': [ERROR, { enforceForSwitchCase: true }],
'valid-jsdoc': OFF,
Expand Down Expand Up @@ -268,6 +269,7 @@ module.exports = ({
'prefer-const': [ERROR, { destructuring: 'all' }],
'prefer-destructuring': OFF,
'prefer-numeric-literals': OFF,
'prefer-object-has-own': OFF, // TODO: NEXT_VERSION_ERROR (?) (https://eslint.org/docs/rules/prefer-object-has-own)
'prefer-rest-params': WARN,
'prefer-spread': WARN,
'prefer-template': ERROR,
Expand Down
4 changes: 3 additions & 1 deletion src/eslint-config-adeira/src/presets/flowtype.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import type { EslintConfig } from '../EslintConfig.flow';
module.exports = ({
plugins: ['eslint-plugin-ft-flow', 'eslint-plugin-fb-flow'],
rules: {
// flowtype (https://github.com/gajus/eslint-plugin-flowtype)
// Flow:
// - https://github.com/flow-typed/eslint-plugin-ft-flow
// - https://github.com/gajus/eslint-plugin-flowtype
'ft-flow/array-style-complex-type': OFF,
'ft-flow/array-style-simple-type': OFF,
'ft-flow/arrow-parens': OFF,
Expand Down
4 changes: 2 additions & 2 deletions src/eslint-fixtures-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"@adeira/js": "^2.1.1",
"@babel/eslint-parser": "^7.16.5",
"@babel/runtime": "^7.16.5",
"eslint": "^7.32.0",
"eslint": "^8.5.0",
"jest-docblock": "^27.4.0"
},
"peerDependencies": {
"eslint": "^7.32.0"
"eslint": "^8.5.0"
}
}
2 changes: 1 addition & 1 deletion src/eslint-plugin-adeira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@adeira/eslint-fixtures-tester": "0.1.0",
"@adeira/flow-types-eslint": "0.0.0",
"@babel/eslint-parser": "^7.16.5",
"eslint": "^7.32.0"
"eslint": "^8.5.0"
},
"peerDependencies": {
"graphql": "^14.0.0 || ^15.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/eslint-plugin-sx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"@adeira/flow-types-eslint": "0.0.0",
"@babel/code-frame": "^7.16.0",
"@babel/eslint-parser": "^7.16.5",
"eslint": "^7.32.0",
"eslint": "^8.5.0",
"react": "^17.0.2"
},
"peerDependencies": {
"@adeira/sx": "^0.28.0",
"eslint": "^7.32.0"
"eslint": "^8.5.0"
}
}
6 changes: 3 additions & 3 deletions src/signed-source/src/__tests__/SignedSource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import os from 'os';
import SignedSource from '../SignedSource';

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

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

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

expect(() =>
SignedSource.signFile(`signature missing, no sign token`),
Expand Down
Loading