Skip to content

feat(typescript-estree): replace globby w/ fast-glob #9518

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

Merged

Conversation

SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Jul 8, 2024

PR Checklist

Overview

Addresses #9453. All tests passed on my machine locally.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @SukkaW!

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 Jul 8, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 0dc3f09
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66ca15c9405f470008fcd161
😎 Deploy Preview https://deploy-preview-9518--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 Jul 8, 2024

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.04%. Comparing base (88b44ce) to head (0dc3f09).
Report is 14 commits behind head on main.

Files Patch % Lines
...ipt-estree/src/parseSettings/resolveProjectList.ts 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9518   +/-   ##
=======================================
  Coverage   88.04%   88.04%           
=======================================
  Files         407      407           
  Lines       13948    13951    +3     
  Branches     4078     4079    +1     
=======================================
+ Hits        12280    12283    +3     
  Misses       1355     1355           
  Partials      313      313           
Flag Coverage Δ
unittest 88.04% <88.88%> (+<0.01%) ⬆️

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

Files Coverage Δ
...ipt-estree/src/parseSettings/resolveProjectList.ts 97.87% <88.88%> (+0.14%) ⬆️

@SukkaW SukkaW changed the title refactor(espree): replace globby w/ fast-glob chore(espree): replace globby w/ fast-glob Jul 8, 2024
@SukkaW SukkaW changed the title chore(espree): replace globby w/ fast-glob chore(typescript-estree): replace globby w/ fast-glob Jul 8, 2024
- <tsconfigRootDir>/tsconfig.extra.json
- <tsconfigRootDir>/tsconfig.json
Copy link
Contributor

Choose a reason for hiding this comment

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

(passerby comment) Is there a small difference how these libraries find files, or why did this change? I don’t think it matters in this test as it’s just error message. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a small difference how these libraries find files

Yes, and thus results in an order difference.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, ordering changes would make this either a bug, a bug fix, or a breaking change.

It looks to me like this is a bug. The project: ['./**/tsconfig.json', './**/tsconfig.extra.json'], indicates that tsconfig.json should come first. No?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoshuaKGoldberg Fixed in the latest commits. Comments are added to explain the change.

@SukkaW SukkaW force-pushed the replace-globby-with-fast-glob branch from cde05a7 to ae480b4 Compare July 10, 2024 13:35
@SukkaW SukkaW requested a review from JoshuaKGoldberg July 10, 2024 13:40
Comment on lines +59 to +67
).reduce<string[]>((acc, folder) => {
if (typeof folder === 'string') {
acc.push(
// prefix with a ! for not match glob
folder.startsWith('!') ? folder : `!${folder}`,
);
}
return acc;
}, []);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bonus change, replace the .reduce.map chain with a single .reduce to avoid unnecessary iteration.

@SukkaW SukkaW requested a review from rubiesonthesky July 16, 2024 08:39
@SukkaW SukkaW force-pushed the replace-globby-with-fast-glob branch from 4bd11fc to 15ac7be Compare August 23, 2024 13:54
@benmccann
Copy link
Contributor

@SukkaW would you consider updating this PR to use tinyglobby rather than fast-glob as tinyglobby has fewer dependencies?

I took a naive stab at it in #9878, but it's failing the CI. I see you have a lot of extra logic here that I don't have, so perhaps that is needed. It seems you're much more familiar with how this project is setup, so if you're able to update this to use tinyglobby perhaps I can just close my PR

I was also curious why this is in draft mode as it appears to be working. Perhaps if you're able to update it to tinyglobby it could also be marked as ready for review?

@SukkaW
Copy link
Contributor Author

SukkaW commented Aug 24, 2024

but it's failing the CI. I see you have a lot of extra logic here that I don't have, so perhaps that is needed.

You can check my comments. fast-glob returns files array in arbitrary order. globby instead matches patterns one by one (iterating file systems multiple times) and then concat the results to ensure the order is correct. I added extra codes to mimic this behavior. You can try this too.

@SukkaW SukkaW marked this pull request as ready for review August 24, 2024 17:18
benmccann added a commit to benmccann/typescript-eslint that referenced this pull request Aug 24, 2024
benmccann added a commit to benmccann/typescript-eslint that referenced this pull request Aug 24, 2024
benmccann added a commit to benmccann/typescript-eslint that referenced this pull request Aug 24, 2024
benmccann added a commit to benmccann/typescript-eslint that referenced this pull request Aug 25, 2024
benmccann added a commit to benmccann/typescript-eslint that referenced this pull request Aug 25, 2024
@bradzacher bradzacher added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Aug 26, 2024
@bradzacher bradzacher requested review from a team and removed request for rubiesonthesky August 26, 2024 00:36
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the cleaup! 🧹

@bradzacher bradzacher changed the title chore(typescript-estree): replace globby w/ fast-glob feat(typescript-estree): replace globby w/ fast-glob Aug 26, 2024
@bradzacher bradzacher merged commit 692a3f5 into typescript-eslint:main Aug 26, 2024
63 of 65 checks passed

if (globProjects.length > 0) {
// Although fast-glob supports multiple patterns, fast-glob returns arbitrary order of results
// to improve performance. To ensure the order is correct, we need to call fast-glob for each pattern

Choose a reason for hiding this comment

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

OOC, does the order matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a unit test case against the order, so yes, it does matter.

Choose a reason for hiding this comment

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

But why does the order matter? Shouldn't the unit test just check that the needed files are linted?

Copy link
Member

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

Folks sometimes do things like ['packages/*/tsconfig.json', 'tsconfig.json'] - and/or entries like 'tsconfig.eslint.json'. The order intent is to first try the lower-level TSConfigs first.

Choose a reason for hiding this comment

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

Gotcha, thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 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.

Enhancement: replace globby with fast-glob
6 participants