Content-Length: 396112 | pFad | http://github.com/typescript-eslint/typescript-eslint/pull/11327/files

20 fix(typescript-estree): infers singleRun as true for project service by nayounsang · Pull Request #11327 · typescript-eslint/typescript-eslint · GitHub
Skip to content

fix(typescript-estree): infers singleRun as true for project service #11327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ 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;
}

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) ||
// 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
Expand Down
18 changes: 18 additions & 0 deletions packages/typescript-estree/tests/lib/inferSingleRun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ describe(inferSingleRun, () => {
expect(actual).toBe(false);
});

it('returns true when singleRun can be inferred options.extraFileExtensions contains entires 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,
Expand All @@ -157,4 +168,11 @@ describe(inferSingleRun, () => {

expect(actual).toBe(false);
});

it('returns true for project service in single run', () => {
vi.stubEnv('CI', 'true');
const actual = inferSingleRun({ projectService: true });

expect(actual).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Copy link
Contributor Author

@nayounsang nayounsang Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As asked, I'm not sure if testing like this is desirable.
parseAndGenerateService -> getProgramAndAST (in singleRun, get AST and program) -> useProgramFromProjectService -> extraFileExtensions

...options,
extraFileExtensions: ['.vue'],
project: null,
projectService: true,
}).services.program;

expect(resultProgram).not.toBeNull();
});
});
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/typescript-eslint/typescript-eslint/pull/11327/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy