jhen0409 / react-chrome-extension-boilerplate

Boilerplate for Chrome Extension React.js project
MIT License
2.14k stars 388 forks source link

jslint: Arrow function used ambiguously with a conditional expression #34

Closed tommedema closed 8 years ago

tommedema commented 8 years ago

Since npm run lint is one of the commands of this boilerplate, it would be a good idea to deal with all jslint errors. I'm having issues resolving this:

/app/components/MainSection.js
  73:41  error  Arrow function used ambiguously with a conditional expression  no-confusing-arrow

The relevant code is:

const completedCount = todos.reduce((count, todo) =>
      todo.completed ? count + 1 : count,
      0
    );

It seems as though jslint doesn't like arrow functions with a conditional expression. I've tried other ways, such as a traditional function, but these resulted in other jslint errors.

jhen0409 commented 8 years ago

Hey Tom, thank you for report! It looks related to this, it enabled no-confusing-arrow, and it released by eslint-config-airbnb@6.2.0.

I'll fix these with:

(count, todo) => (todo.completed ? count + 1 : count)