Skip to content
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

Merged
merged 3 commits into from Jun 8, 2017

Conversation

soda0289
Copy link
Member

@soda0289 soda0289 commented Jun 7, 2017

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

@eslintbot
Copy link

LGTM

@mention-bot
Copy link

@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.

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Jun 7, 2017
/**
* 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);
Copy link
Member

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.

function fixParamsWithParenthesis(fixer) {
const paramToken = context.getTokenAfter(token);
const closingParenToken = context.getTokenAfter(paramToken);
const asyncToken = isAsync ? context.getTokenBefore(token) : null;
Copy link
Member

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.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

@soda0289
Copy link
Member Author

soda0289 commented Jun 7, 2017

Changes:

  • changed the token variable to firstTokenOfParam, which might be a opening paren or identifier.
  • used sourceCode.getToken functions instead of context.getToken
  • Removed extra blank lines

Copy link
Member

@kaicataldo kaicataldo left a 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!

Copy link
Member

@gyandeeps gyandeeps left a 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.

@kaicataldo kaicataldo merged commit 3cfe9ee into master Jun 8, 2017
@kaicataldo
Copy link
Member

Thanks for contributing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants