lib/rules/no-implicit-coercion.js
function report(node, recommendation, shouldFix) {
            context.report({
                node,
                message: "use `{{recommendation}}` instead.",
                data: {
                    recommendation
                },
                fix(fixer) {
                    if (!shouldFix) {
                        return null;
                    }

                    const tokenBefore = sourceCode.getTokenBefore(node);

                    if (
                        tokenBefore &&
                        tokenBefore.range[1] === node.range[0] &&
                        !astUtils.canTokensBeAdjacent(tokenBefore, recommendation)
                    ) {
                        return fixer.replaceText(node, ` ${recommendation}`);
                    }
                    return fixer.replaceText(node, recommendation);
                }
            });
        }
function report(node, recommendation, shouldFix) {
            context.report({
                node,
                message: "use `{{recommendation}}` instead.",
                data: {
                    recommendation
                },
                fix(fixer) {
                    if (!shouldFix) {
                        return null;
                    }

                    const tokenBefore = sourceCode.getTokenBefore(node);

                    if (
                        tokenBefore &&
                        tokenBefore.range[1] === node.range[0] &&
                        !astUtils.canTokensBeAdjacent(tokenBefore, recommendation)
                    ) {
                        return fixer.replaceText(node, ` ${recommendation}`);
                    }
                    return fixer.replaceText(node, recommendation);
                }
            });
        }
function report ( node , recommendation , shouldFix ) { context . report ( { node , message : "use `{{recommendation}}` instead." , data : { recommendation } , fix ( fixer ) { if ( ! shouldFix ) { return null ; } const tokenBefore = sourceCode . getTokenBefore ( node ) ; if ( tokenBefore && tokenBefore . range [ 1 ] === node . range [ 0 ] && ! astUtils . canTokensBeAdjacent ( tokenBefore , recommendation ) ) { return fixer . replaceText ( node , ` ${ recommendation } ` ) ; } return fixer . replaceText ( node , recommendation ) ; } } ) ; }
Reports an error and autofixes the node
@param {ASTNode} node - An ast node to report the error on.
@param {string} recommendation - The recommended code for the issue
@param {bool} shouldFix - Whether this report should fix the node
@returns {void}
Reports an error and autofixes the node