-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Make no-unused-disable fixable #13
Make no-unused-disable fixable #13
Conversation
Ironic, I will fix those lint errors :) |
Codecov Report
@@ Coverage Diff @@
## master #13 +/- ##
==========================================
+ Coverage 96.87% 96.94% +0.06%
==========================================
Files 25 25
Lines 320 327 +7
==========================================
+ Hits 310 317 +7
Misses 10 10
Continue to review full report at Codecov.
|
Thank you very much for this PR. However, unfortunately, I rewrote the If you are still interesting to implement this, you can investigate in lib/patch.js file. This file does the following actions:
|
I'll check that out, thanks! |
@ianobermiller Still interested in finishing this? :) |
Perhaps at some point, but it is no longer a priority. |
5df9cc1
to
4ca9160
Compare
That should do it :) |
4ca9160
to
79a8f2e
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.
Thank you very much!
That direction looks good to me. But I have some concerns. Would you take a look?
- please remove yarn.lock file
- please fix CI errors
And the following comments:
lib/utils/patch.js
Outdated
} else { | ||
clone.endLine = comment.loc.end.line | ||
clone.endColumn = comment.loc.end.column + 1 | ||
clone.fix = function fix(fixer) { | ||
return fixer.remove(comment) |
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.
Please keep line breaks which were in the comment. This can make invalid syntax in semicolon-less style. For example:
foo /*eslint-disable
*/ bar
↓↓↓
foo bar
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.
@ianobermiller Thank you for the update! LGTM except this matter. Would you make the replaced text comment.value.includes("\n") ? "\n" : ""
or something like (and, add a test case)?
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.
Missed that one from the original review, thanks!
e2c4e67
to
11dcac7
Compare
@mysticatea the fixer will run only when there is a single rule (or no particular rule) being disabled. |
Summary: Add a fixer for no-unused-disable that just removes the entire comment node. This behavior is undesirable if you frequently disable multiple rules at a time, as it removes the entire comment even if only one was unused. Since disabling multiple rules is the exception, I still think this fixer has tremendous value. Test plan: - `npm run test` - run the rule on a handful of files in a local project, note that it finds many issues and successfully fixes them
11dcac7
to
1da89ae
Compare
I apologize for my delay. I had been diving into busy days. LGTM, thank you so much! |
This reverts commit f625cd6. # Conflicts: # docs/rules/no-unused-disable.md
Summary:
Add a fixer for no-unused-disable that just removes the entire comment node. If the comment is disabling multiple rules at once, do not offer to fix.
Test plan:
npm run test
finds many issues and successfully fixes them