lib/rules/no-unused-vars.js
function getRhsNode(ref, prevRhsNode) {
            const id = ref.identifier;
            const parent = id.parent;
            const granpa = parent.parent;
            const refScope = ref.from.variableScope;
            const varScope = ref.resolved.scope.variableScope;
            const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id);

            /*
             * Inherits the previous node if this reference is in the node.
             * This is for `a = a + a`-like code.
             */
            if (prevRhsNode && isInside(id, prevRhsNode)) {
                return prevRhsNode;
            }

            if (parent.type === "AssignmentExpression" &&
                granpa.type === "ExpressionStatement" &&
                id === parent.left &&
                !canBeUsedLater
            ) {
                return parent.right;
            }
            return null;
        }
function getRhsNode(ref, prevRhsNode) {
            const id = ref.identifier;
            const parent = id.parent;
            const granpa = parent.parent;
            const refScope = ref.from.variableScope;
            const varScope = ref.resolved.scope.variableScope;
            const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id);

            /*
             * Inherits the previous node if this reference is in the node.
             * This is for `a = a + a`-like code.
             */
            if (prevRhsNode && isInside(id, prevRhsNode)) {
                return prevRhsNode;
            }

            if (parent.type === "AssignmentExpression" &&
                granpa.type === "ExpressionStatement" &&
                id === parent.left &&
                !canBeUsedLater
            ) {
                return parent.right;
            }
            return null;
        }
function getRhsNode ( ref , prevRhsNode ) { const id = ref . identifier ; const parent = id . parent ; const granpa = parent . parent ; const refScope = ref . from . variableScope ; const varScope = ref . resolved . scope . variableScope ; const canBeUsedLater = refScope !== varScope || astUtils . isInLoop ( id ) ; /*
             * Inherits the previous node if this reference is in the node.
             * This is for `a = a + a`-like code.
             */ if ( prevRhsNode && isInside ( id , prevRhsNode ) ) { return prevRhsNode ; } if ( parent . type === "AssignmentExpression" && granpa . type === "ExpressionStatement" && id === parent . left && ! canBeUsedLater ) { return parent . right ; } return null ; }
If a given reference is left-hand side of an assignment, this gets
the right-hand side node of the assignment.

In the following cases, this returns null.

- The reference is not the LHS of an assignment expression.
- The reference is inside of a loop.
- The reference is inside of a function scope which is different from
the declaration.

@param {eslint-scope.Reference} ref - A reference to check.
@param {ASTNode} prevRhsNode - The previous RHS node.
@returns {ASTNode|null} The RHS node or null.
@private
If a given reference is left - hand side of an assignment this gets the right - hand side node of the assignment .