diff --git a/README.md b/README.md index 7290e0ac..e5ed8a37 100644 --- a/README.md +++ b/README.md @@ -817,6 +817,19 @@ Other Style Guides }); ``` + - [8.5](#8.5) 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)** diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 8ba6e5e3..88fbf2eb 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -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