Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjuan committed Oct 30, 2023
1 parent 2981ff9 commit 1ffe49c
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions packages/eslint-plugin/src/util/collectUnusedVariables.ts
Expand Up @@ -441,15 +441,6 @@ function isExported(variable: TSESLint.Scope.Variable): boolean {

const LOGICAL_ASSIGNMENT_OPERATORS = new Set(['&&=', '||=', '??=']);

/**
* Checks whether the given operator is a logical assignment operator or not.
* @param operator The operator
* @returns True if the operator is a logical assignment operator.
*/
function isLogicalAssignmentOperator(operator: string): boolean {
return LOGICAL_ASSIGNMENT_OPERATORS.has(operator);
}

/**
* Determines if the variable is used.
* @param variable The variable to check.
Expand Down Expand Up @@ -712,7 +703,7 @@ function isUsedVariable(variable: TSESLint.Scope.Variable): boolean {
ref.isRead() && // in RHS of an assignment for itself. e.g. `a = a + 1`
// self update. e.g. `a += 1`, `a++`
((parent.type === AST_NODE_TYPES.AssignmentExpression &&
!isLogicalAssignmentOperator(parent.operator) &&
!LOGICAL_ASSIGNMENT_OPERATORS.has(parent.operator) &&
grandparent.type === AST_NODE_TYPES.ExpressionStatement &&
parent.left === id) ||
(parent.type === AST_NODE_TYPES.UpdateExpression &&
Expand Down

0 comments on commit 1ffe49c

Please sign in to comment.