From d12c0441e50a68815dcaa755739780f7bef35919 Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 19 May 2020 16:04:10 +0800 Subject: [PATCH] Style --- rules/prefer-array-find.js | 6 +++--- test/prefer-array-find.js | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rules/prefer-array-find.js b/rules/prefer-array-find.js index 5a7376f0f9..191f4dfe03 100644 --- a/rules/prefer-array-find.js +++ b/rules/prefer-array-find.js @@ -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 { @@ -141,7 +141,7 @@ const fixDestructuring = (source, node) => { fixer.insertTextAfter(right, ` ${operator} ${defaultValueText}`), needParenthesize && fixer.insertTextAfter(node, ')') ].filter(Boolean); - } + }; return { suggest: [ @@ -152,7 +152,7 @@ const fixDestructuring = (source, node) => { { messageId: MESSAGE_ID_USE_LOGICAL_OR_OPERATOR, fix: fix('||') - }, + } ] }; }; diff --git a/test/prefer-array-find.js b/test/prefer-array-find.js index 7fde3509b5..137c5553f2 100644 --- a/test/prefer-array-find.js +++ b/test/prefer-array-find.js @@ -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); @@ -616,7 +616,7 @@ ruleTester.run('prefer-array-find', rule, { } `, errors: [{messageId: MESSAGE_ID_DECLARATION}] - }, + } ] });