diff --git a/CHANGELOG.md b/CHANGELOG.md index d66f970..6e7b428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/__tests__/__fixtures__/valid-eslint-examples/node/process-exit-as-throw.js b/__tests__/__fixtures__/valid-eslint-examples/node/process-exit-as-throw.js index 7729aeb..ed607e1 100644 --- a/__tests__/__fixtures__/valid-eslint-examples/node/process-exit-as-throw.js +++ b/__tests__/__fixtures__/valid-eslint-examples/node/process-exit-as-throw.js @@ -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(); diff --git a/__tests__/__snapshots__/index.test.js.snap b/__tests__/__snapshots__/index.test.js.snap index cb22e5e..f0f02e8 100644 --- a/__tests__/__snapshots__/index.test.js.snap +++ b/__tests__/__snapshots__/index.test.js.snap @@ -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 { @@ -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, diff --git a/__tests__/__snapshots__/presets.test.js.snap b/__tests__/__snapshots__/presets.test.js.snap index 515e4b8..d203e73 100644 --- a/__tests__/__snapshots__/presets.test.js.snap +++ b/__tests__/__snapshots__/presets.test.js.snap @@ -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 { @@ -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, diff --git a/package.json b/package.json index 627c8b5..90bd964 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,6 @@ "snapshot-diff": "^0.9.0" }, "peerDependencies": { - "eslint": ">=7.24.0 <8.0.0" + "eslint": ">=8.0.0" } } diff --git a/src/presets/base.js b/src/presets/base.js index bf4a9a6..8d4834e 100644 --- a/src/presets/base.js +++ b/src/presets/base.js @@ -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, @@ -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, diff --git a/src/presets/flowtype.js b/src/presets/flowtype.js index 2eb931c..b5a6547 100644 --- a/src/presets/flowtype.js +++ b/src/presets/flowtype.js @@ -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,