lib/formatters/codeframe.js
function formatMessage(message, parentResult) {
    const type = (message.fatal || message.severity === 2) ? chalk.red("error") : chalk.yellow("warning");
    const msg = `${chalk.bold(message.message.replace(/([^ ])\.$/u, "$1"))}`;
    const ruleId = message.fatal ? "" : chalk.dim(`(${message.ruleId})`);
    const filePath = formatFilePath(parentResult.filePath, message.line, message.column);
    const sourceCode = parentResult.output ? parentResult.output : parentResult.source;

    const firstLine = [
        `${type}:`,
        `${msg}`,
        ruleId ? `${ruleId}` : "",
        sourceCode ? `at ${filePath}:` : `at ${filePath}`
    ].filter(String).join(" ");

    const result = [firstLine];

    if (sourceCode) {
        result.push(
            codeFrameColumns(sourceCode, { start: { line: message.line, column: message.column } }, { highlightCode: false })
        );
    }

    return result.join("\n");
}
function formatMessage(message, parentResult) {
    const type = (message.fatal || message.severity === 2) ? chalk.red("error") : chalk.yellow("warning");
    const msg = `${chalk.bold(message.message.replace(/([^ ])\.$/u, "$1"))}`;
    const ruleId = message.fatal ? "" : chalk.dim(`(${message.ruleId})`);
    const filePath = formatFilePath(parentResult.filePath, message.line, message.column);
    const sourceCode = parentResult.output ? parentResult.output : parentResult.source;

    const firstLine = [
        `${type}:`,
        `${msg}`,
        ruleId ? `${ruleId}` : "",
        sourceCode ? `at ${filePath}:` : `at ${filePath}`
    ].filter(String).join(" ");

    const result = [firstLine];

    if (sourceCode) {
        result.push(
            codeFrameColumns(sourceCode, { start: { line: message.line, column: message.column } }, { highlightCode: false })
        );
    }

    return result.join("\n");
}
function formatMessage ( message , parentResult ) { const type = ( message . fatal || message . severity === 2 ) ? chalk . red ( "error" ) : chalk . yellow ( "warning" ) ; const msg = ` ${ chalk . bold ( message . message . replace ( / ([^ ])\.$ / u , "$1" ) ) } ` ; const ruleId = message . fatal ? "" : chalk . dim ( ` ${ message . ruleId } ` ) ; const filePath = formatFilePath ( parentResult . filePath , message . line , message . column ) ; const sourceCode = parentResult . output ? parentResult . output : parentResult . source ; const firstLine = [ ` ${ type } ` , ` ${ msg } ` , ruleId ? ` ${ ruleId } ` : "" , sourceCode ? ` ${ filePath } ` : ` ${ filePath } ` ] . filter ( String ) . join ( " " ) ; const result = [ firstLine ] ; if ( sourceCode ) { result . push ( codeFrameColumns ( sourceCode , { start : { line : message . line , column : message . column } } , { highlightCode : false } ) ) ; } return result . join ( "\n" ) ; }
Gets the formatted output for a given message.
@param   {Object} message      The object that represents this message.
@param   {Object} parentResult The result object that this message belongs to.
@returns {string}              The formatted output.
Gets the formatted output for a given message .