From 9ab05682b7a9685b7088335697608bd2da33e171 Mon Sep 17 00:00:00 2001 From: James Henry Date: Tue, 15 Jul 2025 15:27:59 +0400 Subject: [PATCH 1/5] chore: update to nx 21.2.3 (#11400) --- .gitignore | 5 ++ .vscode/settings.json | 1 + package.json | 10 +-- yarn.lock | 145 +++++++++++++++++++++--------------------- 4 files changed, 84 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index bf83f8f9300a..94d644e2544a 100644 --- a/.gitignore +++ b/.gitignore @@ -96,3 +96,8 @@ packages/**/.yarn # Vitest type tests tsconfig*.vitest-temp.json + +# Leave these AI agent files up to individual contributors for now +.cursor/mcp.json +.cursor/rules/nx-rules.mdc +.github/instructions/nx.instructions.md diff --git a/.vscode/settings.json b/.vscode/settings.json index 896fbaebbb3a..23eb7b35f04c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -34,4 +34,5 @@ "extends": "jest_snapshot" }, ], + "nxConsole.generateAiAgentRules": true, } diff --git a/package.json b/package.json index 866837f95da8..33567c469efa 100644 --- a/package.json +++ b/package.json @@ -54,10 +54,10 @@ "@eslint/compat": "^1.2.4", "@eslint/eslintrc": "^3.2.0", "@eslint/js": "^9.26.0", - "@nx/devkit": "21.0.3", - "@nx/js": "21.0.3", - "@nx/vite": "21.0.3", - "@nx/workspace": "21.0.3", + "@nx/devkit": "21.2.3", + "@nx/js": "21.2.3", + "@nx/vite": "21.2.3", + "@nx/workspace": "21.2.3", "@swc/core": "^1.4.12", "@types/debug": "^4.1.12", "@types/eslint-plugin-jsx-a11y": "^6.10.0", @@ -93,7 +93,7 @@ "knip": "^5.41.1", "lint-staged": "^15.2.2", "markdownlint-cli": "^0.44.0", - "nx": "21.0.3", + "nx": "21.2.3", "prettier": "3.5.0", "rimraf": "^5.0.5", "semver": "7.7.0", diff --git a/yarn.lock b/yarn.lock index 5cfb0b47eb02..4b24883fa03d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4352,9 +4352,9 @@ __metadata: languageName: node linkType: hard -"@nx/devkit@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/devkit@npm:21.0.3" +"@nx/devkit@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/devkit@npm:21.2.3" dependencies: ejs: ^3.1.7 enquirer: ~2.3.6 @@ -4365,14 +4365,14 @@ __metadata: tslib: ^2.3.0 yargs-parser: 21.1.1 peerDependencies: - nx: 21.0.3 - checksum: a742dce7d5103b585d0cb13fc2cf11fb41ad5b031b5bb2ff6c7a6f0c837a287123866a0809d411974e4f03a41b057b14b46c8b226231755563267f6a46d3c611 + nx: 21.2.3 + checksum: 3db18a83a29d5577e89266880d6449d9e1677512adc47bdf0a2fd4448809247a964658555a809ca8f8c3197560e5f08ae3cf12244b9b87329cea6399406ca25a languageName: node linkType: hard -"@nx/js@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/js@npm:21.0.3" +"@nx/js@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/js@npm:21.2.3" dependencies: "@babel/core": ^7.23.2 "@babel/plugin-proposal-decorators": ^7.22.7 @@ -4381,8 +4381,8 @@ __metadata: "@babel/preset-env": ^7.23.2 "@babel/preset-typescript": ^7.22.5 "@babel/runtime": ^7.22.6 - "@nx/devkit": 21.0.3 - "@nx/workspace": 21.0.3 + "@nx/devkit": 21.2.3 + "@nx/workspace": 21.2.3 "@zkochan/js-yaml": 0.0.7 babel-plugin-const-enum: ^1.0.1 babel-plugin-macros: ^3.1.0 @@ -4408,88 +4408,89 @@ __metadata: peerDependenciesMeta: verdaccio: optional: true - checksum: 97af3d23ef58484011ba7e0667656c4ab15e38935176d29310c926ba42d3b78aa50724ae293c15e2f565a9752bcbee3b4007197e778d43a33329d8bd38773bb7 + checksum: d2a79a4ca57bd6251362c8853dddc52f6ea51b7da96913611f73ae44e24d562d9f9d8afa002822932d3e246b605f69e363c5c22db8962d14d5e210eae84a9693 languageName: node linkType: hard -"@nx/nx-darwin-arm64@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-darwin-arm64@npm:21.0.3" +"@nx/nx-darwin-arm64@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-darwin-arm64@npm:21.2.3" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@nx/nx-darwin-x64@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-darwin-x64@npm:21.0.3" +"@nx/nx-darwin-x64@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-darwin-x64@npm:21.2.3" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@nx/nx-freebsd-x64@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-freebsd-x64@npm:21.0.3" +"@nx/nx-freebsd-x64@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-freebsd-x64@npm:21.2.3" conditions: os=freebsd & cpu=x64 languageName: node linkType: hard -"@nx/nx-linux-arm-gnueabihf@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-linux-arm-gnueabihf@npm:21.0.3" +"@nx/nx-linux-arm-gnueabihf@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-linux-arm-gnueabihf@npm:21.2.3" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@nx/nx-linux-arm64-gnu@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-linux-arm64-gnu@npm:21.0.3" +"@nx/nx-linux-arm64-gnu@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-linux-arm64-gnu@npm:21.2.3" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@nx/nx-linux-arm64-musl@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-linux-arm64-musl@npm:21.0.3" +"@nx/nx-linux-arm64-musl@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-linux-arm64-musl@npm:21.2.3" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@nx/nx-linux-x64-gnu@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-linux-x64-gnu@npm:21.0.3" +"@nx/nx-linux-x64-gnu@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-linux-x64-gnu@npm:21.2.3" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@nx/nx-linux-x64-musl@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-linux-x64-musl@npm:21.0.3" +"@nx/nx-linux-x64-musl@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-linux-x64-musl@npm:21.2.3" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@nx/nx-win32-arm64-msvc@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-win32-arm64-msvc@npm:21.0.3" +"@nx/nx-win32-arm64-msvc@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-win32-arm64-msvc@npm:21.2.3" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@nx/nx-win32-x64-msvc@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/nx-win32-x64-msvc@npm:21.0.3" +"@nx/nx-win32-x64-msvc@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/nx-win32-x64-msvc@npm:21.2.3" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"@nx/vite@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/vite@npm:21.0.3" +"@nx/vite@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/vite@npm:21.2.3" dependencies: - "@nx/devkit": 21.0.3 - "@nx/js": 21.0.3 + "@nx/devkit": 21.2.3 + "@nx/js": 21.2.3 "@phenomnomnominal/tsquery": ~5.0.1 "@swc/helpers": ~0.5.0 + ajv: ^8.0.0 enquirer: ~2.3.6 picomatch: 4.0.2 semver: ^7.6.3 @@ -4497,23 +4498,23 @@ __metadata: peerDependencies: vite: ^5.0.0 || ^6.0.0 vitest: ^1.3.1 || ^2.0.0 || ^3.0.0 - checksum: 4195276b94cfd310650d5fd68172e00a025b2df75424f1e930923a8703178bc8c1887d3d3854cd4cad2b5b15d70ed4331b9f2aadfba1d172f2d33bc49f098e36 + checksum: cc274da699980816d52927ac037e9f206978853fc4d97c98a08eef8ae542b8ec392e19cf39a2c66889da392853d1553f2179dd8fb223833b3729dcfd8cd68e75 languageName: node linkType: hard -"@nx/workspace@npm:21.0.3": - version: 21.0.3 - resolution: "@nx/workspace@npm:21.0.3" +"@nx/workspace@npm:21.2.3": + version: 21.2.3 + resolution: "@nx/workspace@npm:21.2.3" dependencies: - "@nx/devkit": 21.0.3 + "@nx/devkit": 21.2.3 "@zkochan/js-yaml": 0.0.7 chalk: ^4.1.0 enquirer: ~2.3.6 - nx: 21.0.3 + nx: 21.2.3 picomatch: 4.0.2 tslib: ^2.3.0 yargs-parser: 21.1.1 - checksum: 20c4051faa3a61c28acd8578b04afb4e991da23b382ff8e70aa907d88ea2f553e4b39759a21da893fdf36814ce809a1dce97fc95683576cfb37bf7278f38efc9 + checksum: 6381eb146a0b9b4786452161f7179fcb5f1301b2aa0608ab522b02a0a8e73cdf80097ba68f454dbea94aae31c3b2eb7b23572152fb6cfb6df31b1d6f5a42b4f2 languageName: node linkType: hard @@ -6154,10 +6155,10 @@ __metadata: "@eslint/compat": ^1.2.4 "@eslint/eslintrc": ^3.2.0 "@eslint/js": ^9.26.0 - "@nx/devkit": 21.0.3 - "@nx/js": 21.0.3 - "@nx/vite": 21.0.3 - "@nx/workspace": 21.0.3 + "@nx/devkit": 21.2.3 + "@nx/js": 21.2.3 + "@nx/vite": 21.2.3 + "@nx/workspace": 21.2.3 "@swc/core": ^1.4.12 "@types/debug": ^4.1.12 "@types/eslint-plugin-jsx-a11y": ^6.10.0 @@ -6193,7 +6194,7 @@ __metadata: knip: ^5.41.1 lint-staged: ^15.2.2 markdownlint-cli: ^0.44.0 - nx: 21.0.3 + nx: 21.2.3 prettier: 3.5.0 rimraf: ^5.0.5 semver: 7.7.0 @@ -15289,21 +15290,21 @@ __metadata: languageName: node linkType: hard -"nx@npm:21.0.3": - version: 21.0.3 - resolution: "nx@npm:21.0.3" +"nx@npm:21.2.3": + version: 21.2.3 + resolution: "nx@npm:21.2.3" dependencies: "@napi-rs/wasm-runtime": 0.2.4 - "@nx/nx-darwin-arm64": 21.0.3 - "@nx/nx-darwin-x64": 21.0.3 - "@nx/nx-freebsd-x64": 21.0.3 - "@nx/nx-linux-arm-gnueabihf": 21.0.3 - "@nx/nx-linux-arm64-gnu": 21.0.3 - "@nx/nx-linux-arm64-musl": 21.0.3 - "@nx/nx-linux-x64-gnu": 21.0.3 - "@nx/nx-linux-x64-musl": 21.0.3 - "@nx/nx-win32-arm64-msvc": 21.0.3 - "@nx/nx-win32-x64-msvc": 21.0.3 + "@nx/nx-darwin-arm64": 21.2.3 + "@nx/nx-darwin-x64": 21.2.3 + "@nx/nx-freebsd-x64": 21.2.3 + "@nx/nx-linux-arm-gnueabihf": 21.2.3 + "@nx/nx-linux-arm64-gnu": 21.2.3 + "@nx/nx-linux-arm64-musl": 21.2.3 + "@nx/nx-linux-x64-gnu": 21.2.3 + "@nx/nx-linux-x64-musl": 21.2.3 + "@nx/nx-win32-arm64-msvc": 21.2.3 + "@nx/nx-win32-x64-msvc": 21.2.3 "@yarnpkg/lockfile": ^1.1.0 "@yarnpkg/parsers": 3.0.2 "@zkochan/js-yaml": 0.0.7 @@ -15370,7 +15371,7 @@ __metadata: bin: nx: bin/nx.js nx-cloud: bin/nx-cloud.js - checksum: 9b3ae238d5df6265bff3430e4e0680762fc3236fb2cd3aed4d3177f64f12586fa19aa8dc4f60f9f5674fb035c46dcf6e0dcad3744d717e84f4a70775aaa10d1b + checksum: faaef03d763f6da739f8108c3f8fe4ad5dd30926d15b279508266e8a272164b5d53598fb3ff5b636ee665bb8e9782ccc2a3134cb6c977b577c5c16d5f20722bd languageName: node linkType: hard From 3f58afe010b150a51ca7bcda023c82a50026ea59 Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Tue, 15 Jul 2025 07:23:01 -0500 Subject: [PATCH 2/5] chore(tsconfig-utils): sync `vitest` config with latest setup (#11239) * chore(`tsconfig-utils`): sync `vitest` config with latest setup * revert dependency changes --------- Co-authored-by: Kirk Waiblinger <53019676+kirkwaiblinger@users.noreply.github.com> --- .../{lib => }/getParsedConfigFile.test.ts | 22 +++++++++---------- packages/tsconfig-utils/tsconfig.build.json | 13 ++--------- packages/tsconfig-utils/tsconfig.spec.json | 14 +----------- packages/tsconfig-utils/vitest.config.mts | 5 ----- 4 files changed, 14 insertions(+), 40 deletions(-) rename packages/tsconfig-utils/tests/{lib => }/getParsedConfigFile.test.ts (88%) diff --git a/packages/tsconfig-utils/tests/lib/getParsedConfigFile.test.ts b/packages/tsconfig-utils/tests/getParsedConfigFile.test.ts similarity index 88% rename from packages/tsconfig-utils/tests/lib/getParsedConfigFile.test.ts rename to packages/tsconfig-utils/tests/getParsedConfigFile.test.ts index d26919b52b5c..661c84dcb6b0 100644 --- a/packages/tsconfig-utils/tests/lib/getParsedConfigFile.test.ts +++ b/packages/tsconfig-utils/tests/getParsedConfigFile.test.ts @@ -1,7 +1,7 @@ -import path from 'node:path'; +import * as path from 'node:path'; import * as ts from 'typescript'; -import { getParsedConfigFile } from '../../src/getParsedConfigFile'; +import { getParsedConfigFile } from '../src/getParsedConfigFile.js'; const mockGetParsedCommandLineOfConfigFile = vi.fn(); @@ -22,9 +22,9 @@ describe(getParsedConfigFile, () => { }); it('throws an error when tsserver.sys is undefined', () => { - expect(() => - getParsedConfigFile({} as typeof ts, './tsconfig.json'), - ).toThrow( + expect(() => { + getParsedConfigFile({} as typeof ts, './tsconfig.json'); + }).toThrow( '`getParsedConfigFile` is only supported in a Node-like environment.', ); }); @@ -72,9 +72,9 @@ describe(getParsedConfigFile, () => { }, ] satisfies ts.Diagnostic[], }); - expect(() => getParsedConfigFile(mockTsserver, './tsconfig.json')).toThrow( - /.+ error TS1234: Oh no!/, - ); + expect(() => { + getParsedConfigFile(mockTsserver, './tsconfig.json'); + }).toThrow(/.+ error TS1234: Oh no!/); }); it('throws a diagnostic error when getParsedCommandLineOfConfigFile throws an error', () => { @@ -96,9 +96,9 @@ describe(getParsedConfigFile, () => { } satisfies ts.Diagnostic); }, ); - expect(() => getParsedConfigFile(mockTsserver, './tsconfig.json')).toThrow( - /.+ error TS1234: Oh no!/, - ); + expect(() => { + getParsedConfigFile(mockTsserver, './tsconfig.json'); + }).toThrow(/.+ error TS1234: Oh no!/); }); it('uses compiler options when parsing a config file succeeds', () => { diff --git a/packages/tsconfig-utils/tsconfig.build.json b/packages/tsconfig-utils/tsconfig.build.json index 2250b25126e4..4a1f19accacd 100644 --- a/packages/tsconfig-utils/tsconfig.build.json +++ b/packages/tsconfig-utils/tsconfig.build.json @@ -1,14 +1,5 @@ { - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "baseUrl": ".", - "rootDir": "src", - "outDir": "dist", - "tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo", - "emitDeclarationOnly": false, - "types": ["node"] - }, - "include": ["src/**/*.ts", "typings"], - "exclude": ["vitest.config.mts", "src/**/*.spec.ts", "src/**/*.test.ts"], + "extends": "../../tsconfig.build.json", + "compilerOptions": {}, "references": [] } diff --git a/packages/tsconfig-utils/tsconfig.spec.json b/packages/tsconfig-utils/tsconfig.spec.json index 21fcf7e24f3f..29124fc697d3 100644 --- a/packages/tsconfig-utils/tsconfig.spec.json +++ b/packages/tsconfig-utils/tsconfig.spec.json @@ -1,20 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "../../dist/out-tsc/packages/tsconfig-utils", - "module": "NodeNext", - "resolveJsonModule": true, - "types": ["node", "vitest/globals", "vitest/importMeta"] + "outDir": "../../dist/packages/tsconfig-utils" }, - "include": [ - "vitest.config.mts", - "package.json", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.d.ts", - "tests" - ], - "exclude": ["**/fixtures/**"], "references": [ { "path": "./tsconfig.build.json" diff --git a/packages/tsconfig-utils/vitest.config.mts b/packages/tsconfig-utils/vitest.config.mts index 9cadb9dea2bb..ddc038f86b56 100644 --- a/packages/tsconfig-utils/vitest.config.mts +++ b/packages/tsconfig-utils/vitest.config.mts @@ -11,14 +11,9 @@ const vitestConfig = mergeConfig( root: import.meta.dirname, test: { - diff: { - maxDepth: 1, - }, - dir: path.join(import.meta.dirname, 'tests'), name: packageJson.name.replace('@typescript-eslint/', ''), root: import.meta.dirname, - testTimeout: 10_000, }, }), ); From 0e884c7cbd08b1cd071a67a4faef61a7a8d3ba68 Mon Sep 17 00:00:00 2001 From: Younsang Na <77400131+nayounsang@users.noreply.github.com> Date: Wed, 16 Jul 2025 23:05:10 +0900 Subject: [PATCH 3/5] fix(eslint-plugin): [consistent-generic-constructors] resolve conflict with `isolatedDeclarations` if enabled in `constructor` option (#11351) * test: add tc * fix: ignore constructor report when id is enabled --- .../src/rules/consistent-generic-constructors.ts | 3 ++- .../rules/consistent-generic-constructors.test.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/src/rules/consistent-generic-constructors.ts b/packages/eslint-plugin/src/rules/consistent-generic-constructors.ts index f2a4808d25dd..a26f1422460e 100644 --- a/packages/eslint-plugin/src/rules/consistent-generic-constructors.ts +++ b/packages/eslint-plugin/src/rules/consistent-generic-constructors.ts @@ -123,7 +123,8 @@ export default createRule({ return; } - if (lhs?.typeArguments && !rhs.typeArguments) { + const isolatedDeclarations = context.parserOptions.isolatedDeclarations; + if (!isolatedDeclarations && lhs?.typeArguments && !rhs.typeArguments) { const hasParens = context.sourceCode.getTokenAfter(rhs.callee)?.value === '('; const extraComments = new Set( diff --git a/packages/eslint-plugin/tests/rules/consistent-generic-constructors.test.ts b/packages/eslint-plugin/tests/rules/consistent-generic-constructors.test.ts index 4d0403a85a87..1a573186b1ae 100644 --- a/packages/eslint-plugin/tests/rules/consistent-generic-constructors.test.ts +++ b/packages/eslint-plugin/tests/rules/consistent-generic-constructors.test.ts @@ -45,6 +45,16 @@ class A { ` const a = function (a: Foo = new Foo()) {}; `, + { + code: ` +const foo: Foo = new Foo(); + `, + languageOptions: { + parserOptions: { + isolatedDeclarations: true, + }, + }, + }, // type-annotation { code: 'const a = new Foo();', From f08d08fb48694eea85b38504cc69a5256d1f790e Mon Sep 17 00:00:00 2001 From: MK <19619718+asdf93074@users.noreply.github.com> Date: Fri, 18 Jul 2025 18:07:46 +0500 Subject: [PATCH 4/5] feat(typescript-estree): forbid optional chain in `TemplateTaggedLiteral` (#11391) --- .../_error_/optional-nested-function-tag/fixture.ts | 1 + .../snapshots/1-TSESTree-Error.shot | 7 +++++++ .../snapshots/2-Babel-Error.shot | 8 ++++++++ .../snapshots/3-Alignment-Error.shot | 4 ++++ .../fixtures/_error_/optional-nested-tag/fixture.ts | 1 + .../optional-nested-tag/snapshots/1-TSESTree-Error.shot | 7 +++++++ .../optional-nested-tag/snapshots/2-Babel-Error.shot | 8 ++++++++ .../optional-nested-tag/snapshots/3-Alignment-Error.shot | 4 ++++ .../fixtures/_error_/optional-tag/fixture.ts | 1 + .../_error_/optional-tag/snapshots/1-TSESTree-Error.shot | 7 +++++++ .../_error_/optional-tag/snapshots/2-Babel-Error.shot | 8 ++++++++ .../optional-tag/snapshots/3-Alignment-Error.shot | 4 ++++ packages/typescript-estree/src/convert.ts | 9 ++++++++- 13 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/fixture.ts create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/3-Alignment-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/fixture.ts create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/3-Alignment-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/fixture.ts create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/1-TSESTree-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/2-Babel-Error.shot create mode 100644 packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/3-Alignment-Error.shot diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/fixture.ts b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/fixture.ts new file mode 100644 index 000000000000..7fc56660a355 --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/fixture.ts @@ -0,0 +1 @@ +a?.b()`...` diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..e096b5f6d715 --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,7 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-nested-function-tag > TSESTree - Error`] +TSError +> 1 | a?.b()`...` + | ^^^^^^^^^^^ Tagged template expressions are not permitted in an optional chain. + 2 | diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..69c9ea2f84ea --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/2-Babel-Error.shot @@ -0,0 +1,8 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-nested-function-tag > Babel - Error`] +BabelError +> 1 | a?.b()`...` + | ^ Tagged Template Literals are not allowed in optionalChain. (1:0) + 2 | + diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..11aea0c55d48 --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-function-tag/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-nested-function-tag > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/fixture.ts b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/fixture.ts new file mode 100644 index 000000000000..d6e041652e3d --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/fixture.ts @@ -0,0 +1 @@ +a?.b.c`...` diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..3be80a77ffb4 --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,7 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-nested-tag > TSESTree - Error`] +TSError +> 1 | a?.b.c`...` + | ^^^^^^^^^^^ Tagged template expressions are not permitted in an optional chain. + 2 | diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..e27266628424 --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/2-Babel-Error.shot @@ -0,0 +1,8 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-nested-tag > Babel - Error`] +BabelError +> 1 | a?.b.c`...` + | ^ Tagged Template Literals are not allowed in optionalChain. (1:0) + 2 | + diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..87a5ea5117c6 --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-nested-tag/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-nested-tag > Error Alignment`] +Both errored diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/fixture.ts b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/fixture.ts new file mode 100644 index 000000000000..fb8c8604a1d5 --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/fixture.ts @@ -0,0 +1 @@ +a?.b`...` diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/1-TSESTree-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/1-TSESTree-Error.shot new file mode 100644 index 000000000000..b7909f67ed9e --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/1-TSESTree-Error.shot @@ -0,0 +1,7 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-tag > TSESTree - Error`] +TSError +> 1 | a?.b`...` + | ^^^^^^^^^ Tagged template expressions are not permitted in an optional chain. + 2 | diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/2-Babel-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/2-Babel-Error.shot new file mode 100644 index 000000000000..23079d1b071e --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/2-Babel-Error.shot @@ -0,0 +1,8 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-tag > Babel - Error`] +BabelError +> 1 | a?.b`...` + | ^ Tagged Template Literals are not allowed in optionalChain. (1:0) + 2 | + diff --git a/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/3-Alignment-Error.shot b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/3-Alignment-Error.shot new file mode 100644 index 000000000000..d32839672fdb --- /dev/null +++ b/packages/ast-spec/src/expression/TaggedTemplateExpression/fixtures/_error_/optional-tag/snapshots/3-Alignment-Error.shot @@ -0,0 +1,4 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AST Fixtures > expression > TaggedTemplateExpression > _error_ > optional-tag > Error Alignment`] +Both errored diff --git a/packages/typescript-estree/src/convert.ts b/packages/typescript-estree/src/convert.ts index f2a504aa4a1d..7ebc034afdec 100644 --- a/packages/typescript-estree/src/convert.ts +++ b/packages/typescript-estree/src/convert.ts @@ -1917,7 +1917,13 @@ export class Converter { return result; } - case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.TaggedTemplateExpression: { + if (node.tag.flags & ts.NodeFlags.OptionalChain) { + this.#throwError( + node, + 'Tagged template expressions are not permitted in an optional chain.', + ); + } return this.createNode(node, { type: AST_NODE_TYPES.TaggedTemplateExpression, quasi: this.convertChild(node.template), @@ -1929,6 +1935,7 @@ export class Converter { node, ), }); + } case SyntaxKind.TemplateHead: case SyntaxKind.TemplateMiddle: From 47f73916cb34363a0358dadd9705ffeeb39077a1 Mon Sep 17 00:00:00 2001 From: tao <2471314@gmail.com> Date: Fri, 18 Jul 2025 21:08:55 +0800 Subject: [PATCH 5/5] fix(typescript-estree): ensure the token type of the property name is Identifier (#11329) --- packages/typescript-estree/src/node-utils.ts | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/packages/typescript-estree/src/node-utils.ts b/packages/typescript-estree/src/node-utils.ts index 16054dfc9960..640b493d63bb 100644 --- a/packages/typescript-estree/src/node-utils.ts +++ b/packages/typescript-estree/src/node-utils.ts @@ -480,25 +480,6 @@ export function getTokenType( if (token.kind === SyntaxKind.NullKeyword) { return AST_TOKEN_TYPES.Null; } - let keywordKind: ts.SyntaxKind | undefined; - if (isAtLeast50 && token.kind === SyntaxKind.Identifier) { - keywordKind = ts.identifierToKeywordKind(token as ts.Identifier); - } else if ('originalKeywordKind' in token) { - // @ts-expect-error -- intentional fallback for older TS versions <=4.9 - keywordKind = token.originalKeywordKind; - } - if (keywordKind) { - if (keywordKind === SyntaxKind.NullKeyword) { - return AST_TOKEN_TYPES.Null; - } - if ( - keywordKind >= SyntaxKind.FirstFutureReservedWord && - keywordKind <= SyntaxKind.LastKeyword - ) { - return AST_TOKEN_TYPES.Identifier; - } - return AST_TOKEN_TYPES.Keyword; - } if ( token.kind >= SyntaxKind.FirstKeyword && pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy