Skip to content

Commit

Permalink
Update: add fix for no-confusing-arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
tikotzky committed Mar 28, 2017
1 parent 0541eaf commit e77c0db
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/rules/no-confusing-arrow.js
Expand Up @@ -33,6 +33,8 @@ module.exports = {
recommended: false
},

fixable: "code",

schema: [{
type: "object",
properties: {
Expand All @@ -55,7 +57,15 @@ module.exports = {
const body = node.body;

if (isConditional(body) && !(config.allowParens && astUtils.isParenthesised(sourceCode, body))) {
context.report({ node, message: "Arrow function used ambiguously with a conditional expression." });
context.report({
node,
message: "Arrow function used ambiguously with a conditional expression.",
fix(fixer) {

// if `allowParens` is not set to true dont bother wrapping in parens
return config.allowParens && fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`);
}
});
}
}

Expand Down

0 comments on commit e77c0db

Please sign in to comment.