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(organize_import): move legacy code to a deidicated module an dintroduce restricted globs #4357

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

Conaclos
Copy link
Member

Summary

Part of #3177

This PR moves the current code to a legacy module and introduce restricted globs.

I am using the gloset crate for proper support of globs.
I choose this library because we already use the regex crate (globset is based on the regex crate).

Restricted globs abstracts over gloset in order to have a consistent behavior and make easy a change of glob library if we want to.
Restricted globs support only stars * and globstars ** matchers. * can be escaped with \ on any platforms (matching against \ on Windows is disabled). Also, we configure globset to ensure that * doesn't match /. Characters such as ?, [, and { must be escaped.
I plan to lift some restrictions in the future (before release).
For the time being I think it is enough.

We will certainly need to add a superset to restricted glob in order to match against import sources.
Indeed, import sources can include protocols such as node:fs or, npm:@scope/package/subpath.
We could introduce a special glob that allow matching against it. For example **:** could match against any import source, ** could match only against protocol-less imports, *:** could match only against imports with protocols, ... I am not 100% sure about that and left it for a future PR.

Test Plan

I added some tests.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Oct 21, 2024
Copy link

codspeed-hq bot commented Oct 21, 2024

CodSpeed Performance Report

Merging #4357 will not alter performance

Comparing conaclos/import-sorter-revamping-legacy (ae3e20e) with main (edd82c0)

Summary

✅ 101 untouched benchmarks

@Conaclos Conaclos force-pushed the conaclos/import-sorter-revamping-legacy branch from 7270b1d to c79e2ff Compare October 21, 2024 11:43
@Conaclos Conaclos force-pushed the conaclos/import-sorter-revamping-legacy branch 15 times, most recently from a65942d to ae3e20e Compare October 22, 2024 11:43
@Conaclos Conaclos merged commit e3e37ab into main Oct 22, 2024
12 checks passed
@Conaclos Conaclos deleted the conaclos/import-sorter-revamping-legacy branch October 22, 2024 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants