Skip to content

feat(typescript-estree): default projectService.defaultProject to 'tsconfig.json' #9893

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

@JoshuaKGoldberg JoshuaKGoldberg commented Aug 27, 2024

PR Checklist

Overview

Now, getParsedConfigFile will always be called, even if the user hasn't explicitly provided projectService.defaultProject manually. This is actually good, I think: it'll make sure the project's tsconfig.json is valid.

💖

@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 Aug 27, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 80deb12
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66d1ec2922ce110008cf6d04
😎 Deploy Preview https://deploy-preview-9893--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 (no change 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 Aug 27, 2024

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft August 28, 2024 15:17
fs.readFileSync(
path.isAbsolute(file) ? file : path.join(getCurrentDirectory(), file),
'utf-8',
),
Copy link
Member Author

Choose a reason for hiding this comment

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

Without this absolute checking:

      A fatal parsing error occurred: Parsing error: Could not read project service default project 'tsconfig.json': error TS5012: Cannot read file '/home/runner/work/typescript-eslint/typescript-eslint/packages/eslint-plugin-internal/tests/fixtures/tsconfig.build.json': ENOENT: no such file or directory, open '/home/runner/work/typescript-eslint/typescript-eslint/packages/eslint-plugin-internal/tests/fixtures/tsconfig.build.json'.

That tsconfig.build.json comes from packages/typescript-estree/tsconfig.json. The test was reading with cwd packages/typescript-estree.

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.05%. Comparing base (d9f66da) to head (80deb12).
Report is 27 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9893   +/-   ##
=======================================
  Coverage   88.05%   88.05%           
=======================================
  Files         407      407           
  Lines       13947    13948    +1     
  Branches     4071     4071           
=======================================
+ Hits        12281    12282    +1     
  Misses       1354     1354           
  Partials      312      312           
Flag Coverage Δ
unittest 88.05% <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.23% <100.00%> (ø)
...t-estree/src/create-program/getParsedConfigFile.ts 94.11% <100.00%> (+0.36%) ⬆️
...eate-program/validateDefaultProjectForFilesGlob.ts 100.00% <100.00%> (ø)

... and 36 files with indirect coverage changes

/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
...require('../../jest.config.base.js'),
testRegex: ['./tests/lib/.*\\.test\\.ts$'],
testPathIgnorePatterns: process.env.TYPESCRIPT_ESLINT_PROJECT_SERVICE
? ['/node_modules/', 'project-true']
: [],
Copy link
Member Author

@JoshuaKGoldberg JoshuaKGoldberg Aug 30, 2024

Choose a reason for hiding this comment

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

parse.project-true.test.ts never really needed to be tested with the project service on anyway. Otherwise:

Could not read project service default project 'tsconfig.json': error TS5012: Cannot read file 'tsconfig.json': ENOENT: no such file or directory, open '/Users/josh/repos/typescript-eslint/packages/typescript-estree/tests/fixtures/projectTrue/tsconfig.json'.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review September 1, 2024 11:53
@JoshuaKGoldberg JoshuaKGoldberg merged commit e9428cb into typescript-eslint:main Sep 4, 2024
61 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the project-service-default-project-tsconfig.json branch September 4, 2024 13:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Default projectService.defaultProject to "tsconfig.json"
2 participants