From 303c3ceb035c367553344aaaf734f448fb10e0ac Mon Sep 17 00:00:00 2001 From: nayounsang Date: Sat, 21 Jun 2025 20:04:17 +0900 Subject: [PATCH 1/8] test: add test case --- .../typescript-estree/tests/lib/inferSingleRun.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts index 2fe53da89076..99089600d400 100644 --- a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts +++ b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts @@ -157,4 +157,12 @@ describe(inferSingleRun, () => { expect(actual).toBe(false); }); + + it('returns true for project service in single run', () => { + vi.stubEnv('CI', 'true'); + // Do not set `project: true` if `projectService: true` + const actual = inferSingleRun({ projectService: true }); + + expect(actual).toBe(true); + }); }); From a2e2d21991d6d70d69174ee65bd2b344f7c7926e Mon Sep 17 00:00:00 2001 From: nayounsang Date: Sat, 21 Jun 2025 20:04:38 +0900 Subject: [PATCH 2/8] fix: return true for project service in single run --- packages/typescript-estree/src/parseSettings/inferSingleRun.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts index 8007e6ccd66a..36503db95a6b 100644 --- a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts +++ b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts @@ -24,7 +24,7 @@ export function inferSingleRun(options: TSESTreeOptions | undefined): boolean { if ( // single-run implies type-aware linting - no projects means we can't be in single-run mode - options?.project == null || + (options?.project == null && options?.projectService == null) || // programs passed via options means the user should be managing the programs, so we shouldn't // be creating our own single-run programs accidentally options.programs != null From 34cdad1aa542603cb0efb824e68c37ac44d8bd1d Mon Sep 17 00:00:00 2001 From: nayounsang Date: Fri, 18 Jul 2025 23:08:11 +0900 Subject: [PATCH 3/8] fix: projectService being null is same as projectService is false --- packages/typescript-estree/src/parseSettings/inferSingleRun.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts index 36503db95a6b..b2c39ca166ed 100644 --- a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts +++ b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts @@ -24,7 +24,8 @@ export function inferSingleRun(options: TSESTreeOptions | undefined): boolean { if ( // single-run implies type-aware linting - no projects means we can't be in single-run mode - (options?.project == null && options?.projectService == null) || + (options?.project == null && + (options?.projectService == null || options?.projectService === false)) || // programs passed via options means the user should be managing the programs, so we shouldn't // be creating our own single-run programs accidentally options.programs != null From 9eb8b035d63f07c31c35e8bb6d74a2229f63e91a Mon Sep 17 00:00:00 2001 From: nayounsang Date: Fri, 18 Jul 2025 23:43:36 +0900 Subject: [PATCH 4/8] refactor: simplify logic --- packages/typescript-estree/src/parseSettings/inferSingleRun.ts | 3 +-- packages/typescript-estree/tests/lib/inferSingleRun.test.ts | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts index b2c39ca166ed..077c0ceb0cc3 100644 --- a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts +++ b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts @@ -24,8 +24,7 @@ export function inferSingleRun(options: TSESTreeOptions | undefined): boolean { if ( // single-run implies type-aware linting - no projects means we can't be in single-run mode - (options?.project == null && - (options?.projectService == null || options?.projectService === false)) || + (options?.project == null && !options?.projectService) || // programs passed via options means the user should be managing the programs, so we shouldn't // be creating our own single-run programs accidentally options.programs != null diff --git a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts index 99089600d400..822a8dd70ef4 100644 --- a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts +++ b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts @@ -160,7 +160,6 @@ describe(inferSingleRun, () => { it('returns true for project service in single run', () => { vi.stubEnv('CI', 'true'); - // Do not set `project: true` if `projectService: true` const actual = inferSingleRun({ projectService: true }); expect(actual).toBe(true); From b0dcd4aa5d72cdbbe816857fe10fe88cdbf25486 Mon Sep 17 00:00:00 2001 From: nayounsang Date: Fri, 18 Jul 2025 23:49:34 +0900 Subject: [PATCH 5/8] feat: temp commit, bypass extraFileExtentions.length --- packages/typescript-estree/src/parseSettings/inferSingleRun.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts index 077c0ceb0cc3..a2a59b585f34 100644 --- a/packages/typescript-estree/src/parseSettings/inferSingleRun.ts +++ b/packages/typescript-estree/src/parseSettings/inferSingleRun.ts @@ -18,7 +18,7 @@ export function inferSingleRun(options: TSESTreeOptions | undefined): boolean { // https://github.com/typescript-eslint/typescript-eslint/issues/9504 // There's no support (yet?) for extraFileExtensions in single-run hosts. // Only watch program hosts and project service can support that. - if (options?.extraFileExtensions?.length) { + if (options?.extraFileExtensions?.length && !options.projectService) { return false; } From b937bb7fa82b1b86a7b3065a7326858c789fdba9 Mon Sep 17 00:00:00 2001 From: nayounsang Date: Sat, 19 Jul 2025 17:51:46 +0900 Subject: [PATCH 6/8] test: temp commit, add test for extraFileExtentions.length --- .../tests/lib/inferSingleRun.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts index 822a8dd70ef4..7cb77f89432c 100644 --- a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts +++ b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts @@ -143,6 +143,17 @@ describe(inferSingleRun, () => { expect(actual).toBe(false); }); + it('returns true when singleRun can be inferred with projectService', () => { + vi.stubEnv('CI', 'true'); + + const actual = inferSingleRun({ + extraFileExtensions: ['.vue'], + projectService: true, + }); + + expect(actual).toBe(true); + }); + it('returns false when there is no way to infer singleRun', () => { const actual = inferSingleRun({ programs: null, From ca1e819b1d6f5662d5b9266fd4484281f09901ef Mon Sep 17 00:00:00 2001 From: nayounsang Date: Sat, 19 Jul 2025 23:42:21 +0900 Subject: [PATCH 7/8] test: more detail test name --- packages/typescript-estree/tests/lib/inferSingleRun.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts index 7cb77f89432c..d91cb4ed04cb 100644 --- a/packages/typescript-estree/tests/lib/inferSingleRun.test.ts +++ b/packages/typescript-estree/tests/lib/inferSingleRun.test.ts @@ -143,7 +143,7 @@ describe(inferSingleRun, () => { expect(actual).toBe(false); }); - it('returns true when singleRun can be inferred with projectService', () => { + it('returns true when singleRun can be inferred options.extraFileExtensions contains entires with projectService', () => { vi.stubEnv('CI', 'true'); const actual = inferSingleRun({ From 9800aba9532368978b8743c5f0da0e4a55a95562 Mon Sep 17 00:00:00 2001 From: nayounsang Date: Mon, 21 Jul 2025 17:44:17 +0900 Subject: [PATCH 8/8] test: generate program instance with extraFileExtensions when projectservice is true --- .../tests/lib/semanticInfo-singleRun.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/typescript-estree/tests/lib/semanticInfo-singleRun.test.ts b/packages/typescript-estree/tests/lib/semanticInfo-singleRun.test.ts index 69789fa2dc3e..1bebfbb97923 100644 --- a/packages/typescript-estree/tests/lib/semanticInfo-singleRun.test.ts +++ b/packages/typescript-estree/tests/lib/semanticInfo-singleRun.test.ts @@ -260,4 +260,17 @@ describe('semanticInfo - singleRun', () => { ); }, ); + + it('should create program when extraFileExtensions is provided in projectService and singleRun mode', () => { + vi.stubEnv('TSESTREE_SINGLE_RUN', 'true'); + + const resultProgram = parseAndGenerateServices(code, { + ...options, + extraFileExtensions: ['.vue'], + project: null, + projectService: true, + }).services.program; + + expect(resultProgram).not.toBeNull(); + }); });