[eslint-v2][arrow functions] add no-confusing-arrow rule

This commit is contained in:
Harrison Shoff
2016-02-14 14:47:23 -08:00
committed by Jordan Harband
parent 172dffbb52
commit 6a03a32915
2 changed files with 16 additions and 0 deletions

View File

@@ -817,6 +817,19 @@ Other Style Guides
});
```
- [8.5](#8.5) <a name='8.5'></a> Avoid confusing arrow function syntax (`=>`) with comparison operators (`<=`, `>=`). eslint: [no-confusing-arrow](http://eslint.org/docs/rules/no-confusing-arrow)
```js
// bad
const isActive = item => item.height > 256 ? true : false;
// bad
const isActive = (item) => item.height > 256 ? true : false;
// good
const isActive = item => { return item.height > 256 ? true : false; }
```
**[⬆ back to top](#table-of-contents)**

View File

@@ -28,6 +28,9 @@ module.exports = {
'generator-star-spacing': 0,
// disallow modifying variables of class declarations
'no-class-assign': 0,
// disallow arrow functions where they could be confused with comparisons
// http://eslint.org/docs/rules/no-confusing-arrow
'no-confusing-arrow': 2,
// disallow modifying variables that are declared using const
'no-const-assign': 2,
// disallow specific imports