From 7443c84e7a721b599b38609479c52c86cc0df618 Mon Sep 17 00:00:00 2001 From: Joseph Phelan <47540781+joephela@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:08:34 -0500 Subject: [PATCH] update typescript-eslint (#43) * update typescript-eslint * improve imports * update project typescript-eslint --- .changeset/quick-bats-jog.md | 6 + README.md | 2 +- eslint.config.mjs | 25 +-- package.json | 2 - packages/eslint-config-widen/package.json | 14 +- packages/eslint-config-widen/src/base.ts | 2 +- .../eslint-config-widen/src/typescript.ts | 9 +- packages/eslint-playground/package.json | 3 +- yarn.lock | 204 ++---------------- 9 files changed, 45 insertions(+), 222 deletions(-) create mode 100644 .changeset/quick-bats-jog.md diff --git a/.changeset/quick-bats-jog.md b/.changeset/quick-bats-jog.md new file mode 100644 index 0000000..91275fd --- /dev/null +++ b/.changeset/quick-bats-jog.md @@ -0,0 +1,6 @@ +--- +'eslint-config-widen': patch +'eslint-playground': patch +--- + +Upgrade the typescript-eslint package away from the legacy config setups. diff --git a/README.md b/README.md index 6266764..6bacf7c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Widen's shared ESLint config and plugins. yarn add -D eslint eslint-{config,plugin}-widen eslint-plugin-sort @babel/{core,eslint-parser} # If you use TypeScript -yarn add -D @typescript-eslint/{eslint-plugin,parser} +yarn add -D typescript-eslint # If you use React yarn add -D eslint-plugin-{react,react-hooks,jsx-a11y} diff --git a/eslint.config.mjs b/eslint.config.mjs index 9516f4b..2ad5ca2 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,30 +1,17 @@ -import { FlatCompat } from '@eslint/eslintrc' -import js from '@eslint/js' +import eslint from '@eslint/js' import typescriptEslint from '@typescript-eslint/eslint-plugin' import tsParser from '@typescript-eslint/parser' +import sort from 'eslint-plugin-sort' import globals from 'globals' -import path from 'node:path' -import { fileURLToPath } from 'node:url' - -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) - -//TODO: cleanup compat https://acquia.atlassian.net/browse/FE-1172 -const compat = new FlatCompat({ - allConfig: js.configs.all, - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, -}) +import tseslint from 'typescript-eslint' export default [ { ignores: ['**/lib/', '**/packages/eslint-playground/'], }, - ...compat.extends( - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:sort/recommended', - ), + eslint.configs.recommended, + ...tseslint.configs.recommended, + sort.configs['flat/recommended'], { languageOptions: { globals: { diff --git a/package.json b/package.json index d6e55e8..2d61ba3 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,6 @@ "@changesets/cli": "^2.27.7", "@eslint/eslintrc": "^3.1.0", "@eslint/js": "^9.6.0", - "@typescript-eslint/eslint-plugin": "^7.16.0", - "@typescript-eslint/parser": "^7.16.0", "eslint": "^9.6.0", "eslint-plugin-sort": "^3.0.2", "globals": "^15.8.0", diff --git a/packages/eslint-config-widen/package.json b/packages/eslint-config-widen/package.json index e82a242..c818939 100644 --- a/packages/eslint-config-widen/package.json +++ b/packages/eslint-config-widen/package.json @@ -16,8 +16,6 @@ "name": "eslint-config-widen", "peerDependencies": { "@babel/eslint-parser": "^7.22.15", - "@typescript-eslint/eslint-plugin": "^6.9.1", - "@typescript-eslint/parser": "^6.9.1", "eslint": ">= 9", "eslint-plugin-jest": ">= 28", "eslint-plugin-jsx-a11y": ">= 6", @@ -25,15 +23,10 @@ "eslint-plugin-react": ">= 7", "eslint-plugin-react-hooks": ">= 4", "eslint-plugin-sort": ">= 3", - "eslint-plugin-widen": ">=3.0.0" + "eslint-plugin-widen": ">=3.0.0", + "typescript-eslint": ">= 7.16.0" }, "peerDependenciesMeta": { - "@typescript-eslint/eslint-plugin": { - "optional": true - }, - "@typescript-eslint/parser": { - "optional": true - }, "eslint-plugin-jest": { "optional": true }, @@ -48,6 +41,9 @@ }, "eslint-plugin-react-hooks": { "optional": true + }, + "typescript-eslint": { + "optional": true } }, "repository": { diff --git a/packages/eslint-config-widen/src/base.ts b/packages/eslint-config-widen/src/base.ts index fe44dd7..e544d9e 100644 --- a/packages/eslint-config-widen/src/base.ts +++ b/packages/eslint-config-widen/src/base.ts @@ -1,8 +1,8 @@ +import babelParser from '@babel/eslint-parser' import js from '@eslint/js' import prettier from 'eslint-plugin-prettier' import sort from 'eslint-plugin-sort' import widen from 'eslint-plugin-widen' -import babelParser from '@babel/eslint-parser' import sharedGlobals from './sharedGlobals.js' export default [ diff --git a/packages/eslint-config-widen/src/typescript.ts b/packages/eslint-config-widen/src/typescript.ts index d4f1bee..a9fafb3 100644 --- a/packages/eslint-config-widen/src/typescript.ts +++ b/packages/eslint-config-widen/src/typescript.ts @@ -1,11 +1,14 @@ -import tseslint from 'typescript-eslint' +import { configs, parser, plugin } from 'typescript-eslint' export default [ - ...tseslint.configs.recommended, + ...configs.recommended, { files: ['*.ts', '*.tsx'], languageOptions: { - parser: tseslint.parser, + parser: parser, + }, + plugins: { + '@typescript-eslint': plugin, }, rules: { '@typescript-eslint/camelcase': 'off', diff --git a/packages/eslint-playground/package.json b/packages/eslint-playground/package.json index 338ef85..0c9fd1c 100644 --- a/packages/eslint-playground/package.json +++ b/packages/eslint-playground/package.json @@ -16,7 +16,8 @@ "eslint-plugin-react": "^7.34.3", "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-sort": "^3.0.2", - "eslint-plugin-widen": "workspace:^" + "eslint-plugin-widen": "workspace:^", + "typescript-eslint": "^7.16.0" }, "dependencies": { "react": "^18.3.1" diff --git a/yarn.lock b/yarn.lock index b4a8a65..0656c1f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,44 +32,14 @@ __metadata: languageName: node linkType: hard -"@babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/compat-data@npm:7.24.7" - checksum: 1fc276825dd434fe044877367dfac84171328e75a8483a6976aa28bf833b32367e90ee6df25bdd97c287d1aa8019757adcccac9153de70b1932c0d243a978ae9 - languageName: node - linkType: hard - -"@babel/compat-data@npm:^7.24.8": +"@babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.24.7, @babel/compat-data@npm:^7.24.8": version: 7.24.8 resolution: "@babel/compat-data@npm:7.24.8" checksum: 75b2cf8220ad17ec50486a461c3fecb60cae6498b1beec3946dabf894129d03d34d9b545bbd3e81c8f9d36570a8b4d1965c694b16c02868926510c3374822c39 languageName: node linkType: hard -"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3, @babel/core@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/core@npm:7.24.7" - dependencies: - "@ampproject/remapping": ^2.2.0 - "@babel/code-frame": ^7.24.7 - "@babel/generator": ^7.24.7 - "@babel/helper-compilation-targets": ^7.24.7 - "@babel/helper-module-transforms": ^7.24.7 - "@babel/helpers": ^7.24.7 - "@babel/parser": ^7.24.7 - "@babel/template": ^7.24.7 - "@babel/traverse": ^7.24.7 - "@babel/types": ^7.24.7 - convert-source-map: ^2.0.0 - debug: ^4.1.0 - gensync: ^1.0.0-beta.2 - json5: ^2.2.3 - semver: ^6.3.1 - checksum: 017497e2a1b4683a885219eef7d2aee83c1c0cf353506b2e180b73540ec28841d8ef1ea1837fa69f8c561574b24ddd72f04764b27b87afedfe0a07299ccef24d - languageName: node - linkType: hard - -"@babel/core@npm:^7.24.8": +"@babel/core@npm:^7.11.6, @babel/core@npm:^7.12.3, @babel/core@npm:^7.24.7, @babel/core@npm:^7.24.8": version: 7.24.8 resolution: "@babel/core@npm:7.24.8" dependencies: @@ -106,19 +76,7 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.24.7, @babel/generator@npm:^7.7.2": - version: 7.24.7 - resolution: "@babel/generator@npm:7.24.7" - dependencies: - "@babel/types": ^7.24.7 - "@jridgewell/gen-mapping": ^0.3.5 - "@jridgewell/trace-mapping": ^0.3.25 - jsesc: ^2.5.1 - checksum: 0ff31a73b15429f1287e4d57b439bba4a266f8c673bb445fe313b82f6d110f586776997eb723a777cd7adad9d340edd162aea4973a90112c5d0cfcaf6686844b - languageName: node - linkType: hard - -"@babel/generator@npm:^7.24.8": +"@babel/generator@npm:^7.24.8, @babel/generator@npm:^7.7.2": version: 7.24.8 resolution: "@babel/generator@npm:7.24.8" dependencies: @@ -149,20 +107,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-compilation-targets@npm:^7.22.6, @babel/helper-compilation-targets@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/helper-compilation-targets@npm:7.24.7" - dependencies: - "@babel/compat-data": ^7.24.7 - "@babel/helper-validator-option": ^7.24.7 - browserslist: ^4.22.2 - lru-cache: ^5.1.1 - semver: ^6.3.1 - checksum: dfc88bc35e223ade796c7267901728217c665adc5bc2e158f7b0ae850de14f1b7941bec4fe5950ae46236023cfbdeddd9c747c276acf9b39ca31f8dd97dc6cc6 - languageName: node - linkType: hard - -"@babel/helper-compilation-targets@npm:^7.24.8": +"@babel/helper-compilation-targets@npm:^7.22.6, @babel/helper-compilation-targets@npm:^7.24.7, @babel/helper-compilation-targets@npm:^7.24.8": version: 7.24.8 resolution: "@babel/helper-compilation-targets@npm:7.24.8" dependencies: @@ -270,22 +215,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-module-transforms@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/helper-module-transforms@npm:7.24.7" - dependencies: - "@babel/helper-environment-visitor": ^7.24.7 - "@babel/helper-module-imports": ^7.24.7 - "@babel/helper-simple-access": ^7.24.7 - "@babel/helper-split-export-declaration": ^7.24.7 - "@babel/helper-validator-identifier": ^7.24.7 - peerDependencies: - "@babel/core": ^7.0.0 - checksum: ddff3b41c2667876b4e4e73d961168f48a5ec9560c95c8c2d109e6221f9ca36c6f90c6317eb7a47f2a3c99419c356e529a86b79174cad0d4f7a61960866b88ca - languageName: node - linkType: hard - -"@babel/helper-module-transforms@npm:^7.24.8": +"@babel/helper-module-transforms@npm:^7.24.7, @babel/helper-module-transforms@npm:^7.24.8": version: 7.24.8 resolution: "@babel/helper-module-transforms@npm:7.24.8" dependencies: @@ -371,13 +301,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-string-parser@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/helper-string-parser@npm:7.24.7" - checksum: 09568193044a578743dd44bf7397940c27ea693f9812d24acb700890636b376847a611cdd0393a928544e79d7ad5b8b916bd8e6e772bc8a10c48a647a96e7b1a - languageName: node - linkType: hard - "@babel/helper-string-parser@npm:^7.24.8": version: 7.24.8 resolution: "@babel/helper-string-parser@npm:7.24.8" @@ -392,14 +315,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-validator-option@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/helper-validator-option@npm:7.24.7" - checksum: 9689166bf3f777dd424c026841c8cd651e41b21242dbfd4569a53086179a3e744c8eddd56e9d10b54142270141c91581b53af0d7c00c82d552d2540e2a919f7e - languageName: node - linkType: hard - -"@babel/helper-validator-option@npm:^7.24.8": +"@babel/helper-validator-option@npm:^7.24.7, @babel/helper-validator-option@npm:^7.24.8": version: 7.24.8 resolution: "@babel/helper-validator-option@npm:7.24.8" checksum: a52442dfa74be6719c0608fee3225bd0493c4057459f3014681ea1a4643cd38b68ff477fe867c4b356da7330d085f247f0724d300582fa4ab9a02efaf34d107c @@ -418,16 +334,6 @@ __metadata: languageName: node linkType: hard -"@babel/helpers@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/helpers@npm:7.24.7" - dependencies: - "@babel/template": ^7.24.7 - "@babel/types": ^7.24.7 - checksum: 934da58098a3670ca7f9f42425b9c44d0ca4f8fad815c0f51d89fc7b64c5e0b4c7d5fec038599de691229ada737edeaf72fad3eba8e16dd5842e8ea447f76b66 - languageName: node - linkType: hard - "@babel/helpers@npm:^7.24.8": version: 7.24.8 resolution: "@babel/helpers@npm:7.24.8" @@ -450,16 +356,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/parser@npm:7.24.7" - bin: - parser: ./bin/babel-parser.js - checksum: fc9d2c4c8712f89672edc55c0dc5cf640dcec715b56480f111f85c2bc1d507e251596e4110d65796690a96ac37a4b60432af90b3e97bb47e69d4ef83872dbbd6 - languageName: node - linkType: hard - -"@babel/parser@npm:^7.24.8": +"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.24.7, @babel/parser@npm:^7.24.8": version: 7.24.8 resolution: "@babel/parser@npm:7.24.8" bin: @@ -1496,25 +1393,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/traverse@npm:7.24.7" - dependencies: - "@babel/code-frame": ^7.24.7 - "@babel/generator": ^7.24.7 - "@babel/helper-environment-visitor": ^7.24.7 - "@babel/helper-function-name": ^7.24.7 - "@babel/helper-hoist-variables": ^7.24.7 - "@babel/helper-split-export-declaration": ^7.24.7 - "@babel/parser": ^7.24.7 - "@babel/types": ^7.24.7 - debug: ^4.3.1 - globals: ^11.1.0 - checksum: 7cd366afe9e7ee77e493779fdf24f67bf5595247289364f4689e29688572505eaeb886d7a8f20ebb9c29fc2de7d0895e4ff9e203e78e39ac67239724d45aa83b - languageName: node - linkType: hard - -"@babel/traverse@npm:^7.24.8": +"@babel/traverse@npm:^7.24.7, @babel/traverse@npm:^7.24.8": version: 7.24.8 resolution: "@babel/traverse@npm:7.24.8" dependencies: @@ -1532,18 +1411,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.24.7, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": - version: 7.24.7 - resolution: "@babel/types@npm:7.24.7" - dependencies: - "@babel/helper-string-parser": ^7.24.7 - "@babel/helper-validator-identifier": ^7.24.7 - to-fast-properties: ^2.0.0 - checksum: 3e4437fced97e02982972ce5bebd318c47d42c9be2152c0fd28c6f786cc74086cc0a8fb83b602b846e41df37f22c36254338eada1a47ef9d8a1ec92332ca3ea8 - languageName: node - linkType: hard - -"@babel/types@npm:^7.24.8": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.24.7, @babel/types@npm:^7.24.8, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": version: 7.24.8 resolution: "@babel/types@npm:7.24.8" dependencies: @@ -2421,7 +2289,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:7.16.0, @typescript-eslint/eslint-plugin@npm:^7.16.0": +"@typescript-eslint/eslint-plugin@npm:7.16.0": version: 7.16.0 resolution: "@typescript-eslint/eslint-plugin@npm:7.16.0" dependencies: @@ -2455,7 +2323,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/parser@npm:7.16.0, @typescript-eslint/parser@npm:^7.16.0": +"@typescript-eslint/parser@npm:7.16.0": version: 7.16.0 resolution: "@typescript-eslint/parser@npm:7.16.0" dependencies: @@ -3101,7 +2969,7 @@ __metadata: languageName: node linkType: hard -"browserslist@npm:^4.22.2, browserslist@npm:^4.23.0, browserslist@npm:^4.23.1": +"browserslist@npm:^4.23.0, browserslist@npm:^4.23.1": version: 4.23.2 resolution: "browserslist@npm:4.23.2" dependencies: @@ -3830,8 +3698,6 @@ __metadata: eslint-config-prettier: ^9.1.0 peerDependencies: "@babel/eslint-parser": ^7.22.15 - "@typescript-eslint/eslint-plugin": ^6.9.1 - "@typescript-eslint/parser": ^6.9.1 eslint: ">= 9" eslint-plugin-jest: ">= 28" eslint-plugin-jsx-a11y: ">= 6" @@ -3840,11 +3706,8 @@ __metadata: eslint-plugin-react-hooks: ">= 4" eslint-plugin-sort: ">= 3" eslint-plugin-widen: ">=3.0.0" + typescript-eslint: ">= 7.16.0" peerDependenciesMeta: - "@typescript-eslint/eslint-plugin": - optional: true - "@typescript-eslint/parser": - optional: true eslint-plugin-jest: optional: true eslint-plugin-jsx-a11y: @@ -3855,6 +3718,8 @@ __metadata: optional: true eslint-plugin-react-hooks: optional: true + typescript-eslint: + optional: true languageName: unknown linkType: soft @@ -3868,8 +3733,6 @@ __metadata: "@changesets/cli": ^2.27.7 "@eslint/eslintrc": ^3.1.0 "@eslint/js": ^9.6.0 - "@typescript-eslint/eslint-plugin": ^7.16.0 - "@typescript-eslint/parser": ^7.16.0 eslint: ^9.6.0 eslint-plugin-sort: ^3.0.2 globals: ^15.8.0 @@ -3897,6 +3760,7 @@ __metadata: eslint-plugin-sort: ^3.0.2 eslint-plugin-widen: "workspace:^" react: ^18.3.1 + typescript-eslint: ^7.16.0 languageName: unknown linkType: soft @@ -4173,14 +4037,7 @@ __metadata: languageName: node linkType: hard -"estraverse@npm:^5.1.0, estraverse@npm:^5.2.0": - version: 5.2.0 - resolution: "estraverse@npm:5.2.0" - checksum: ec11b70d946bf5d7f76f91db38ef6f08109ac1b36cda293a26e678e58df4719f57f67b9ec87042afdd1f0267cee91865be3aa48d2161765a93defab5431be7b8 - languageName: node - linkType: hard - -"estraverse@npm:^5.3.0": +"estraverse@npm:^5.1.0, estraverse@npm:^5.2.0, estraverse@npm:^5.3.0": version: 5.3.0 resolution: "estraverse@npm:5.3.0" checksum: 072780882dc8416ad144f8fe199628d2b3e7bbc9989d9ed43795d2c90309a2047e6bc5979d7e2322a341163d22cfad9e21f4110597fe487519697389497e4e2b @@ -4471,13 +4328,6 @@ __metadata: languageName: node linkType: hard -"function-bind@npm:^1.1.1": - version: 1.1.1 - resolution: "function-bind@npm:1.1.1" - checksum: b32fbaebb3f8ec4969f033073b43f5c8befbb58f1a79e12f1d7490358150359ebd92f49e72ff0144f65f2c48ea2a605bff2d07965f548f6474fd8efd95bf361a - languageName: node - linkType: hard - "function-bind@npm:^1.1.2": version: 1.1.2 resolution: "function-bind@npm:1.1.2" @@ -4767,15 +4617,6 @@ __metadata: languageName: node linkType: hard -"has@npm:^1.0.3": - version: 1.0.3 - resolution: "has@npm:1.0.3" - dependencies: - function-bind: ^1.1.1 - checksum: b9ad53d53be4af90ce5d1c38331e712522417d017d5ef1ebd0507e07c2fbad8686fffb8e12ddecd4c39ca9b9b47431afbb975b8abf7f3c3b82c98e9aad052792 - languageName: node - linkType: hard - "hasown@npm:^2.0.0, hasown@npm:^2.0.1, hasown@npm:^2.0.2": version: 2.0.2 resolution: "hasown@npm:2.0.2" @@ -4952,7 +4793,7 @@ __metadata: languageName: node linkType: hard -"is-core-module@npm:^2.13.0": +"is-core-module@npm:^2.13.0, is-core-module@npm:^2.8.0": version: 2.14.0 resolution: "is-core-module@npm:2.14.0" dependencies: @@ -4961,15 +4802,6 @@ __metadata: languageName: node linkType: hard -"is-core-module@npm:^2.8.0": - version: 2.8.1 - resolution: "is-core-module@npm:2.8.1" - dependencies: - has: ^1.0.3 - checksum: 418b7bc10768a73c41c7ef497e293719604007f88934a6ffc5f7c78702791b8528102fb4c9e56d006d69361549b3d9519440214a74aefc7e0b79e5e4411d377f - languageName: node - linkType: hard - "is-data-view@npm:^1.0.1": version: 1.0.1 resolution: "is-data-view@npm:1.0.1"