diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 8890046..05dd246 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -59,7 +59,9 @@ "@eslint/compat": "^1.2.5", "@eslint/js": "^9.18.0", "@stylistic/eslint-plugin": "^2.13.0", + "@typescript-eslint/parser": "^8.21.0", "eslint": "^9.18.0", + "eslint-import-resolver-typescript": "^3.7.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-tsdoc": "^0.4.0", "globals": "^15.14.0", diff --git a/packages/eslint-config/src/lib/typescript-config.ts b/packages/eslint-config/src/lib/typescript-config.ts index 4901245..45291a7 100644 --- a/packages/eslint-config/src/lib/typescript-config.ts +++ b/packages/eslint-config/src/lib/typescript-config.ts @@ -1,4 +1,7 @@ import * as globals from 'globals'; +import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'; +// @ts-expect-error - don't have types +import importPlugin from 'eslint-plugin-import'; import stylistic from '@stylistic/eslint-plugin'; import tsdocPlugin from 'eslint-plugin-tsdoc'; import tseslint from 'typescript-eslint'; @@ -6,7 +9,7 @@ import tseslint from 'typescript-eslint'; const tsconfigRootDir = import.meta.dirname; export const tsConfig = tseslint.config({ - files: [ '**/*.ts', '**/*.mjs', '**/*.cjs', '**/*.js' ], + files: [ '**/*.{ts,js,cjs,mjs}' ], languageOptions: { globals: { ...globals['shared-node-browser'], @@ -19,6 +22,8 @@ export const tsConfig = tseslint.config({ tsconfigRootDir, }, }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + extends: [ (importPlugin as any).flatConfigs.recommended, (importPlugin as any).flatConfigs.typescript ], plugins: { '@typescript-eslint': tseslint.plugin, '@stylistic': stylistic, @@ -64,7 +69,7 @@ export const tsConfig = tseslint.config({ 'no-unused-vars': 'off', 'prefer-const': 'error', - 'sort-imports': [ 'error' ], + // 'sort-imports': 'error', '@typescript-eslint/prefer-string-starts-ends-with': 'off', '@typescript-eslint/no-dynamic-delete': 'off', @@ -73,4 +78,13 @@ export const tsConfig = tseslint.config({ 'require-await': 'error', '@typescript-eslint/consistent-type-definitions': 'off', }, + settings: { + 'import/resolver': { + typescript: { + alwaysTryTypes: true, + project: [ tsconfigRootDir ], + }, + node: {}, + }, + }, }); diff --git a/yarn.lock b/yarn.lock index b081a17..863ab89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3003,7 +3003,9 @@ __metadata: "@stylistic/eslint-plugin": "npm:^2.13.0" "@types/eslint": "npm:^9.6.1" "@types/node": "npm:^22.10.7" + "@typescript-eslint/parser": "npm:^8.21.0" eslint: "npm:^9.18.0" + eslint-import-resolver-typescript: "npm:^3.7.0" eslint-plugin-import: "npm:^2.31.0" eslint-plugin-tsdoc: "npm:^0.4.0" globals: "npm:^15.14.0" @@ -3117,6 +3119,13 @@ __metadata: languageName: node linkType: hard +"@nolyfill/is-core-module@npm:1.0.39": + version: 1.0.39 + resolution: "@nolyfill/is-core-module@npm:1.0.39" + checksum: 10c0/34ab85fdc2e0250879518841f74a30c276bca4f6c3e13526d2d1fe515e1adf6d46c25fcd5989d22ea056d76f7c39210945180b4859fc83b050e2da411aa86289 + languageName: node + linkType: hard + "@npmcli/agent@npm:^2.0.0": version: 2.2.2 resolution: "@npmcli/agent@npm:2.2.2" @@ -4052,7 +4061,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/parser@npm:8.21.0": +"@typescript-eslint/parser@npm:8.21.0, @typescript-eslint/parser@npm:^8.21.0": version: 8.21.0 resolution: "@typescript-eslint/parser@npm:8.21.0" dependencies: @@ -6097,6 +6106,16 @@ __metadata: languageName: node linkType: hard +"enhanced-resolve@npm:^5.15.0": + version: 5.18.0 + resolution: "enhanced-resolve@npm:5.18.0" + dependencies: + graceful-fs: "npm:^4.2.4" + tapable: "npm:^2.2.0" + checksum: 10c0/5fcc264a6040754ab5b349628cac2bb5f89cee475cbe340804e657a5b9565f70e6aafb338d5895554eb0ced9f66c50f38a255274a0591dcb64ee17c549c459ce + languageName: node + linkType: hard + "entities@npm:^2.0.0": version: 2.2.0 resolution: "entities@npm:2.2.0" @@ -6471,6 +6490,31 @@ __metadata: languageName: node linkType: hard +"eslint-import-resolver-typescript@npm:^3.7.0": + version: 3.7.0 + resolution: "eslint-import-resolver-typescript@npm:3.7.0" + dependencies: + "@nolyfill/is-core-module": "npm:1.0.39" + debug: "npm:^4.3.7" + enhanced-resolve: "npm:^5.15.0" + fast-glob: "npm:^3.3.2" + get-tsconfig: "npm:^4.7.5" + is-bun-module: "npm:^1.0.2" + is-glob: "npm:^4.0.3" + stable-hash: "npm:^0.0.4" + peerDependencies: + eslint: "*" + eslint-plugin-import: "*" + eslint-plugin-import-x: "*" + peerDependenciesMeta: + eslint-plugin-import: + optional: true + eslint-plugin-import-x: + optional: true + checksum: 10c0/b1dec542a31486b3b5730f71f08a8ee2ac4915dbc4aa1493fd15bc8fcadcb029772ab39a425824c235045b3a7e629290a339d4a7e7f3dd32b24e715106352d40 + languageName: node + linkType: hard + "eslint-module-utils@npm:^2.12.0": version: 2.12.0 resolution: "eslint-module-utils@npm:2.12.0" @@ -7168,6 +7212,15 @@ __metadata: languageName: node linkType: hard +"get-tsconfig@npm:^4.7.5": + version: 4.10.0 + resolution: "get-tsconfig@npm:4.10.0" + dependencies: + resolve-pkg-maps: "npm:^1.0.0" + checksum: 10c0/c9b5572c5118923c491c04285c73bd55b19e214992af957c502a3be0fc0043bb421386ffd45ca3433c0a7fba81221ca300479e8393960acf15d0ed4563f38a86 + languageName: node + linkType: hard + "git-hooks-list@npm:^3.0.0": version: 3.1.0 resolution: "git-hooks-list@npm:3.1.0" @@ -7735,6 +7788,15 @@ __metadata: languageName: node linkType: hard +"is-bun-module@npm:^1.0.2": + version: 1.3.0 + resolution: "is-bun-module@npm:1.3.0" + dependencies: + semver: "npm:^7.6.3" + checksum: 10c0/2966744188fcd28e0123c52158c7073973f88babfa9ab04e2846ec5862d6b0f8f398df6413429d930f7c5ee6111ce2cbfb3eb8652d9ec42d4a37dc5089a866fb + languageName: node + linkType: hard + "is-callable@npm:^1.1.3, is-callable@npm:^1.2.7": version: 1.2.7 resolution: "is-callable@npm:1.2.7" @@ -11219,6 +11281,13 @@ __metadata: languageName: node linkType: hard +"resolve-pkg-maps@npm:^1.0.0": + version: 1.0.0 + resolution: "resolve-pkg-maps@npm:1.0.0" + checksum: 10c0/fb8f7bbe2ca281a73b7ef423a1cbc786fb244bd7a95cbe5c3fba25b27d327150beca8ba02f622baea65919a57e061eb5005204daa5f93ed590d9b77463a567ab + languageName: node + linkType: hard + "resolve@npm:^1.1.7, resolve@npm:^1.14.2, resolve@npm:^1.22.1, resolve@npm:^1.22.4, resolve@npm:^1.22.8, resolve@npm:~1.22.2": version: 1.22.10 resolution: "resolve@npm:1.22.10" @@ -11799,6 +11868,13 @@ __metadata: languageName: node linkType: hard +"stable-hash@npm:^0.0.4": + version: 0.0.4 + resolution: "stable-hash@npm:0.0.4" + checksum: 10c0/53d010d2a1b014fb60d398c095f43912c353b7b44774e55222bb26fd428bc75b73d7bdfcae509ce927c23ca9c5aff2dc1bc82f191d30e57a879550bc2952bdb0 + languageName: node + linkType: hard + "stack-utils@npm:^2.0.6": version: 2.0.6 resolution: "stack-utils@npm:2.0.6" @@ -12118,6 +12194,13 @@ __metadata: languageName: node linkType: hard +"tapable@npm:^2.2.0": + version: 2.2.1 + resolution: "tapable@npm:2.2.1" + checksum: 10c0/bc40e6efe1e554d075469cedaba69a30eeb373552aaf41caeaaa45bf56ffacc2674261b106245bd566b35d8f3329b52d838e851ee0a852120acae26e622925c9 + languageName: node + linkType: hard + "tar@npm:^6.1.11, tar@npm:^6.2.1": version: 6.2.1 resolution: "tar@npm:6.2.1"