-
-
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
[Fix] no-unused-modules
: don't error out when running with flat config and an eslintrc isn't present
#3116
base: main
Are you sure you want to change the base?
Conversation
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.
Looks pretty good, thanks!
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3116 +/- ##
==========================================
+ Coverage 90.45% 94.99% +4.54%
==========================================
Files 84 83 -1
Lines 3634 3618 -16
Branches 1279 1276 -3
==========================================
+ Hits 3287 3437 +150
+ Misses 347 181 -166 ☔ View full report in Codecov by Sentry. |
4a50098
to
d5ba9af
Compare
Addressed lint errors |
d5ba9af
to
a515ac9
Compare
no-unused-modules
: don't error out when running with flat config and an eslintrc isn't present
7ba8372
to
bc01442
Compare
Updated, based on feedback in #3079 to not attempt to avoid the error, but to instead rethrow with a more informative message. I updated the PR description to reflect the new approach. There's not a great way to test this now. With the integration tests before, we could remove the rc config, run lint, and observe that it didn't error out. Now we're wanting it to error out when no rc is present, and there's not a great way to recreate that in the rule's unit tests or in integration tests that don't throw (unless we write a custom node script to serve as an integration test). Thoughts? |
bc01442
to
e17e073
Compare
I suppose we could have a test make a temp dir (using |
e17e073
to
9acd806
Compare
Added a test that does the following:
|
dda50b9
to
133aeeb
Compare
5159bce
to
691aba5
Compare
… no eslintrc is present This change adjusts what we're doing if an error is thrown while attempting to enumerate lintable files in the no-used-modules rule, when users are running with flat config. Now, if FileEnumerator throws due to a lack of eslintrc and the user is running with flat config, we catch the error and rethrow with a more informative message. I also cleaned up the original aspects of the implementation that was using the proposed eslint context functions, since that proposal was walked back and the API was never introduced. Note: This isn't an ideal state, since this rule still relies on the legacy api to understand what needs to be ignored. Remaining tethered to the legacy config system is going to need to be solved at some point. Fixes import-js#3079
691aba5
to
322ef5f
Compare
@ljharb I got this about where I want it, except for one question to you. I added the test to the existing set of unit tests just because all the CI plumbing was already in place to add it there. Though, it doesn't really feel right for it to be there, since it's more of an integration test. Would you rather it be where I have it now, or add a new workflow to CI for doing this kind of integration testing? |
I think that it's fine where it is to land this, but it might make sense to move it in a followup? … although i do see there's 2 uncovered lines in the diff |
Sounds good
Do you mean the catch block? If so, that's because the new test isn't really contributing to the coverage report, since it's building the plugin and running lint as a separate exec command. |
This change adjusts what we're doing if an error is thrown while attempting to enumerate lintable files in the
no-used-modules
rule, when users are running with flat config. Now, ifFileEnumerator
throws due to a lack of eslintrc and the user is running with flat config, we catch the error and rethrow with a more informative message.I also cleaned up the original aspects of the implementation that was using the proposed eslint context functions, since that proposal was walked back and the API was never introduced.
Note: This isn't an ideal state, since this rule still relies on the legacy api to understand what needs to be ignored. Remaining tethered to the legacy config system is going to need to be solved at some point.
Fixes #3079