lib/rules/semi-spacing.js
function checkSemicolonSpacing(token, node) {
            if (astUtils.isSemicolonToken(token)) {
                const location = token.loc.start;

                if (hasLeadingSpace(token)) {
                    if (!requireSpaceBefore) {
                        context.report({
                            node,
                            loc: location,
                            message: "Unexpected whitespace before semicolon.",
                            fix(fixer) {
                                const tokenBefore = sourceCode.getTokenBefore(token);

                                return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
                            }
                        });
                    }
                } else {
                    if (requireSpaceBefore) {
                        context.report({
                            node,
                            loc: location,
                            message: "Missing whitespace before semicolon.",
                            fix(fixer) {
                                return fixer.insertTextBefore(token, " ");
                            }
                        });
                    }
                }

                if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) {
                    if (hasTrailingSpace(token)) {
                        if (!requireSpaceAfter) {
                            context.report({
                                node,
                                loc: location,
                                message: "Unexpected whitespace after semicolon.",
                                fix(fixer) {
                                    const tokenAfter = sourceCode.getTokenAfter(token);

                                    return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
                                }
                            });
                        }
                    } else {
                        if (requireSpaceAfter) {
                            context.report({
                                node,
                                loc: location,
                                message: "Missing whitespace after semicolon.",
                                fix(fixer) {
                                    return fixer.insertTextAfter(token, " ");
                                }
                            });
                        }
                    }
                }
            }
        }
function checkSemicolonSpacing(token, node) {
            if (astUtils.isSemicolonToken(token)) {
                const location = token.loc.start;

                if (hasLeadingSpace(token)) {
                    if (!requireSpaceBefore) {
                        context.report({
                            node,
                            loc: location,
                            message: "Unexpected whitespace before semicolon.",
                            fix(fixer) {
                                const tokenBefore = sourceCode.getTokenBefore(token);

                                return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
                            }
                        });
                    }
                } else {
                    if (requireSpaceBefore) {
                        context.report({
                            node,
                            loc: location,
                            message: "Missing whitespace before semicolon.",
                            fix(fixer) {
                                return fixer.insertTextBefore(token, " ");
                            }
                        });
                    }
                }

                if (!isFirstTokenInCurrentLine(token) && !isLastTokenInCurrentLine(token) && !isBeforeClosingParen(token)) {
                    if (hasTrailingSpace(token)) {
                        if (!requireSpaceAfter) {
                            context.report({
                                node,
                                loc: location,
                                message: "Unexpected whitespace after semicolon.",
                                fix(fixer) {
                                    const tokenAfter = sourceCode.getTokenAfter(token);

                                    return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
                                }
                            });
                        }
                    } else {
                        if (requireSpaceAfter) {
                            context.report({
                                node,
                                loc: location,
                                message: "Missing whitespace after semicolon.",
                                fix(fixer) {
                                    return fixer.insertTextAfter(token, " ");
                                }
                            });
                        }
                    }
                }
            }
        }
function checkSemicolonSpacing ( token , node ) { if ( astUtils . isSemicolonToken ( token ) ) { const location = token . loc . start ; if ( hasLeadingSpace ( token ) ) { if ( ! requireSpaceBefore ) { context . report ( { node , loc : location , message : "Unexpected whitespace before semicolon." , fix ( fixer ) { const tokenBefore = sourceCode . getTokenBefore ( token ) ; return fixer . removeRange ( [ tokenBefore . range [ 1 ] , token . range [ 0 ] ] ) ; } } ) ; } } else { if ( requireSpaceBefore ) { context . report ( { node , loc : location , message : "Missing whitespace before semicolon." , fix ( fixer ) { return fixer . insertTextBefore ( token , " " ) ; } } ) ; } } if ( ! isFirstTokenInCurrentLine ( token ) && ! isLastTokenInCurrentLine ( token ) && ! isBeforeClosingParen ( token ) ) { if ( hasTrailingSpace ( token ) ) { if ( ! requireSpaceAfter ) { context . report ( { node , loc : location , message : "Unexpected whitespace after semicolon." , fix ( fixer ) { const tokenAfter = sourceCode . getTokenAfter ( token ) ; return fixer . removeRange ( [ token . range [ 1 ] , tokenAfter . range [ 0 ] ] ) ; } } ) ; } } else { if ( requireSpaceAfter ) { context . report ( { node , loc : location , message : "Missing whitespace after semicolon." , fix ( fixer ) { return fixer . insertTextAfter ( token , " " ) ; } } ) ; } } } } }
Reports if the given token has invalid spacing.
@param {Token} token The semicolon token to check.
@param {ASTNode} node The corresponding node of the token.
@returns {void}
Reports if the given token has invalid spacing .