lib/rules/no-inner-declarations.js
function check(node) {
            const body = nearestBody(),
                valid = ((body.type === "Program" && body.distance === 1) ||
                    body.distance === 2);

            if (!valid) {
                context.report({
                    node,
                    message: "Move {{type}} declaration to {{body}} root.",
                    data: {
                        type: (node.type === "FunctionDeclaration" ? "function" : "variable"),
                        body: (body.type === "Program" ? "program" : "function body")
                    }
                });
            }
        }
function check(node) {
            const body = nearestBody(),
                valid = ((body.type === "Program" && body.distance === 1) ||
                    body.distance === 2);

            if (!valid) {
                context.report({
                    node,
                    message: "Move {{type}} declaration to {{body}} root.",
                    data: {
                        type: (node.type === "FunctionDeclaration" ? "function" : "variable"),
                        body: (body.type === "Program" ? "program" : "function body")
                    }
                });
            }
        }
function check ( node ) { const body = nearestBody ( ) , valid = ( ( body . type === "Program" && body . distance === 1 ) || body . distance === 2 ) ; if ( ! valid ) { context . report ( { node , message : "Move {{type}} declaration to {{body}} root." , data : { type : ( node . type === "FunctionDeclaration" ? "function" : "variable" ) , body : ( body . type === "Program" ? "program" : "function body" ) } } ) ; } }
Ensure that a given node is at a program or function body's root.
@param {ASTNode} node Declaration node to check.
@returns {void}
Ensure that a given node is at a program or function body s root .