Skip to content

Commit 6a03a32

Browse files
hshoffljharb
authored andcommitted
[eslint-v2][arrow functions] add no-confusing-arrow rule
1 parent 172dffb commit 6a03a32

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,19 @@ Other Style Guides
817817
});
818818
```
819819
820+
- [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)
821+
822+
```js
823+
// bad
824+
const isActive = item => item.height > 256 ? true : false;
825+
826+
// bad
827+
const isActive = (item) => item.height > 256 ? true : false;
828+
829+
// good
830+
const isActive = item => { return item.height > 256 ? true : false; }
831+
```
832+
820833
**[⬆ back to top](#table-of-contents)**
821834
822835

packages/eslint-config-airbnb/rules/es6.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ module.exports = {
2828
'generator-star-spacing': 0,
2929
// disallow modifying variables of class declarations
3030
'no-class-assign': 0,
31+
// disallow arrow functions where they could be confused with comparisons
32+
// http://eslint.org/docs/rules/no-confusing-arrow
33+
'no-confusing-arrow': 2,
3134
// disallow modifying variables that are declared using const
3235
'no-const-assign': 2,
3336
// disallow specific imports

0 commit comments

Comments
 (0)