lib/rules/vars-on-top.js
function isVarOnTop(node, statements) {
            const l = statements.length;
            let i = 0;

            // skip over directives
            for (; i < l; ++i) {
                if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) {
                    break;
                }
            }

            for (; i < l; ++i) {
                if (!isVariableDeclaration(statements[i])) {
                    return false;
                }
                if (statements[i] === node) {
                    return true;
                }
            }

            return false;
        }
function isVarOnTop(node, statements) {
            const l = statements.length;
            let i = 0;

            // skip over directives
            for (; i < l; ++i) {
                if (!looksLikeDirective(statements[i]) && !looksLikeImport(statements[i])) {
                    break;
                }
            }

            for (; i < l; ++i) {
                if (!isVariableDeclaration(statements[i])) {
                    return false;
                }
                if (statements[i] === node) {
                    return true;
                }
            }

            return false;
        }
function isVarOnTop ( node , statements ) { const l = statements . length ; let i = 0 ; // skip over directives for ( ; i < l ; ++ i ) { if ( ! looksLikeDirective ( statements [ i ] ) && ! looksLikeImport ( statements [ i ] ) ) { break ; } } for ( ; i < l ; ++ i ) { if ( ! isVariableDeclaration ( statements [ i ] ) ) { return false ; } if ( statements [ i ] === node ) { return true ; } } return false ; }
Checks whether this variable is on top of the block body
@param {ASTNode} node - The node to check
@param {ASTNode[]} statements - collection of ASTNodes for the parent node block
@returns {boolean} True if var is on top otherwise false
Checks whether this variable is on top of the block body