From 4ba812665525b659e944a76f6db100216dd2a31d Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Mon, 23 Sep 2024 11:58:20 +0200 Subject: [PATCH] Fix lint errors --- eslint.config.mjs | 10 ++++++++++ package.json | 1 + packages/base/src/index.d.mts | 2 +- packages/browser/src/index.d.mts | 2 +- packages/commonjs/src/index.d.mts | 2 +- packages/jest/src/index.d.mts | 2 +- packages/mocha/src/index.d.mts | 2 +- packages/nodejs/src/index.d.mts | 2 +- packages/typescript/src/index.d.mts | 2 +- tsconfig.json | 4 +--- yarn.lock | 3 ++- 11 files changed, 21 insertions(+), 11 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index b7a0753c..a2ece714 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -6,6 +6,7 @@ import base from '@metamask/eslint-config'; // eslint-disable-next-line no-shadow import jest from '@metamask/eslint-config-jest'; import nodejs from '@metamask/eslint-config-nodejs'; +import typescript from '@metamask/eslint-config-typescript'; /** * @type {import('eslint').Linter.Config[]} @@ -19,8 +20,17 @@ const config = [ ...nodejs, ...jest, + // This is the recommended way to apply a config array to a subset of files: + // https://eslint.org/docs/latest/use/configure/combine-configs#apply-a-config-array-to-a-subset-of-files + ...typescript.map((typeScriptConfig) => ({ + files: ['**/*.d.mts'], + ...typeScriptConfig, + })), + { name: 'main', + files: ['**/*.js', '**/*.mjs'], + languageOptions: { ecmaVersion: 2022, diff --git a/package.json b/package.json index 4c0dfba6..0d63fea3 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@metamask/eslint-config": "^13.0.0", "@metamask/eslint-config-jest": "workspace:^", "@metamask/eslint-config-nodejs": "^13.0.0", + "@metamask/eslint-config-typescript": "workspace:^", "@metamask/utils": "^9.1.0", "@types/eslint__js": "^8.42.3", "@types/jest": "^29.5.12", diff --git a/packages/base/src/index.d.mts b/packages/base/src/index.d.mts index 8704c152..3f913173 100644 --- a/packages/base/src/index.d.mts +++ b/packages/base/src/index.d.mts @@ -1,5 +1,5 @@ declare module '@metamask/eslint-config' { - import { Linter } from 'eslint'; + import type { Linter } from 'eslint'; const config: Linter.Config[]; export default config; diff --git a/packages/browser/src/index.d.mts b/packages/browser/src/index.d.mts index 24f348fe..cbc219dd 100644 --- a/packages/browser/src/index.d.mts +++ b/packages/browser/src/index.d.mts @@ -1,5 +1,5 @@ declare module '@metamask/eslint-config-browser' { - import { Linter } from 'eslint'; + import type { Linter } from 'eslint'; const config: Linter.Config[]; export default config; diff --git a/packages/commonjs/src/index.d.mts b/packages/commonjs/src/index.d.mts index f97dcb50..c4e7cdec 100644 --- a/packages/commonjs/src/index.d.mts +++ b/packages/commonjs/src/index.d.mts @@ -1,5 +1,5 @@ declare module '@metamask/eslint-config-commonjs' { - import { Linter } from 'eslint'; + import type { Linter } from 'eslint'; const config: Linter.Config[]; export default config; diff --git a/packages/jest/src/index.d.mts b/packages/jest/src/index.d.mts index 2cc70c64..8bfa0f5c 100644 --- a/packages/jest/src/index.d.mts +++ b/packages/jest/src/index.d.mts @@ -1,5 +1,5 @@ declare module '@metamask/eslint-config-jest' { - import { Linter } from 'eslint'; + import type { Linter } from 'eslint'; const config: Linter.Config[]; export default config; diff --git a/packages/mocha/src/index.d.mts b/packages/mocha/src/index.d.mts index 5425596f..3f4c136d 100644 --- a/packages/mocha/src/index.d.mts +++ b/packages/mocha/src/index.d.mts @@ -1,5 +1,5 @@ declare module '@metamask/eslint-config-mocha' { - import { Linter } from 'eslint'; + import type { Linter } from 'eslint'; const config: Linter.Config[]; export default config; diff --git a/packages/nodejs/src/index.d.mts b/packages/nodejs/src/index.d.mts index a2b4e72f..aaddc196 100644 --- a/packages/nodejs/src/index.d.mts +++ b/packages/nodejs/src/index.d.mts @@ -1,5 +1,5 @@ declare module '@metamask/eslint-config-nodejs' { - import { Linter } from 'eslint'; + import type { Linter } from 'eslint'; const config: Linter.Config[]; export default config; diff --git a/packages/typescript/src/index.d.mts b/packages/typescript/src/index.d.mts index e6d0da6a..db16262b 100644 --- a/packages/typescript/src/index.d.mts +++ b/packages/typescript/src/index.d.mts @@ -1,5 +1,5 @@ declare module '@metamask/eslint-config-typescript' { - import { Linter } from 'eslint'; + import type { Linter } from 'eslint'; const config: Linter.Config[]; export default config; diff --git a/tsconfig.json b/tsconfig.json index 505bcaac..11ae8484 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,6 @@ "strict": true, "target": "ES2022" }, - "include": [ - "**/*.mjs", - ], + "include": ["**/*.mjs", "**/*.mts"], "exclude": ["./dist", "**/node_modules"] } diff --git a/yarn.lock b/yarn.lock index 31397854..8424a240 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1003,7 +1003,7 @@ __metadata: languageName: unknown linkType: soft -"@metamask/eslint-config-typescript@workspace:packages/typescript": +"@metamask/eslint-config-typescript@workspace:^, @metamask/eslint-config-typescript@workspace:packages/typescript": version: 0.0.0-use.local resolution: "@metamask/eslint-config-typescript@workspace:packages/typescript" dependencies: @@ -5096,6 +5096,7 @@ __metadata: "@metamask/eslint-config": ^13.0.0 "@metamask/eslint-config-jest": "workspace:^" "@metamask/eslint-config-nodejs": ^13.0.0 + "@metamask/eslint-config-typescript": "workspace:^" "@metamask/utils": ^9.1.0 "@types/eslint__js": ^8.42.3 "@types/jest": ^29.5.12