Skip to content

Commit

Permalink
feat(rules): omit arrow function parens unless they are necessary
Browse files Browse the repository at this point in the history
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: metarhia/Metarhia#22
  • Loading branch information
aqrln committed Aug 22, 2018
1 parent d6d7ee1 commit 4b9f1a2
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions rules/ecmascript-6.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ module.exports = {
'arrow-parens': [
'error',
'as-needed',
{
requireForBlockBody: true,
},
],
'arrow-spacing': [
'error',
Expand Down

0 comments on commit 4b9f1a2

Please sign in to comment.