lib/rules/spaced-comment.js
function checkCommentForSpace(node) {
            const type = node.type.toLowerCase(),
                rule = styleRules[type],
                commentIdentifier = type === "block" ? "/*" : "//";

            // Ignores empty comments.
            if (node.value.length === 0) {
                return;
            }

            const beginMatch = rule.beginRegex.exec(node.value);
            const endMatch = rule.endRegex.exec(node.value);

            // Checks.
            if (requireSpace) {
                if (!beginMatch) {
                    const hasMarker = rule.markers.exec(node.value);
                    const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier;

                    if (rule.hasExceptions) {
                        reportBegin(node, "Expected exception block, space or tab after '{{refChar}}' in comment.", hasMarker, marker);
                    } else {
                        reportBegin(node, "Expected space or tab after '{{refChar}}' in comment.", hasMarker, marker);
                    }
                }

                if (balanced && type === "block" && !endMatch) {
                    reportEnd(node, "Expected space or tab before '*/' in comment.");
                }
            } else {
                if (beginMatch) {
                    if (!beginMatch[1]) {
                        reportBegin(node, "Unexpected space or tab after '{{refChar}}' in comment.", beginMatch, commentIdentifier);
                    } else {
                        reportBegin(node, "Unexpected space or tab after marker ({{refChar}}) in comment.", beginMatch, beginMatch[1]);
                    }
                }

                if (balanced && type === "block" && endMatch) {
                    reportEnd(node, "Unexpected space or tab before '*/' in comment.", endMatch);
                }
            }
        }
function checkCommentForSpace(node) {
            const type = node.type.toLowerCase(),
                rule = styleRules[type],
                commentIdentifier = type === "block" ? "/*" : "//";

            // Ignores empty comments.
            if (node.value.length === 0) {
                return;
            }

            const beginMatch = rule.beginRegex.exec(node.value);
            const endMatch = rule.endRegex.exec(node.value);

            // Checks.
            if (requireSpace) {
                if (!beginMatch) {
                    const hasMarker = rule.markers.exec(node.value);
                    const marker = hasMarker ? commentIdentifier + hasMarker[0] : commentIdentifier;

                    if (rule.hasExceptions) {
                        reportBegin(node, "Expected exception block, space or tab after '{{refChar}}' in comment.", hasMarker, marker);
                    } else {
                        reportBegin(node, "Expected space or tab after '{{refChar}}' in comment.", hasMarker, marker);
                    }
                }

                if (balanced && type === "block" && !endMatch) {
                    reportEnd(node, "Expected space or tab before '*/' in comment.");
                }
            } else {
                if (beginMatch) {
                    if (!beginMatch[1]) {
                        reportBegin(node, "Unexpected space or tab after '{{refChar}}' in comment.", beginMatch, commentIdentifier);
                    } else {
                        reportBegin(node, "Unexpected space or tab after marker ({{refChar}}) in comment.", beginMatch, beginMatch[1]);
                    }
                }

                if (balanced && type === "block" && endMatch) {
                    reportEnd(node, "Unexpected space or tab before '*/' in comment.", endMatch);
                }
            }
        }
function checkCommentForSpace ( node ) { const type = node . type . toLowerCase ( ) , rule = styleRules [ type ] , commentIdentifier = type === "block" ? "/*" : "//" ; // Ignores empty comments. if ( node . value . length === 0 ) { return ; } const beginMatch = rule . beginRegex . exec ( node . value ) ; const endMatch = rule . endRegex . exec ( node . value ) ; // Checks. if ( requireSpace ) { if ( ! beginMatch ) { const hasMarker = rule . markers . exec ( node . value ) ; const marker = hasMarker ? commentIdentifier + hasMarker [ 0 ] : commentIdentifier ; if ( rule . hasExceptions ) { reportBegin ( node , "Expected exception block, space or tab after '{{refChar}}' in comment." , hasMarker , marker ) ; } else { reportBegin ( node , "Expected space or tab after '{{refChar}}' in comment." , hasMarker , marker ) ; } } if ( balanced && type === "block" && ! endMatch ) { reportEnd ( node , "Expected space or tab before '*/' in comment." ) ; } } else { if ( beginMatch ) { if ( ! beginMatch [ 1 ] ) { reportBegin ( node , "Unexpected space or tab after '{{refChar}}' in comment." , beginMatch , commentIdentifier ) ; } else { reportBegin ( node , "Unexpected space or tab after marker ({{refChar}}) in comment." , beginMatch , beginMatch [ 1 ] ) ; } } if ( balanced && type === "block" && endMatch ) { reportEnd ( node , "Unexpected space or tab before '*/' in comment." , endMatch ) ; } } }
Reports a given comment if it's invalid.
@param {ASTNode} node - a comment node to check.
@returns {void}
Reports a given comment if it s invalid .