-
-
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 95.04% 92.06% -2.98%
==========================================
Files 84 83 -1
Lines 3634 3618 -16
Branches 1279 1276 -3
==========================================
- Hits 3454 3331 -123
- Misses 180 287 +107 ☔ 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
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
Added a test that does the following:
|
9993d21
to
dda50b9
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
dda50b9
to
133aeeb
Compare
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