Skip to content

Commit

Permalink
Fix: no-extra-parens incorrectly reports async function expressions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add authored and not-an-aardvark committed Aug 1, 2017
1 parent c794f86 commit 78a85e0
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 182 deletions.
4 changes: 3 additions & 1 deletion lib/rules/no-extra-parens.js
Expand Up @@ -418,6 +418,7 @@ module.exports = {
function checkExpressionOrExportStatement(node) {
const firstToken = isParenthesised(node) ? sourceCode.getTokenBefore(node) : sourceCode.getFirstToken(node);
const secondToken = sourceCode.getTokenAfter(firstToken, astUtils.isNotOpeningParenToken);
const thirdToken = secondToken ? sourceCode.getTokenAfter(secondToken) : null;

if (
astUtils.isOpeningParenToken(firstToken) &&
Expand All @@ -427,7 +428,8 @@ module.exports = {
secondToken.value === "function" ||
secondToken.value === "class" ||
secondToken.value === "let" && astUtils.isOpeningBracketToken(sourceCode.getTokenAfter(secondToken, astUtils.isNotClosingParenToken))
)
) ||
secondToken && secondToken.type === "Identifier" && secondToken.value === "async" && thirdToken && thirdToken.type === "Keyword" && thirdToken.value === "function"
)
) {
tokensToIgnore.add(secondToken);
Expand Down

0 comments on commit 78a85e0

Please sign in to comment.