Skip to content

Bug(typescript-estree): never infers singleRun as true for project service #9854

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

typescript-estree

ESLint Config

import tseslint from "typescript-eslint";

export default tseslint.config(tseslint.configs.base, {
	files: ["**/*.ts"],
	languageOptions: {
		parserOptions: {
			projectService: true,
			tsconfigRootDir: import.meta.dirname,
		},
	},
	rules: {
		"@typescript-eslint/no-floating-promises": "error",
	},
});

Expected Result

Internally, inferSingleRun should return true when we're in single-run mode. Executing this config with something like npx eslint . should be determined to be in single-run mode.

Actual Result

singleRun is always inferred to be false right now, because of:

if (
// single-run implies type-aware linting - no projects means we can't be in single-run mode
options?.project == 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
) {
return false;
}

Additional Info

This doesn't generally have any impact on runtime performance right now. The project service doesn't generally use any single-run optimizations in single-run mode. But:


We should also investigate whether the options?.extraFileExtensions?.length check can be bypassed with options.projectService per #9504:

// 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) {
return false;
}

Versions

package version
@typescript-eslint/typescript-estree 8.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions