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

feat(typescript-estree): allow specifying project: true #6084

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Nov 25, 2022

PR Checklist

Overview

Allows users to specify parserOptions.project: true to indicate each file should be linted with the closest tsconfig.json to that file.

  • Initial draft working for "one-and-done" use case of
  • Get it to also work for watch mode, where tsconfig.json files might be moved between lints
    • Work... ish. We won't know if someone moves a tsconfig.json to re-lint a currently visible file in an IDE. But as soon as the file is changed, we'll know to re-check its relative tsconfig.json anyway.
  • Test it
  • Document it

Throwing up a draft now to be very visible about progress.

@nx-cloud
Copy link

nx-cloud bot commented Nov 25, 2022

☁️ Nx Cloud Report

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

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@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.

@netlify
Copy link

netlify bot commented Nov 25, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 040a56a
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/63e56168d1e1600008e95fd8
😎 Deploy Preview https://deploy-preview-6084--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@JoshuaKGoldberg JoshuaKGoldberg added this to the 6.0.0 milestone Nov 25, 2022
@bradzacher
Copy link
Member

bradzacher commented Nov 25, 2022

Get it to also work for watch mode, where tsconfig.json files might be moved between lints

pleasekillme4

if only we had a way to attach watchers to the disk 😿

@codecov
Copy link

codecov bot commented Nov 25, 2022

Codecov Report

Merging #6084 (040a56a) into main (f330e06) will increase coverage by 0.00%.
The diff coverage is 94.28%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6084   +/-   ##
=======================================
  Coverage   91.52%   91.52%           
=======================================
  Files         371      372    +1     
  Lines       12651    12689   +38     
  Branches     3717     3730   +13     
=======================================
+ Hits        11579    11614   +35     
  Misses        754      754           
- Partials      318      321    +3     
Flag Coverage Δ
unittest 91.52% <94.28%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...pt-estree/src/parseSettings/createParseSettings.ts 93.47% <66.66%> (-4.03%) ⬇️
...pescript-estree/src/parseSettings/ExpiringCache.ts 100.00% <100.00%> (+4.76%) ⬆️
...-estree/src/parseSettings/getProjectConfigFiles.ts 100.00% <100.00%> (ø)
...ipt-estree/src/parseSettings/resolveProjectList.ts 91.11% <0.00%> (-4.45%) ⬇️
...int-plugin/src/rules/strict-boolean-expressions.ts 98.90% <0.00%> (+0.06%) ⬆️

@JoshuaKGoldberg JoshuaKGoldberg changed the title [DRAFT] feat(typescript-estree): allow specifying project: true feat(typescript-estree): allow specifying project: true Nov 25, 2022
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review November 25, 2022 08:35
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 19, 2023
bradzacher
bradzacher previously approved these changes Jan 23, 2023
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

we're like 99% of the way there - just need to handle cache lifetime and we gucci

vito_good

docs/linting/Typed_Linting.md Outdated Show resolved Hide resolved
docs/linting/Typed_Linting.md Outdated Show resolved Hide resolved
docs/architecture/Parser.mdx Show resolved Hide resolved
docs/architecture/Parser.mdx Outdated Show resolved Hide resolved
JoshuaKGoldberg and others added 2 commits January 23, 2023 08:25
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Jan 30, 2023
@bradzacher bradzacher removed this from the 6.0.0 milestone Jan 30, 2023
@bradzacher bradzacher added the enhancement New feature or request label Jan 30, 2023
@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented Feb 4, 2023

ugh git

@JoshuaKGoldberg JoshuaKGoldberg removed the awaiting response Issues waiting for a reply from the OP or another party label Feb 5, 2023
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

Overall this LGTM - so stamped

Before you land it - could you do a perf test just so we can update the docs with messaging around perf if we need to?

To test the perf I'd just use the time tool against main then against your branch:

  • git checkout main && yarn && time ./node_modules/.bin/eslint .
  • git checkout parser-options-project-true && yarn && time ./node_modules/.bin/eslint .

You'll see a line like this:

./node_modules/.bin/eslint .  62.97s user 4.09s system 167% cpu 40.009 total

The first number is the one to compare.
I'd do a couple runs of each just to smooth any outlier slowness.

I'd expect this to be a little slower due to the lookup required for every file - but I think that with the caching you've built in it shouldn't be MUCH slower. For a big, deeply nested project they might find it has more of an impact.

If the difference is minuscule then I don't think we need to worry about any messaging, but if it's different enough one way or the other it's probably worth mentioning!

But this is why it'd be worth a test - just to see if it is actually different enough.


If you wanted you could go hog-ham and investigate the proper perf trace before and after:
#6366 (comment)

The thing that would be interesting to see would be the cost of the createParseSettings before and after as that's where your changes are.
Would be interesting to see the proper breakdown!

@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented Feb 10, 2023

  • main: ./node_modules/.bin/eslint . 61.71s user 3.54s system 166% cpu 39.264 total
  • parser-options-project-true: ./node_modules/.bin/eslint . 61.56s user 3.66s system 167% cpu 38.829 total

👌

@JoshuaKGoldberg JoshuaKGoldberg added this pull request to the merge queue Feb 10, 2023
@JoshuaKGoldberg JoshuaKGoldberg removed this pull request from the merge queue due to a manual request Feb 10, 2023
@JoshuaKGoldberg JoshuaKGoldberg merged commit dcd05f0 into typescript-eslint:main Feb 10, 2023
@JoshuaKGoldberg JoshuaKGoldberg deleted the parser-options-project-true branch February 10, 2023 03:34
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: support looking up tsconfig.json relative to linted file
3 participants