mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 04:08:02 -05:00
[eslint-v2][arrow functions] add no-confusing-arrow rule
This commit is contained in:
committed by
Jordan Harband
parent
172dffbb52
commit
6a03a32915
13
README.md
13
README.md
@@ -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)**
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user