lib/rules/newline-before-return.js
function canFix(node) {
            const leadingComments = sourceCode.getCommentsBefore(node);
            const lastLeadingComment = leadingComments[leadingComments.length - 1];
            const tokenBefore = sourceCode.getTokenBefore(node);

            if (leadingComments.length === 0) {
                return true;
            }

            /*
             * if the last leading comment ends in the same line as the previous token and
             * does not share a line with the `return` node, we can consider it safe to fix.
             * Example:
             * function a() {
             *     var b; //comment
             *     return;
             * }
             */
            if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line &&
                lastLeadingComment.loc.end.line !== node.loc.start.line) {
                return true;
            }

            return false;
        }
function canFix(node) {
            const leadingComments = sourceCode.getCommentsBefore(node);
            const lastLeadingComment = leadingComments[leadingComments.length - 1];
            const tokenBefore = sourceCode.getTokenBefore(node);

            if (leadingComments.length === 0) {
                return true;
            }

            /*
             * if the last leading comment ends in the same line as the previous token and
             * does not share a line with the `return` node, we can consider it safe to fix.
             * Example:
             * function a() {
             *     var b; //comment
             *     return;
             * }
             */
            if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line &&
                lastLeadingComment.loc.end.line !== node.loc.start.line) {
                return true;
            }

            return false;
        }
function canFix ( node ) { const leadingComments = sourceCode . getCommentsBefore ( node ) ; const lastLeadingComment = leadingComments [ leadingComments . length - 1 ] ; const tokenBefore = sourceCode . getTokenBefore ( node ) ; if ( leadingComments . length === 0 ) { return true ; } /*
             * if the last leading comment ends in the same line as the previous token and
             * does not share a line with the `return` node, we can consider it safe to fix.
             * Example:
             * function a() {
             *     var b; //comment
             *     return;
             * }
             */ if ( lastLeadingComment . loc . end . line === tokenBefore . loc . end . line && lastLeadingComment . loc . end . line !== node . loc . start . line ) { return true ; } return false ; }
Checks whether it is safe to apply a fix to a given return statement.

The fix is not considered safe if the given return statement has leading comments,
as we cannot safely determine if the newline should be added before or after the comments.
For more information, see: https://github.com/eslint/eslint/issues/5958#issuecomment-222767211

@param {ASTNode} node - The return statement node to check.
@returns {boolean} `true` if it can fix the node.
@private
Checks whether it is safe to apply a fix to a given return statement .