Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 19, 2020
1 parent 5ffb1e2 commit d12c044
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions rules/prefer-array-find.js
Expand Up @@ -113,7 +113,7 @@ const fixDestructuring = (source, node) => {
// `AssignmentExpression` always starts with `[` or `(`, so we don't need check ASI
const needParenthesize = isAssign &&
!isParenthesized(node, source) &&
assignmentNeedParenthesize(element.type !== 'AssignmentPattern' ? element : element.left);
assignmentNeedParenthesize(element.type === 'AssignmentPattern' ? element.left : element);

if (element.type !== 'AssignmentPattern') {
return {
Expand Down Expand Up @@ -141,7 +141,7 @@ const fixDestructuring = (source, node) => {
fixer.insertTextAfter(right, ` ${operator} ${defaultValueText}`),
needParenthesize && fixer.insertTextAfter(node, ')')
].filter(Boolean);
}
};

return {
suggest: [
Expand All @@ -152,7 +152,7 @@ const fixDestructuring = (source, node) => {
{
messageId: MESSAGE_ID_USE_LOGICAL_OR_OPERATOR,
fix: fix('||')
},
}
]
};
};
Expand Down
20 changes: 10 additions & 10 deletions test/prefer-array-find.js
Expand Up @@ -530,15 +530,15 @@ ruleTester.run('prefer-array-find', rule, {
// Test `const foo = array.filter(); foo[0];`
ruleTester.run('prefer-array-find', rule, {
valid: [
`const foo = array.find(bar), first = foo[0];`,
`const foo = array.filter(bar), first = foo[+0];`,
`const foo = array.filter(bar), first = a[foo][0];`,
`const foo = array.filter(bar), first = foo[-0];`,
`const foo = array.filter(bar), first = foo[1-1];`,
`const foo = array.filter(bar), first = foo["0"];`,
`const foo = array.filter(bar), first = foo.first;`,
`foo = array.filter(bar); const first = foo[+0];`,
`const {foo} = array.filter(bar), first = foo[0];`,
'const foo = array.find(bar), first = foo[0];',
'const foo = array.filter(bar), first = foo[+0];',
'const foo = array.filter(bar), first = a[foo][0];',
'const foo = array.filter(bar), first = foo[-0];',
'const foo = array.filter(bar), first = foo[1-1];',
'const foo = array.filter(bar), first = foo["0"];',
'const foo = array.filter(bar), first = foo.first;',
'foo = array.filter(bar); const first = foo[+0];',
'const {foo} = array.filter(bar), first = foo[0];',
outdent`
const foo = array.filter(bar);
doSomething(foo);
Expand Down Expand Up @@ -616,7 +616,7 @@ ruleTester.run('prefer-array-find', rule, {
}
`,
errors: [{messageId: MESSAGE_ID_DECLARATION}]
},
}
]
});

Expand Down

0 comments on commit d12c044

Please sign in to comment.