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
Update: add fixer for wrap-iife
#7196
Conversation
@not-an-aardvark, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @lo1tuma and @ilyavolodin to be potential reviewers |
LGTM |
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.
LGTM, thank you!
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.
Minor tweak about multiline comments, otherwise looks good.
// The outer call expression will always be wrapped at this point. | ||
// Replace the range between the end of the function expression and the end of the call expression. | ||
// for example, in `(function(foo) {}(bar))`, the range `(bar))` should get replaced with `)(bar)`. | ||
// Replace the parens from the outer expression, and parenthesize the function expression. |
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.
In our coding conventions, we prefer multi-line comments to be formatted like this:
/*
* First line of comment here.
* Second line. Note that each line starts with asterisk aligned with the open-comment asterisk character.
* Both comment start and end should be on their own line.
* Comment ends with asterisk of close-comment token aligned with other asterisks.
*/
// The inner function expression will always be wrapped at this point. | ||
// It's only necessary to replace the range between the end of the function expression | ||
// and the call expression. For example, in `(function(foo) {})(bar)`, the range `)(bar)` | ||
// should get replaced with `(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.
Same as above re: multiline comment.
LGTM |
Added a commit to fix multiline comment style. |
Thanks @not-an-aardvark, changes LGTM. |
I'll champion this. |
LGTM. Thanks for contributing to ESLint! |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[x] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
Please check each item to ensure your pull request is ready:
What changes did you make? (Give an overview)
This adds a fixer for
wrap-iife
.If the IIFE has no surrounding parentheses, the fixer surrounds it with parentheses. The fixer also removes parentheses that are in the wrong place according to the rule option:
Is there anything you'd like reviewers to focus on?
Nothing in particular.