Skip to content
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

fix(typescript-estree): don't allow single-run unless we're in type-aware linting mode #5893

Merged
merged 2 commits into from Oct 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/typescript-estree/src/parseSettings/inferSingleRun.ts
Expand Up @@ -15,6 +15,16 @@ import type { TSESTreeOptions } from '../parser-options';
* @returns Whether this is part of a single run, rather than a long-running process.
*/
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 ||
Comment on lines +19 to +20
Copy link
Member

Choose a reason for hiding this comment

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

This I'm confused about. I thought single-run linting can have a lack of project if users don't provide a project in their ESLint config?

Looking through the stack:

  1. parseForESLint(code, options?): can be called with just code?
  2. parseAndGenerateServices(code, options): passes parserOptions to...
  3. createParseSettings(code, options): passes options to inferSingleRun

// 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;
}

// Allow users to explicitly inform us of their intent to perform a single run (or not) with TSESTREE_SINGLE_RUN
if (process.env.TSESTREE_SINGLE_RUN === 'false') {
return false;
Expand Down