From 10bf84c98ee028b0ccf4927f1488f9f90aa35a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sun, 29 Aug 2021 17:57:20 +0200 Subject: [PATCH] feat: support ESLint 8.x BREAKING CHANGE: Requires Node@^12.22.0 || ^14.17.0 || >=16.0.0 BREAKING CHANGE: Requires ESLint@^8.0.0-0 --- .babelrc | 2 +- .travis.yml | 2 +- package.json | 16 ++++++++-------- src/rules/noUnusedExpressions.js | 3 ++- tests/rules/assertions/defineFlowType.js | 12 ++++++------ tests/rules/assertions/useFlowType.js | 14 +++++++------- tests/rules/index.js | 2 +- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.babelrc b/.babelrc index 8b6de73d..fb7703b1 100644 --- a/.babelrc +++ b/.babelrc @@ -8,7 +8,7 @@ "@babel/preset-env", { "targets": { - "node": 10 + "node": 12 } } ] diff --git a/.travis.yml b/.travis.yml index c7f9df5a..9cc17300 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - node - - 10 + - 12 before_install: - npm config set depth 0 notifications: diff --git a/package.json b/package.json index 8bb60cbc..e0a5fdc4 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,18 @@ }, "description": "Flowtype linting rules for ESLint.", "devDependencies": { - "@babel/cli": "^7.15.4", - "@babel/core": "^7.15.5", - "@babel/node": "^7.15.4", + "@babel/cli": "^7.15.7", + "@babel/core": "^7.15.8", + "@babel/eslint-parser": "^7.15.8", + "@babel/node": "^7.15.8", "@babel/plugin-proposal-object-rest-spread": "^7.15.6", - "@babel/preset-env": "^7.15.6", + "@babel/preset-env": "^7.15.8", "@babel/register": "^7.15.3", "ajv": "^8.6.3", - "babel-eslint": "^10.1.0", "babel-plugin-add-module-exports": "^1.0.4", "chai": "^4.3.4", "eclint": "^2.8.1", - "eslint": "^7.32.0", + "eslint": "^8.0.0", "eslint-config-canonical": "^27.0.1", "gitdown": "^3.1.4", "glob": "^7.1.7", @@ -32,7 +32,7 @@ "semantic-release": "^17.4.7" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "husky": { "hooks": { @@ -48,7 +48,7 @@ "main": "./dist/index.js", "name": "eslint-plugin-flowtype", "peerDependencies": { - "eslint": "^7.32.0" + "eslint": "^8.0.0" }, "repository": { "type": "git", diff --git a/src/rules/noUnusedExpressions.js b/src/rules/noUnusedExpressions.js index 2cfdf736..c89a4a33 100644 --- a/src/rules/noUnusedExpressions.js +++ b/src/rules/noUnusedExpressions.js @@ -1,7 +1,8 @@ // A wrapper around ESLint's core rule no-unused-expressions, additionally ignores type cast // expressions. +import { builtinRules } from 'eslint/use-at-your-own-risk'; -import coreNOE from 'eslint/lib/rules/no-unused-expressions'; +const coreNOE = builtinRules.get('no-unused-expressions'); const meta = coreNOE.meta; diff --git a/tests/rules/assertions/defineFlowType.js b/tests/rules/assertions/defineFlowType.js index 8e421c07..f863a4f9 100644 --- a/tests/rules/assertions/defineFlowType.js +++ b/tests/rules/assertions/defineFlowType.js @@ -1,7 +1,7 @@ -import { - RuleTester, -} from 'eslint'; -import noUndefRule from 'eslint/lib/rules/no-undef'; +import { RuleTester } from 'eslint'; +import { builtinRules } from 'eslint/use-at-your-own-risk'; + +const noUndefRule = builtinRules.get('no-undef'); const VALID_WITH_DEFINE_FLOW_TYPE = [ { @@ -198,7 +198,7 @@ const ALWAYS_VALID = [ */ { const ruleTester = new RuleTester({ - parser: require.resolve('babel-eslint'), + parser: require.resolve('@babel/eslint-parser'), }); ruleTester.run('no-undef must not trigger an error in these cases', noUndefRule, { @@ -209,7 +209,7 @@ const ALWAYS_VALID = [ { const ruleTester = new RuleTester({ - parser: require.resolve('babel-eslint'), + parser: require.resolve('@babel/eslint-parser'), }); ruleTester.run('no-undef must trigger an error when define-flow-type is not used in these cases', noUndefRule, { diff --git a/tests/rules/assertions/useFlowType.js b/tests/rules/assertions/useFlowType.js index 7d7ee44a..3687b225 100644 --- a/tests/rules/assertions/useFlowType.js +++ b/tests/rules/assertions/useFlowType.js @@ -1,9 +1,9 @@ -import { - RuleTester, -} from 'eslint'; -import noUnusedVarsRule from 'eslint/lib/rules/no-unused-vars'; +import { RuleTester } from 'eslint'; +import { builtinRules } from 'eslint/use-at-your-own-risk'; import useFlowType from '../../../src/rules/useFlowType'; +const noUnusedVarsRule = builtinRules.get('no-unused-vars'); + const VALID_WITH_USE_FLOW_TYPE = [ { code: 'declare class A {}', @@ -92,7 +92,7 @@ const ALWAYS_VALID = [ */ { const ruleTester = new RuleTester({ - parser: require.resolve('babel-eslint'), + parser: require.resolve('@babel/eslint-parser'), }); ruleTester.run('no-unused-vars must not trigger an error in these cases', noUnusedVarsRule, { @@ -103,7 +103,7 @@ const ALWAYS_VALID = [ { const ruleTester = new RuleTester({ - parser: require.resolve('babel-eslint'), + parser: require.resolve('@babel/eslint-parser'), }); ruleTester.run('no-unused-vars must trigger an error in these cases', noUnusedVarsRule, { @@ -117,7 +117,7 @@ const ALWAYS_VALID = [ { const ruleTester = new RuleTester({ - parser: require.resolve('babel-eslint'), + parser: require.resolve('@babel/eslint-parser'), rules: { 'use-flow-type': 1, }, diff --git a/tests/rules/index.js b/tests/rules/index.js index 87d0a7ab..f9a2ddd4 100644 --- a/tests/rules/index.js +++ b/tests/rules/index.js @@ -60,7 +60,7 @@ const reportingRules = [ 'valid-syntax', ]; -const parser = require.resolve('babel-eslint'); +const parser = require.resolve('@babel/eslint-parser'); const ajv = new Ajv({ verbose: true, });