From c7a46ec25b4e9ef49102771f2205b9b8ddc2c816 Mon Sep 17 00:00:00 2001 From: Logan Rosen Date: Tue, 18 Feb 2025 12:30:36 -0500 Subject: [PATCH] Improve ESLint config (#24290) * Improve ESLint config --- build-scripts/eslint.config.mjs | 26 +++---- eslint.config.mjs | 32 +++++---- gallery/eslint.config.mjs | 14 ++-- package.json | 3 +- test/.eslintrc | 5 -- yarn.lock | 117 ++++++++++++++++++-------------- 6 files changed, 103 insertions(+), 94 deletions(-) delete mode 100644 test/.eslintrc diff --git a/build-scripts/eslint.config.mjs b/build-scripts/eslint.config.mjs index 6c33f43ba5..781dcf3898 100644 --- a/build-scripts/eslint.config.mjs +++ b/build-scripts/eslint.config.mjs @@ -1,16 +1,16 @@ +// @ts-check + +import tseslint from "typescript-eslint"; import rootConfig from "../eslint.config.mjs"; -export default [ - ...rootConfig, - { - rules: { - "no-console": "off", - "import/no-extraneous-dependencies": "off", - "import/extensions": "off", - "import/no-dynamic-require": "off", - "global-require": "off", - "@typescript-eslint/no-require-imports": "off", - "prefer-arrow-callback": "off", - }, +export default tseslint.config(...rootConfig, { + rules: { + "no-console": "off", + "import/no-extraneous-dependencies": "off", + "import/extensions": "off", + "import/no-dynamic-require": "off", + "global-require": "off", + "@typescript-eslint/no-require-imports": "off", + "prefer-arrow-callback": "off", }, -]; +}); diff --git a/eslint.config.mjs b/eslint.config.mjs index a5986d29af..6907fdecbe 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,11 +1,16 @@ +// @ts-check + /* eslint-disable import/no-extraneous-dependencies */ import unusedImports from "eslint-plugin-unused-imports"; import globals from "globals"; -import tsParser from "@typescript-eslint/parser"; import path from "node:path"; import { fileURLToPath } from "node:url"; import js from "@eslint/js"; import { FlatCompat } from "@eslint/eslintrc"; +import tseslint from "typescript-eslint"; +import eslintConfigPrettier from "eslint-config-prettier"; +import { configs as litConfigs } from "eslint-plugin-lit"; +import { configs as wcConfigs } from "eslint-plugin-wc"; const _filename = fileURLToPath(import.meta.url); const _dirname = path.dirname(_filename); @@ -15,17 +20,14 @@ const compat = new FlatCompat({ allConfig: js.configs.all, }); -export default [ - ...compat.extends( - "airbnb-base", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/strict", - "plugin:@typescript-eslint/stylistic", - "plugin:wc/recommended", - "plugin:lit/all", - "plugin:lit-a11y/recommended", - "prettier" - ), +export default tseslint.config( + ...compat.extends("airbnb-base", "plugin:lit-a11y/recommended"), + eslintConfigPrettier, + litConfigs["flat/all"], + tseslint.configs.recommended, + tseslint.configs.strict, + tseslint.configs.stylistic, + wcConfigs["flat/recommended"], { plugins: { "unused-imports": unusedImports, @@ -43,7 +45,7 @@ export default [ Polymer: true, }, - parser: tsParser, + parser: tseslint.parser, ecmaVersion: 2020, sourceType: "module", @@ -184,5 +186,5 @@ export default [ ], "no-use-before-define": "off", }, - }, -]; + } +); diff --git a/gallery/eslint.config.mjs b/gallery/eslint.config.mjs index 95108521b0..1860147df8 100644 --- a/gallery/eslint.config.mjs +++ b/gallery/eslint.config.mjs @@ -1,10 +1,10 @@ +// @ts-check + +import tseslint from "typescript-eslint"; import rootConfig from "../eslint.config.mjs"; -export default [ - ...rootConfig, - { - rules: { - "no-console": "off", - }, +export default tseslint.config(...rootConfig, { + rules: { + "no-console": "off", }, -]; +}); diff --git a/package.json b/package.json index b6fa4fdd4b..bbe026e817 100644 --- a/package.json +++ b/package.json @@ -186,8 +186,6 @@ "@types/tar": "6.1.13", "@types/ua-parser-js": "0.7.39", "@types/webspeechapi": "0.0.29", - "@typescript-eslint/eslint-plugin": "8.24.0", - "@typescript-eslint/parser": "8.24.0", "@vitest/coverage-v8": "3.0.5", "babel-loader": "9.2.1", "babel-plugin-template-html-minifier": "4.1.0", @@ -227,6 +225,7 @@ "terser-webpack-plugin": "5.3.11", "ts-lit-plugin": "2.0.2", "typescript": "5.7.3", + "typescript-eslint": "8.24.1", "vitest": "3.0.5", "webpack-stats-plugin": "1.1.3", "webpackbar": "7.0.0", diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index 04cfba7cd0..0000000000 --- a/test/.eslintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "rules": { - "import/no-extraneous-dependencies": 0 - } -} diff --git a/yarn.lock b/yarn.lock index fb64df3d49..27d5fb8825 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5021,15 +5021,15 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/eslint-plugin@npm:8.24.0" +"@typescript-eslint/eslint-plugin@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/eslint-plugin@npm:8.24.1" dependencies: "@eslint-community/regexpp": "npm:^4.10.0" - "@typescript-eslint/scope-manager": "npm:8.24.0" - "@typescript-eslint/type-utils": "npm:8.24.0" - "@typescript-eslint/utils": "npm:8.24.0" - "@typescript-eslint/visitor-keys": "npm:8.24.0" + "@typescript-eslint/scope-manager": "npm:8.24.1" + "@typescript-eslint/type-utils": "npm:8.24.1" + "@typescript-eslint/utils": "npm:8.24.1" + "@typescript-eslint/visitor-keys": "npm:8.24.1" graphemer: "npm:^1.4.0" ignore: "npm:^5.3.1" natural-compare: "npm:^1.4.0" @@ -5038,64 +5038,64 @@ __metadata: "@typescript-eslint/parser": ^8.0.0 || ^8.0.0-alpha.0 eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.8.0" - checksum: 10/2b65131dab6159285cd8688ae8fe4708e87f6aede7a6bcf65deec6f506a26f04409c7320d7957f59380f5b387fff2acfaa2c8117e2cbfc1b9368002e7905f616 + checksum: 10/4c455e98d47f8dc1ea12c0dae0a849de49b0ad9aa5f9591b2ba24c07b75af0782a349d13cf6c5c375c6e8ba43d12555f932d43d31f25c8848eceb972021c12ee languageName: node linkType: hard -"@typescript-eslint/parser@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/parser@npm:8.24.0" +"@typescript-eslint/parser@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/parser@npm:8.24.1" dependencies: - "@typescript-eslint/scope-manager": "npm:8.24.0" - "@typescript-eslint/types": "npm:8.24.0" - "@typescript-eslint/typescript-estree": "npm:8.24.0" - "@typescript-eslint/visitor-keys": "npm:8.24.0" + "@typescript-eslint/scope-manager": "npm:8.24.1" + "@typescript-eslint/types": "npm:8.24.1" + "@typescript-eslint/typescript-estree": "npm:8.24.1" + "@typescript-eslint/visitor-keys": "npm:8.24.1" debug: "npm:^4.3.4" peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.8.0" - checksum: 10/b5c66a3208c69144cd5d0b7a2c763205ef8ae88eea76067186bab0909aa9756fe015616b98a7f252a5106aa5e86baeb98f9affbdc0f5d19863a2150f2431bfe0 + checksum: 10/9a0f86b140a2c63ff8eca17f40fe315d8a5b7ab51594e2630caff845717aab1c2138edd070e710d7edb0daf685d6bba827e983e8cb076b53d03eda07307b0113 languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/scope-manager@npm:8.24.0" +"@typescript-eslint/scope-manager@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/scope-manager@npm:8.24.1" dependencies: - "@typescript-eslint/types": "npm:8.24.0" - "@typescript-eslint/visitor-keys": "npm:8.24.0" - checksum: 10/175032d4f714d68b734d7281c340e073a37d348010d308b9cccf8d63d745b8cc9515229e32dcd838acf4a85e21a4e8eff6c557c31ba45e36917e3417de32d723 + "@typescript-eslint/types": "npm:8.24.1" + "@typescript-eslint/visitor-keys": "npm:8.24.1" + checksum: 10/ab668c073c51cf801a1f5ef8578d0ae29d778d92b143cb1575bb7a867016f45ef4d044ce374fbe47606391f2d39b6963df725964e90af85bff1c435d8006b535 languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/type-utils@npm:8.24.0" +"@typescript-eslint/type-utils@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/type-utils@npm:8.24.1" dependencies: - "@typescript-eslint/typescript-estree": "npm:8.24.0" - "@typescript-eslint/utils": "npm:8.24.0" + "@typescript-eslint/typescript-estree": "npm:8.24.1" + "@typescript-eslint/utils": "npm:8.24.1" debug: "npm:^4.3.4" ts-api-utils: "npm:^2.0.1" peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.8.0" - checksum: 10/a6558d0b0ab7a43826b481c103c556abbafa93c9941d75d647266dc0f55e68950f44a63842a2e7839a7448329f9b7ee88c84913084438dbac38dba5efbc1afbc + checksum: 10/7161f6218f2f1a100142c50d71d5e470459821e3715a4d6717be3ae4e1ef8aac06c6144f1010690f15c34ee9d8330526324a8133e541aa7382439f180ccb2860 languageName: node linkType: hard -"@typescript-eslint/types@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/types@npm:8.24.0" - checksum: 10/ddaaec99c191830cc29ce289678d44f7201dd06c29540750ca4802b6bd2a6dfd8cc29b46ed270dc0198f23e742540bb1e4fe618b6b44e4e76bad7f774bd3fc4a +"@typescript-eslint/types@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/types@npm:8.24.1" + checksum: 10/f3f624d7494c02a35810988388e2d5cc35ac10860e455148faba0fe332c6b8cf4be0aa0c1e0f0012813e2d6e86c17aadadfd0c7c6e73433c064755df7d81535b languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/typescript-estree@npm:8.24.0" +"@typescript-eslint/typescript-estree@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/typescript-estree@npm:8.24.1" dependencies: - "@typescript-eslint/types": "npm:8.24.0" - "@typescript-eslint/visitor-keys": "npm:8.24.0" + "@typescript-eslint/types": "npm:8.24.1" + "@typescript-eslint/visitor-keys": "npm:8.24.1" debug: "npm:^4.3.4" fast-glob: "npm:^3.3.2" is-glob: "npm:^4.0.3" @@ -5104,32 +5104,32 @@ __metadata: ts-api-utils: "npm:^2.0.1" peerDependencies: typescript: ">=4.8.4 <5.8.0" - checksum: 10/89e451f5d2136b405d046823c93ac7065d90c7a9f084ffb324e374c769b17ee2580d3711ada1e1575331b234059148f173230e560b08efa3073f8f0c04ce1224 + checksum: 10/b0645010607d3469b85479344245ef1fd6bd24804271fb439280167ad87e9f05cdf6a2ba2ccbcdc946c339c323249a86dd1e7ce6e130eb6e73ea619795b76151 languageName: node linkType: hard -"@typescript-eslint/utils@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/utils@npm:8.24.0" +"@typescript-eslint/utils@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/utils@npm:8.24.1" dependencies: "@eslint-community/eslint-utils": "npm:^4.4.0" - "@typescript-eslint/scope-manager": "npm:8.24.0" - "@typescript-eslint/types": "npm:8.24.0" - "@typescript-eslint/typescript-estree": "npm:8.24.0" + "@typescript-eslint/scope-manager": "npm:8.24.1" + "@typescript-eslint/types": "npm:8.24.1" + "@typescript-eslint/typescript-estree": "npm:8.24.1" peerDependencies: eslint: ^8.57.0 || ^9.0.0 typescript: ">=4.8.4 <5.8.0" - checksum: 10/773a4085e45a94f5a64b34550e7d890b5418c69a9dcd58862410e7e0ded46e3380c8dd7d38baafaa93ef40b2a77320092bded3ca36f15b2f7ea6babeb831e590 + checksum: 10/90890afc1de2eaabf94fb80e03713b81e976d927fa998159d132a0cf17c093a1722e27be9a642c5b94104db6dedb86a15addac046853c1f608bdcef27cfb1fd1 languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:8.24.0": - version: 8.24.0 - resolution: "@typescript-eslint/visitor-keys@npm:8.24.0" +"@typescript-eslint/visitor-keys@npm:8.24.1": + version: 8.24.1 + resolution: "@typescript-eslint/visitor-keys@npm:8.24.1" dependencies: - "@typescript-eslint/types": "npm:8.24.0" + "@typescript-eslint/types": "npm:8.24.1" eslint-visitor-keys: "npm:^4.2.0" - checksum: 10/a93bc9e587784cbc47d6849f14581aa3f15574b187a7b98597362acbca43b06c36a6dfa889b5320ced62b182abf0b9759a694489d72fc7902cdea11830a7a535 + checksum: 10/94876bd771e050dadf4af6e2bbb3819d3a14407d69a643153eb56857dae982cd3b68ba644613c433449e305ec0fd6f4aeab573ceb8f8d25fea9c55396153d6b9 languageName: node linkType: hard @@ -9398,8 +9398,6 @@ __metadata: "@types/tar": "npm:6.1.13" "@types/ua-parser-js": "npm:0.7.39" "@types/webspeechapi": "npm:0.0.29" - "@typescript-eslint/eslint-plugin": "npm:8.24.0" - "@typescript-eslint/parser": "npm:8.24.0" "@vaadin/combo-box": "npm:24.6.5" "@vaadin/vaadin-themable-mixin": "npm:24.6.5" "@vibrant/color": "npm:4.0.0" @@ -9487,6 +9485,7 @@ __metadata: tsparticles-engine: "npm:2.12.0" tsparticles-preset-links: "npm:2.12.0" typescript: "npm:5.7.3" + typescript-eslint: "npm:8.24.1" ua-parser-js: "npm:2.0.2" vis-data: "npm:7.1.9" vis-network: "npm:9.1.9" @@ -14685,6 +14684,20 @@ __metadata: languageName: node linkType: hard +"typescript-eslint@npm:8.24.1": + version: 8.24.1 + resolution: "typescript-eslint@npm:8.24.1" + dependencies: + "@typescript-eslint/eslint-plugin": "npm:8.24.1" + "@typescript-eslint/parser": "npm:8.24.1" + "@typescript-eslint/utils": "npm:8.24.1" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <5.8.0" + checksum: 10/c50e555c5a5a42f843d2a7d57315b35749eb05fdf2b264fd8471f8a825a744444fb534c0a6bb3f0086ad3b3dc0ef76da6ac3154a917af81c908016d5874cbbae + languageName: node + linkType: hard + "typescript@npm:5.7.3": version: 5.7.3 resolution: "typescript@npm:5.7.3"