-
Notifications
You must be signed in to change notification settings - Fork 30
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
Implement fix for noUnnecessaryElseRule #103
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.
Thank you for submitting this PR.
I left some comments regarding the implementation.
Incidentally the thing with block-scoped variables in the else
-block is also discussed and fixed in eslint/eslint#11076
The test need to be updated for the changed error output (see failed CI of this PR). Also please add a .fix
file next to the .lint
file to ensure the fixes work as expected.
0450bb4
to
8b05c1a
Compare
I've decided to remove the stripping of the else block, since I couldn't figure out a way to do this sanely in a single fix. It almost feels like it should be a separate no-unneccassary-block rule with fixer. |
Just saw your comments, reading now.. |
Ah, much better now. Thanks for the explanations. |
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.
the changes look good to me. I just added comments for minor improvements.
rules/noUnnecessaryElseRule.ts
Outdated
return ts.forEachChild(sourceFile, cb); | ||
} | ||
|
||
/** Return true to traverse children, false otherwise */ |
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.
this comment no longer applies
rules/noUnnecessaryElseRule.ts
Outdated
} | ||
} | ||
|
||
class IfWalker extends Lint.AbstractWalker<void> { |
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.
could be reverted to extend AbstractIfStatementWalker
. you can then drop the implementation of walk
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.
Thanks @eile
I'll publish a new release today so you can enjoy this new fixing capability.
And it's published as |
No description provided.