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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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);
});
});
Loading
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