8000 fix(typescript-estree): don't throw on missing tsconfig.json by default in project service by JoshuaKGoldberg · Pull Request #9989 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

fix(typescript-estree): don't throw on missing tsconfig.json by default in project service #9989

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

Conversation

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Changes error throwing to only occur if the user explicitly provides a parserOptions.defaultProject.

💖

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link
netlify bot commented Sep 14, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 318279b
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66e59a9bf48f9d0008432618
😎 Deploy Preview https://deploy-preview-9989--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 4 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
nx-cloud bot commented Sep 14, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 318279b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

Copy link
codecov bot commented Sep 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.67%. Comparing base (77e65df) to head (318279b).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9989   +/-   ##
=======================================
  Coverage   88.67%   88.67%           
=======================================
  Files         425      425           
  Lines       14797    14799    +2     
  Branches     4302     4304    +2     
=======================================
+ Hits        13121    13123    +2     
  Misses       1533     1533           
  Partials      143      143           
Flag Coverage Δ
unittest 88.67% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...-estree/src/create-program/createProjectService.ts 95.45% <100.00%> (+0.21%) ⬆️

Copy link
Member
@auvred auvred left a comment

Choose a reason for hiding this comment

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

👍

@auvred auvred added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Sep 14, 2024
@ex0ns
Copy link
ex0ns commented Sep 15, 2024

I have been troubleshooting this issue on my side without realizing there was an open issue/pr to already fix that. I was checking about the fix and wondering about the if inside the try, that involve knowing the subtle difference between the config and optionRawObject, it also feels a bit strange to parse the config file that might not exist and then wait for the exception.

I don't want to overstep, but I have tested the following solution (closer to what was done in 8.4)

  if (options.allowDefaultProject?.length) {
    log('Enabling default project: %s', options.defaultProject);
    let configFile: ts.ParsedCommandLine;

    try {
      configFile = getParsedConfigFile(
        tsserver,
        options.defaultProject,
        tsconfigRootDir,
      );
    } catch (error) {
      throw new Error(
        `Could not read project service default project '${options.defaultProject}': ${(error as Error).message}`,
      );
    }

    service.setCompilerOptionsForInferredProjects(
      // NOTE: The inferred projects API is not intended for source files when a tsconfig
      // exists.  There is no API that generates an InferredProjectCompilerOptions suggesting
      // it is meant for hard coded options passed in. Hard asserting as a work around.
      // See https://github.com/microsoft/TypeScript/blob/27bcd4cb5a98bce46c9cdd749752703ead021a4b/src/server/protocol.ts#L1904
      configFile.options as ts.server.protocol.InferredProjectCompilerOptions,
    );
  }

Which will only try to parse the config if we actually want to use a defaultProject.

@JoshuaKGoldberg JoshuaKGoldberg merged commit ef3384e into typescript-eslint:main Sep 15, 2024
65 of 66 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Upgrade to 8.5.0 breaks linting setup with NX and projectService: true
4 participants
0