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

Conflicting rules 'no-confusing-arrow' and 'arrow-body-style' #752

Closed
robbinjanssen opened this issue Feb 22, 2016 · 5 comments
Closed

Conflicting rules 'no-confusing-arrow' and 'arrow-body-style' #752

robbinjanssen opened this issue Feb 22, 2016 · 5 comments

Comments

@robbinjanssen
Copy link

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",
@lencioni
Copy link
Contributor

Does it work if you use parentheses?

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

@elliottsj
Copy link

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

@ljharb
Copy link
Collaborator

ljharb commented Feb 22, 2016

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.

@ljharb ljharb closed this as completed in 33f1ddb Feb 22, 2016
@ljharb
Copy link
Collaborator

ljharb commented Feb 22, 2016

Published as v6.0.2

ljharb added a commit that referenced this issue Mar 21, 2016
gilbox pushed a commit to gilbox/javascript that referenced this issue Mar 21, 2016
jaylaw81 pushed a commit to appirio-digital/ads-best-practices that referenced this issue Sep 19, 2017
jaylaw81 pushed a commit to appirio-digital/ads-best-practices that referenced this issue Sep 19, 2017
@tb
Copy link

tb commented Dec 13, 2017

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

worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants