Skip to content

Commit

Permalink
no-keyword-prefix: Remove useless code (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Mar 13, 2020
1 parent 350e3a6 commit 7aa2dc4
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions rules/no-keyword-prefix.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -140,8 +120,7 @@ const create = context => {
}

if (
!options.checkProperties ||
(options.ignoreDestructuring && isInsideObjectPattern(node))
!options.checkProperties
) {
return;
}
Expand Down

0 comments on commit 7aa2dc4

Please sign in to comment.