lib/rules/no-use-before-define.js
function isInInitializer(variable, reference) {
    if (variable.scope !== reference.from) {
        return false;
    }

    let node = variable.identifiers[0].parent;
    const location = reference.identifier.range[1];

    while (node) {
        if (node.type === "VariableDeclarator") {
            if (isInRange(node.init, location)) {
                return true;
            }
            if (FOR_IN_OF_TYPE.test(node.parent.parent.type) &&
                isInRange(node.parent.parent.right, location)
            ) {
                return true;
            }
            break;
        } else if (node.type === "AssignmentPattern") {
            if (isInRange(node.right, location)) {
                return true;
            }
        } else if (SENTINEL_TYPE.test(node.type)) {
            break;
        }

        node = node.parent;
    }

    return false;
}
function isInInitializer(variable, reference) {
    if (variable.scope !== reference.from) {
        return false;
    }

    let node = variable.identifiers[0].parent;
    const location = reference.identifier.range[1];

    while (node) {
        if (node.type === "VariableDeclarator") {
            if (isInRange(node.init, location)) {
                return true;
            }
            if (FOR_IN_OF_TYPE.test(node.parent.parent.type) &&
                isInRange(node.parent.parent.right, location)
            ) {
                return true;
            }
            break;
        } else if (node.type === "AssignmentPattern") {
            if (isInRange(node.right, location)) {
                return true;
            }
        } else if (SENTINEL_TYPE.test(node.type)) {
            break;
        }

        node = node.parent;
    }

    return false;
}
function isInInitializer ( variable , reference ) { if ( variable . scope !== reference . from ) { return false ; } let node = variable . identifiers [ 0 ] . parent ; const location = reference . identifier . range [ 1 ] ; while ( node ) { if ( node . type === "VariableDeclarator" ) { if ( isInRange ( node . init , location ) ) { return true ; } if ( FOR_IN_OF_TYPE . test ( node . parent . parent . type ) && isInRange ( node . parent . parent . right , location ) ) { return true ; } break ; } else if ( node . type === "AssignmentPattern" ) { if ( isInRange ( node . right , location ) ) { return true ; } } else if ( SENTINEL_TYPE . test ( node . type ) ) { break ; } node = node . parent ; } return false ; }
Checks whether or not a given reference is inside of the initializers of a given variable.

This returns `true` in the following cases:

var a = a
var [a = a] = list
var {a = a} = obj
for (var a in a) {}
for (var a of a) {}

@param {Variable} variable - A variable to check.
@param {Reference} reference - A reference to check.
@returns {boolean} `true` if the reference is inside of the initializers.
Checks whether or not a given reference is inside of the initializers of a given variable .