Skip to content

Commit

Permalink
fix: ignore arrow functions with predicates in arrow-parens (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyleunderwood authored and gajus committed Jul 18, 2019
1 parent 94a9e8b commit 7560260
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/rules/arrowParens.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export default {
return;
}

// Similarly, a predicate always requires parens just like a return type
// does, and therefore this case can also be safely ignored.
if (node.predicate) {
return;
}

// "as-needed", { "requireForBlockBody": true }: x => x
if (
requireForBlockBody &&
Expand Down
2 changes: 2 additions & 0 deletions tests/rules/assertions/arrowParens.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ export default {
{code: '<T>(a: T) => { return a; }',
options: ['always', {requireForBlockBody: true}]},
{code: '<T>(a: T) => { return a; }',
options: ['as-needed', {requireForBlockBody: true}]},
{code: '(a): %checks => typeof a === "number"',
options: ['as-needed', {requireForBlockBody: true}]}

]
Expand Down

0 comments on commit 7560260

Please sign in to comment.