lib/rules/consistent-return.js
function checkLastSegment(node) {
            let loc, name;

            /*
             * Skip if it expected no return value or unreachable.
             * When unreachable, all paths are returned or thrown.
             */
            if (!funcInfo.hasReturnValue ||
                funcInfo.codePath.currentSegments.every(isUnreachable) ||
                astUtils.isES5Constructor(node) ||
                isClassConstructor(node)
            ) {
                return;
            }

            // Adjust a location and a message.
            if (node.type === "Program") {

                // The head of program.
                loc = { line: 1, column: 0 };
                name = "program";
            } else if (node.type === "ArrowFunctionExpression") {

                // `=>` token
                loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
            } else if (
                node.parent.type === "MethodDefinition" ||
                (node.parent.type === "Property" && node.parent.method)
            ) {

                // Method name.
                loc = node.parent.key.loc.start;
            } else {

                // Function name or `function` keyword.
                loc = (node.id || node).loc.start;
            }

            if (!name) {
                name = astUtils.getFunctionNameWithKind(node);
            }

            // Reports.
            context.report({
                node,
                loc,
                messageId: "missingReturn",
                data: { name }
            });
        }
function checkLastSegment(node) {
            let loc, name;

            /*
             * Skip if it expected no return value or unreachable.
             * When unreachable, all paths are returned or thrown.
             */
            if (!funcInfo.hasReturnValue ||
                funcInfo.codePath.currentSegments.every(isUnreachable) ||
                astUtils.isES5Constructor(node) ||
                isClassConstructor(node)
            ) {
                return;
            }

            // Adjust a location and a message.
            if (node.type === "Program") {

                // The head of program.
                loc = { line: 1, column: 0 };
                name = "program";
            } else if (node.type === "ArrowFunctionExpression") {

                // `=>` token
                loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc.start;
            } else if (
                node.parent.type === "MethodDefinition" ||
                (node.parent.type === "Property" && node.parent.method)
            ) {

                // Method name.
                loc = node.parent.key.loc.start;
            } else {

                // Function name or `function` keyword.
                loc = (node.id || node).loc.start;
            }

            if (!name) {
                name = astUtils.getFunctionNameWithKind(node);
            }

            // Reports.
            context.report({
                node,
                loc,
                messageId: "missingReturn",
                data: { name }
            });
        }
function checkLastSegment ( node ) { let loc , name ; /*
             * Skip if it expected no return value or unreachable.
             * When unreachable, all paths are returned or thrown.
             */ if ( ! funcInfo . hasReturnValue || funcInfo . codePath . currentSegments . every ( isUnreachable ) || astUtils . isES5Constructor ( node ) || isClassConstructor ( node ) ) { return ; } // Adjust a location and a message. if ( node . type === "Program" ) { // The head of program. loc = { line : 1 , column : 0 } ; name = "program" ; } else if ( node . type === "ArrowFunctionExpression" ) { // `=>` token loc = context . getSourceCode ( ) . getTokenBefore ( node . body , astUtils . isArrowToken ) . loc . start ; } else if ( node . parent . type === "MethodDefinition" || ( node . parent . type === "Property" && node . parent . method ) ) { // Method name. loc = node . parent . key . loc . start ; } else { // Function name or `function` keyword. loc = ( node . id || node ) . loc . start ; } if ( ! name ) { name = astUtils . getFunctionNameWithKind ( node ) ; } // Reports. context . report ( { node , loc , messageId : "missingReturn" , data : { name } } ) ; }
Checks whether of not the implicit returning is consistent if the last
code path segment is reachable.

@param {ASTNode} node - A program/function node to check.
@returns {void}
Checks whether of not the implicit returning is consistent if the last code path segment is reachable .