-
-
Notifications
You must be signed in to change notification settings - Fork 4.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: Add space between async and param on fix (fixes #8682) #8693
Conversation
LGTM |
@soda0289, thanks for your PR! By analyzing the history of the files in this pull request, we identified @vitorbal, @not-an-aardvark and @nfroidure to be potential reviewers. |
lib/rules/arrow-parens.js
Outdated
/** | ||
* Determines whether a arrow function argument end with `)` | ||
* @param {ASTNode} node The arrow function node. | ||
* @returns {void} | ||
*/ | ||
function parens(node) { | ||
const token = sourceCode.getFirstToken(node, node.async ? 1 : 0); | ||
const isAsync = node.async; | ||
const token = sourceCode.getFirstToken(node, isAsync ? 1 : 0); |
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.
I know this was here before, but can you give this variable a more descriptive name? It's not clear which token it's referring to.
lib/rules/arrow-parens.js
Outdated
function fixParamsWithParenthesis(fixer) { | ||
const paramToken = context.getTokenAfter(token); | ||
const closingParenToken = context.getTokenAfter(paramToken); | ||
const asyncToken = isAsync ? context.getTokenBefore(token) : null; |
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.
Can you use sourceCode.getTokenBefore
and sourceCode.getTokenAfter
instead of context.getTokenBefore
and context.getTokenAfter
? The latter two are deprecated.
LGTM |
LGTM |
Changes:
|
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.
Still LGTM. Thanks for contributing!
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. I think its always good to keep function like these or other helper fucntions outside context and just curry it (in this case) to return a function for fixer.
Thanks for contributing! |
What is the purpose of this pull request? (put an "X" next to item)
[ X ] Bug fix (template)
What changes did you make? (Give an overview)
Update the fixer code to add space between async and the arrow function parameter when they are side by side.
Is there anything you'd like reviewers to focus on?
Nothing in particular