Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rules): omit arrow function parens unless they are necessary #11

Merged
merged 1 commit into from
Aug 22, 2018

Conversation

aqrln
Copy link
Member

@aqrln aqrln commented Aug 22, 2018

Remove requireForBlockBody option of arrow-parens 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:

const f = x => x;

const g = (x, y) => x + y;

const h = (x) => {
  console.log(x);
};

const i = (x, f) => {
  f(x);
};

After:

// 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

/cc @tshemsedinov @lundibundi @nechaido @belochub @alinkedd @JuliaGerasymenko

Copy link
Member

@lundibundi lundibundi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM either way.

Remove `requireForBlockBody` option of `arrow-parens` 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
@aqrln aqrln force-pushed the feat-rules-omit-arrow-parens-unless-necessary branch from 4b9f1a2 to 9e8999d Compare August 22, 2018 12:58
@aqrln aqrln merged commit 16d56e4 into master Aug 22, 2018
@aqrln aqrln deleted the feat-rules-omit-arrow-parens-unless-necessary branch August 22, 2018 17:01
@aqrln
Copy link
Member Author

aqrln commented Aug 22, 2018

Released and published to npm as v4.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants