Javascript: Conflicting rules 'no-confusing-arrow' and 'arrow-body-style'

Created on 22 Feb 2016  路  5Comments  路  Source: airbnb/javascript

Currently I'm using eslint with the airbnb config to lint my project. However since the last update (6.0.1) i've found somewhat conflicting rules, the 'no-confusing-arrow' rule and the 'arrow-body-style' rule.

Take this piece of code:

export const conflict = (a) => a > 1 ? 'yes' : 'no';

This triggers the no-confusing-arrow rule.

According to the rule it should be written as following:

export const conflict = (a) => {
  return a > 1 ? 'yes' : 'no';
};

However this triggers the arrow-body-style rule.

Any idea how to solve this while keeping the shorthand if?

Versions used:

"eslint": "^2.2.0",
"eslint-config-airbnb": "^6.0.1",

Most helpful comment

Does it work if you use parentheses?

export const conflict = (a) => (a > 1 ? 'yes' : 'no');

All 5 comments

Does it work if you use parentheses?

export const conflict = (a) => (a > 1 ? 'yes' : 'no');

Adding parentheses still triggers no-confusing-arrow for me.

Looks like this is also an eslint bug.

I'll disable no-confusing-arrow until they've fixed it - will release a patch later today.

Published as v6.0.2

    export const conflict = a => (a > 1 ? 'yes' : 'no')

worked for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

graingert picture graingert  路  3Comments

tpiros picture tpiros  路  3Comments

brendanvinson picture brendanvinson  路  4Comments

ar
mbifulco picture mbifulco  路  3Comments

tunnckoCore picture tunnckoCore  路  3Comments