From 4b9f1a2e392f67a6205c31294b66e0a54618024a Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Wed, 22 Aug 2018 15:19:21 +0300 Subject: [PATCH] feat(rules): omit arrow function parens unless they are necessary Remove `requireForBlockBody` option of `arrow-body-style` rule. BREAKING CHANGE: previously, only arrow functions consisting of a single expression were allowed to omit parentheses around the parameter list (and required to, if there's only one parameter in the list). After this change, the parens are only allowed when they are required syntactically. Before: ```js const f = x => x; const g = (x, y) => x + y; const h = (x) => { console.log(x); }; const i = (x, f) => { f(x); }; ``` After: ```js // Not affected const f = x => x; // Not affected const g = (x, y) => x + y; // AFFECTED const h = x => { console.log(x); }; // Not affected const i = (x, f) => { f(x); }; ``` This rule is fixable via `eslint --fix`. Refs: https://github.com/metarhia/Metarhia/issues/22 --- rules/ecmascript-6.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/rules/ecmascript-6.js b/rules/ecmascript-6.js index ee32bba..03ac5cd 100644 --- a/rules/ecmascript-6.js +++ b/rules/ecmascript-6.js @@ -12,9 +12,6 @@ module.exports = { 'arrow-parens': [ 'error', 'as-needed', - { - requireForBlockBody: true, - }, ], 'arrow-spacing': [ 'error',