-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[New] extensions
: allow enforcement decision overrides based on specifier
#3105
Conversation
…sion overrides based on specifier
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3105 +/- ##
==========================================
+ Coverage 95.08% 95.61% +0.53%
==========================================
Files 83 83
Lines 3618 3629 +11
Branches 1276 1282 +6
==========================================
+ Hits 3440 3470 +30
+ Misses 178 159 -19 ☔ View full report in Codecov by Sentry. |
1c127b7
to
b067170
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if two contradictory pathGroupOverrides options end up applying to the same file?
extensions
: allow enforcement decision overrides based on specifier
It mirrors the behavior of |
b067170
to
344df04
Compare
@ljharb Did this PR need any further work? |
@Xunnamius there's a few lines in the diff that aren't covered by tests. |
344df04
to
7a69297
Compare
@ljharb I'm not seeing any uncovered lines on codecov? Though I did see some failing eslint tests. They are now passing. It could be the case that I'm not seeing something obvious, so please let me know :) |
a0ab04d
to
63da958
Compare
63da958
to
fa36d49
Compare
When can we expect this feature to be released? |
@alexandre-le-borgne Just a guess, but might be waiting on #3152, which I should find the time to finish up either today or tomorrow :) |
This PR implements in
import/extensions
: a new option enabling developers to override the decision to enforce or ignore extensions for imports with matching specifiers.A demo package containing this feature is temporarily available for easy testing:
Prevent false negatives when checking the extensions of bespoke imports
I already use
import/order
with custompathGroups
. This allows me to control the grouping of certain paths, such as custom aliases fromtsconfig.json
'spaths
. This in turn ensures all imports are sorted properly, even when the project is using syntactically sound but otherwise bespoke custom aliases likemy-project:api.js
(in lieu of../../../../src/api.js
).Unfortunately, if I mistype
my-project:api
(i.e. I forgot the extension), theimport/extensions
rule will still pass; the enforcement decision is "ignore" when it should have been "enforce". This is because, likeimport/order
, the grouping strategy employed by this rule is quite coarse-grained, but unlikeimport/order
, this rule is missing apathGroups
-like setting for finer-grained sorting. The goal of this PR is to fill that gap.The documentation updates associated with the changes in this PR are part of a separate PR and can be previewed here (towards the bottom of the section). This PR also includes tests.