lib/rules/prefer-const.js
function canBecomeVariableDeclaration(identifier) {
    let node = identifier.parent;

    while (PATTERN_TYPE.test(node.type)) {
        node = node.parent;
    }

    return (
        node.type === "VariableDeclarator" ||
        (
            node.type === "AssignmentExpression" &&
            node.parent.type === "ExpressionStatement" &&
            DECLARATION_HOST_TYPE.test(node.parent.parent.type)
        )
    );
}
function canBecomeVariableDeclaration(identifier) {
    let node = identifier.parent;

    while (PATTERN_TYPE.test(node.type)) {
        node = node.parent;
    }

    return (
        node.type === "VariableDeclarator" ||
        (
            node.type === "AssignmentExpression" &&
            node.parent.type === "ExpressionStatement" &&
            DECLARATION_HOST_TYPE.test(node.parent.parent.type)
        )
    );
}
function canBecomeVariableDeclaration ( identifier ) { let node = identifier . parent ; while ( PATTERN_TYPE . test ( node . type ) ) { node = node . parent ; } return ( node . type === "VariableDeclarator" || ( node . type === "AssignmentExpression" && node . parent . type === "ExpressionStatement" && DECLARATION_HOST_TYPE . test ( node . parent . parent . type ) ) ) ; }
Checks whether a given Identifier node becomes a VariableDeclaration or not.

@param {ASTNode} identifier - An Identifier node to check.
@returns {boolean} `true` if the node can become a VariableDeclaration.
Checks whether a given Identifier node becomes a VariableDeclaration or not .