From 8aa0382d1fa938489811b40f8ab2732d34dec247 Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Thu, 7 Nov 2024 11:01:44 -0600 Subject: [PATCH 1/6] fix: broken imports in esm + typescript <5.5 --- src/etc/could-be-function.ts | 2 +- src/etc/could-be-type.ts | 2 +- src/etc/get-loc.ts | 2 +- src/etc/get-type-services.ts | 2 +- src/rules/no-cyclic-action.ts | 2 +- src/rules/no-unsafe-subject-next.ts | 2 +- src/rules/throw-error.ts | 2 +- tests/etc/could-be-type.test.ts | 2 +- tests/etc/create-source-file-and-type-checker.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/etc/could-be-function.ts b/src/etc/could-be-function.ts index 3f66a524..0a5e3c67 100644 --- a/src/etc/could-be-function.ts +++ b/src/etc/could-be-function.ts @@ -1,4 +1,4 @@ -import * as ts from 'typescript'; +import ts from 'typescript'; import { couldBeType } from './could-be-type'; export function couldBeFunction(type: ts.Type): boolean { diff --git a/src/etc/could-be-type.ts b/src/etc/could-be-type.ts index 2e73dab2..b8156cce 100644 --- a/src/etc/could-be-type.ts +++ b/src/etc/could-be-type.ts @@ -1,5 +1,5 @@ import * as tsutils from 'ts-api-utils'; -import * as ts from 'typescript'; +import ts from 'typescript'; export function couldBeType( type: ts.Type, diff --git a/src/etc/get-loc.ts b/src/etc/get-loc.ts index af40b46a..68605a40 100644 --- a/src/etc/get-loc.ts +++ b/src/etc/get-loc.ts @@ -1,5 +1,5 @@ import { TSESTree } from '@typescript-eslint/utils'; -import * as ts from 'typescript'; +import ts from 'typescript'; export function getLoc(node: ts.Node): TSESTree.SourceLocation { const sourceFile = node.getSourceFile(); diff --git a/src/etc/get-type-services.ts b/src/etc/get-type-services.ts index 0c3e7eb8..75f814c8 100644 --- a/src/etc/get-type-services.ts +++ b/src/etc/get-type-services.ts @@ -1,6 +1,6 @@ import { ESLintUtils, TSESLint, TSESTree } from '@typescript-eslint/utils'; import * as tsutils from 'ts-api-utils'; -import * as ts from 'typescript'; +import ts from 'typescript'; import { couldBeFunction } from './could-be-function'; import { couldBeType as tsutilsEtcCouldBeType } from './could-be-type'; import { isArrowFunctionExpression, isFunctionDeclaration } from './is'; diff --git a/src/rules/no-cyclic-action.ts b/src/rules/no-cyclic-action.ts index c9cf6ac7..5df88fa7 100644 --- a/src/rules/no-cyclic-action.ts +++ b/src/rules/no-cyclic-action.ts @@ -1,6 +1,6 @@ import { TSESTree as es } from '@typescript-eslint/utils'; import { stripIndent } from 'common-tags'; -import * as ts from 'typescript'; +import ts from 'typescript'; import { defaultObservable } from '../constants'; import { getTypeServices, isCallExpression, isIdentifier } from '../etc'; import { ruleCreator } from '../utils'; diff --git a/src/rules/no-unsafe-subject-next.ts b/src/rules/no-unsafe-subject-next.ts index 3205a17f..9745179c 100644 --- a/src/rules/no-unsafe-subject-next.ts +++ b/src/rules/no-unsafe-subject-next.ts @@ -1,6 +1,6 @@ import { TSESTree as es } from '@typescript-eslint/utils'; import * as tsutils from 'ts-api-utils'; -import * as ts from 'typescript'; +import ts from 'typescript'; import { couldBeType, getTypeServices, diff --git a/src/rules/throw-error.ts b/src/rules/throw-error.ts index 88094db0..4cd7801f 100644 --- a/src/rules/throw-error.ts +++ b/src/rules/throw-error.ts @@ -1,6 +1,6 @@ import { TSESTree as es, ESLintUtils } from '@typescript-eslint/utils'; import * as tsutils from 'ts-api-utils'; -import * as ts from 'typescript'; +import ts from 'typescript'; import { couldBeFunction, couldBeType, getTypeServices } from '../etc'; import { ruleCreator } from '../utils'; diff --git a/tests/etc/could-be-type.test.ts b/tests/etc/could-be-type.test.ts index 3b24f698..0b964f43 100644 --- a/tests/etc/could-be-type.test.ts +++ b/tests/etc/could-be-type.test.ts @@ -1,4 +1,4 @@ -import * as ts from 'typescript'; +import ts from 'typescript'; import { couldBeType } from '../../src/etc/could-be-type'; import { createSourceFileAndTypeChecker } from './create-source-file-and-type-checker'; diff --git a/tests/etc/create-source-file-and-type-checker.ts b/tests/etc/create-source-file-and-type-checker.ts index 3b2d8063..6d7ae5a1 100644 --- a/tests/etc/create-source-file-and-type-checker.ts +++ b/tests/etc/create-source-file-and-type-checker.ts @@ -1,5 +1,5 @@ import * as tsvfs from '@typescript/vfs'; -import * as ts from 'typescript'; +import ts from 'typescript'; interface SourceFileAndTypeChecker { sourceFile: ts.SourceFile; From 70379a43c3c016178458d6d8684e231ece7cfc19 Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Thu, 7 Nov 2024 11:02:13 -0600 Subject: [PATCH 2/6] fix(deps): align typescript version with typescript-estree --- package.json | 4 ++-- yarn.lock | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index bcf3a5a2..bf10184d 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "rxjs": ">=7.0.0", - "typescript": ">=4.2.0" + "typescript": ">=4.7.4" }, "devDependencies": { "@eslint/js": "^9.14.0", @@ -86,7 +86,7 @@ "rxjs": "^7.0.0", "tsup": "^8.3.5", "tsx": "^4.19.2", - "typescript": "~5.6.3", + "typescript": "~5.5.4", "typescript-eslint": "^8.13.0", "vitest": "^2.1.4" }, diff --git a/yarn.lock b/yarn.lock index 581422ba..a19c7941 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2437,13 +2437,13 @@ __metadata: tslib: "npm:^2.1.0" tsup: "npm:^8.3.5" tsx: "npm:^4.19.2" - typescript: "npm:~5.6.3" + typescript: "npm:~5.0" typescript-eslint: "npm:^8.13.0" vitest: "npm:^2.1.4" peerDependencies: eslint: ^8.57.0 || ^9.0.0 rxjs: ">=7.0.0" - typescript: ">=4.2.0" + typescript: ">=4.7.4" languageName: unknown linkType: soft @@ -4770,23 +4770,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.6.3": - version: 5.6.3 - resolution: "typescript@npm:5.6.3" +"typescript@npm:~5.0": + version: 5.0.4 + resolution: "typescript@npm:5.0.4" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/44f61d3fb15c35359bc60399cb8127c30bae554cd555b8e2b46d68fa79d680354b83320ad419ff1b81a0bdf324197b29affe6cc28988cd6a74d4ac60c94f9799 + checksum: 10c0/2f5bd1cead194905957cb34e220b1d6ff1662399adef8ec1864f74620922d860ee35b6e50eafb3b636ea6fd437195e454e1146cb630a4236b5095ed7617395c2 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A~5.6.3#optional!builtin": - version: 5.6.3 - resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40" +"typescript@patch:typescript@npm%3A~5.0#optional!builtin": + version: 5.0.4 + resolution: "typescript@patch:typescript@npm%3A5.0.4#optional!builtin::version=5.0.4&hash=b5f058" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/7c9d2e07c81226d60435939618c91ec2ff0b75fbfa106eec3430f0fcf93a584bc6c73176676f532d78c3594fe28a54b36eb40b3d75593071a7ec91301533ace7 + checksum: 10c0/c3f7b80577bddf6fab202a7925131ac733bfc414aec298c2404afcddc7a6f242cfa8395cf2d48192265052e11a7577c27f6e5fac8d8fe6a6602023c83d6b3292 languageName: node linkType: hard From ecf7bb0c01036b9046db9bd64296c916c133f1c4 Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Thu, 7 Nov 2024 11:03:55 -0600 Subject: [PATCH 3/6] docs: update changelog for fix --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2447dfe0..4630548c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ # Changelog +## Unreleased + +- Fixed broken imports in ESM configs using typescript versions lower than 5.5. + ## v0.2.1 -- Decrease minimum `typescript-eslint` version to ^8.1.0 (matches import-x plugin). +- Decreased minimum `typescript-eslint` version to ^8.1.0 (matches import-x plugin). ## v0.2.0 From 5d6d3b2c2cbd1e18257c0390f766661679628d66 Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Thu, 7 Nov 2024 11:34:11 -0600 Subject: [PATCH 4/6] chore: update lock file --- yarn.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index a19c7941..6221caff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2437,7 +2437,7 @@ __metadata: tslib: "npm:^2.1.0" tsup: "npm:^8.3.5" tsx: "npm:^4.19.2" - typescript: "npm:~5.0" + typescript: "npm:~5.5.4" typescript-eslint: "npm:^8.13.0" vitest: "npm:^2.1.4" peerDependencies: @@ -4770,23 +4770,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.0": - version: 5.0.4 - resolution: "typescript@npm:5.0.4" +"typescript@npm:~5.5.4": + version: 5.5.4 + resolution: "typescript@npm:5.5.4" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/2f5bd1cead194905957cb34e220b1d6ff1662399adef8ec1864f74620922d860ee35b6e50eafb3b636ea6fd437195e454e1146cb630a4236b5095ed7617395c2 + checksum: 10c0/422be60f89e661eab29ac488c974b6cc0a660fb2228003b297c3d10c32c90f3bcffc1009b43876a082515a3c376b1eefcce823d6e78982e6878408b9a923199c languageName: node linkType: hard -"typescript@patch:typescript@npm%3A~5.0#optional!builtin": - version: 5.0.4 - resolution: "typescript@patch:typescript@npm%3A5.0.4#optional!builtin::version=5.0.4&hash=b5f058" +"typescript@patch:typescript@npm%3A~5.5.4#optional!builtin": + version: 5.5.4 + resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin::version=5.5.4&hash=379a07" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/c3f7b80577bddf6fab202a7925131ac733bfc414aec298c2404afcddc7a6f242cfa8395cf2d48192265052e11a7577c27f6e5fac8d8fe6a6602023c83d6b3292 + checksum: 10c0/73409d7b9196a5a1217b3aaad929bf76294d3ce7d6e9766dd880ece296ee91cf7d7db6b16c6c6c630ee5096eccde726c0ef17c7dfa52b01a243e57ae1f09ef07 languageName: node linkType: hard From 99b89988dab62b1d346b8e44fac27aa0e38a9511 Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Thu, 7 Nov 2024 11:34:31 -0600 Subject: [PATCH 5/6] chore(lint): ignore default member lint warnings --- eslint.config.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index d8a05a9c..3eec6b1d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -63,6 +63,8 @@ export default tseslint.config(gitignore(), { }, ], + 'import-x/no-named-as-default-member': 'off', + 'n/no-missing-import': 'off', 'eslint-plugin/require-meta-docs-description': [ From 9bf6e82381a23adf4c3d91601c33a63e1465f3b3 Mon Sep 17 00:00:00 2001 From: Jason Weinzierl Date: Thu, 7 Nov 2024 11:40:57 -0600 Subject: [PATCH 6/6] chore(deps-dev): ts 5.6 is ok with tseslint v8 It was just tseslint v7 that doesn't like ts 5.6. --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index bf10184d..ea2f9dc9 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "rxjs": "^7.0.0", "tsup": "^8.3.5", "tsx": "^4.19.2", - "typescript": "~5.5.4", + "typescript": "~5.6.3", "typescript-eslint": "^8.13.0", "vitest": "^2.1.4" }, diff --git a/yarn.lock b/yarn.lock index 6221caff..ff11d1ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2437,7 +2437,7 @@ __metadata: tslib: "npm:^2.1.0" tsup: "npm:^8.3.5" tsx: "npm:^4.19.2" - typescript: "npm:~5.5.4" + typescript: "npm:~5.6.3" typescript-eslint: "npm:^8.13.0" vitest: "npm:^2.1.4" peerDependencies: @@ -4770,23 +4770,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.5.4": - version: 5.5.4 - resolution: "typescript@npm:5.5.4" +"typescript@npm:~5.6.3": + version: 5.6.3 + resolution: "typescript@npm:5.6.3" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/422be60f89e661eab29ac488c974b6cc0a660fb2228003b297c3d10c32c90f3bcffc1009b43876a082515a3c376b1eefcce823d6e78982e6878408b9a923199c + checksum: 10c0/44f61d3fb15c35359bc60399cb8127c30bae554cd555b8e2b46d68fa79d680354b83320ad419ff1b81a0bdf324197b29affe6cc28988cd6a74d4ac60c94f9799 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A~5.5.4#optional!builtin": - version: 5.5.4 - resolution: "typescript@patch:typescript@npm%3A5.5.4#optional!builtin::version=5.5.4&hash=379a07" +"typescript@patch:typescript@npm%3A~5.6.3#optional!builtin": + version: 5.6.3 + resolution: "typescript@patch:typescript@npm%3A5.6.3#optional!builtin::version=5.6.3&hash=8c6c40" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/73409d7b9196a5a1217b3aaad929bf76294d3ce7d6e9766dd880ece296ee91cf7d7db6b16c6c6c630ee5096eccde726c0ef17c7dfa52b01a243e57ae1f09ef07 + checksum: 10c0/7c9d2e07c81226d60435939618c91ec2ff0b75fbfa106eec3430f0fcf93a584bc6c73176676f532d78c3594fe28a54b36eb40b3d75593071a7ec91301533ace7 languageName: node linkType: hard