From 7aa2dc456df50f7cb53aa46d871a7b1a9c0b92be Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 13 Mar 2020 16:54:50 +0800 Subject: [PATCH] `no-keyword-prefix`: Remove useless code (#601) --- rules/no-keyword-prefix.js | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/rules/no-keyword-prefix.js b/rules/no-keyword-prefix.js index 3ed48f7aed..0671b24a35 100644 --- a/rules/no-keyword-prefix.js +++ b/rules/no-keyword-prefix.js @@ -27,26 +27,6 @@ function findKeywordPrefix(name, options) { }); } -function isInsideObjectPattern(node) { - let current = node; - - while (current) { - const {parent} = current; - - if (parent && parent.type === 'Property' && parent.computed && parent.key === current) { - return false; - } - - if (current.type === 'ObjectPattern') { - return true; - } - - current = parent; - } - - return false; -} - function checkMemberExpression(report, node, options) { const {name} = node; const keyword = findKeywordPrefix(name, options); @@ -90,7 +70,7 @@ function checkObjectPattern(report, node, options) { const valueIsInvalid = node.parent.value.name && Boolean(keyword); // Ignore destructuring if the option is set, unless a new identifier is created - if (valueIsInvalid && !(assignmentKeyEqualsValue && options.ignoreDestructuring)) { + if (valueIsInvalid && !assignmentKeyEqualsValue) { report(node, keyword); } @@ -140,8 +120,7 @@ const create = context => { } if ( - !options.checkProperties || - (options.ignoreDestructuring && isInsideObjectPattern(node)) + !options.checkProperties ) { return; }