lib/rules/comma-spacing.js
function report(node, loc, otherNode) {
            context.report({
                node,
                fix(fixer) {
                    if (options[loc]) {
                        if (loc === "before") {
                            return fixer.insertTextBefore(node, " ");
                        }
                        return fixer.insertTextAfter(node, " ");

                    }
                    let start, end;
                    const newText = "";

                    if (loc === "before") {
                        start = otherNode.range[1];
                        end = node.range[0];
                    } else {
                        start = node.range[1];
                        end = otherNode.range[0];
                    }

                    return fixer.replaceTextRange([start, end], newText);

                },
                messageId: options[loc] ? "missing" : "unexpected",
                data: {
                    loc
                }
            });
        }
function report(node, loc, otherNode) {
            context.report({
                node,
                fix(fixer) {
                    if (options[loc]) {
                        if (loc === "before") {
                            return fixer.insertTextBefore(node, " ");
                        }
                        return fixer.insertTextAfter(node, " ");

                    }
                    let start, end;
                    const newText = "";

                    if (loc === "before") {
                        start = otherNode.range[1];
                        end = node.range[0];
                    } else {
                        start = node.range[1];
                        end = otherNode.range[0];
                    }

                    return fixer.replaceTextRange([start, end], newText);

                },
                messageId: options[loc] ? "missing" : "unexpected",
                data: {
                    loc
                }
            });
        }
function report ( node , loc , otherNode ) { context . report ( { node , fix ( fixer ) { if ( options [ loc ] ) { if ( loc === "before" ) { return fixer . insertTextBefore ( node , " " ) ; } return fixer . insertTextAfter ( node , " " ) ; } let start , end ; const newText = "" ; if ( loc === "before" ) { start = otherNode . range [ 1 ] ; end = node . range [ 0 ] ; } else { start = node . range [ 1 ] ; end = otherNode . range [ 0 ] ; } return fixer . replaceTextRange ( [ start , end ] , newText ) ; } , messageId : options [ loc ] ? "missing" : "unexpected" , data : { loc } } ) ; }
Reports a spacing error with an appropriate message.
@param {ASTNode} node The binary expression node to report.
@param {string} loc Is the error "before" or "after" the comma?
@param {ASTNode} otherNode The node at the left or right of `node`
@returns {void}
@private
Reports a spacing error with an appropriate message .