Skip to content

Commit

Permalink
Output code warnings in yellow instead of red (palantir#3402)
Browse files Browse the repository at this point in the history
  • Loading branch information
jez9999 authored and ajafff committed Oct 27, 2017
1 parent 0176122 commit 965ecb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/formatters/codeFrameFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class Formatter extends AbstractFormatter {
}

let failureString = failure.getFailure();
failureString = chalk.red(failureString);
failureString = failure.getRuleSeverity() === "warning" ? chalk.yellow(failureString) : chalk.red(failureString);

// Rule
let ruleName = failure.getRuleName();
Expand Down
7 changes: 7 additions & 0 deletions test/formatters/codeFrameFormatterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe("CodeFrame Formatter", () => {
createFailure(sourceFile, 2, 3, "&<>'\" should be escaped", "escape", undefined, "error"),
createFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name", undefined, "error"),
createFailure(sourceFile, 0, maxPosition, "full failure", "full-name", undefined, "error"),
createFailure(sourceFile, 0, maxPosition, "warning failure", "warning-name", undefined, "warning"),
];

const expectedResultPlain =
Expand Down Expand Up @@ -88,6 +89,12 @@ describe("CodeFrame Formatter", () => {
\u001b[90m 3 | \u001b[39m private name\u001b[33m:\u001b[39m string\u001b[33m;\u001b[39m
\u001b[90m 4 | \u001b[39m\u001b[0m
\u001b[33mwarning failure\u001b[39m \u001b[90m(warning-name)\u001b[39m
\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 1 | \u001b[39mmodule \u001b[33mCodeFrameModule\u001b[39m {
\u001b[90m 2 | \u001b[39m \u001b[36mexport\u001b[39m \u001b[36mclass\u001b[39m \u001b[33mCodeFrameClass\u001b[39m {
\u001b[90m 3 | \u001b[39m private name\u001b[33m:\u001b[39m string\u001b[33m;\u001b[39m
\u001b[90m 4 | \u001b[39m\u001b[0m
\u001b[31m&<>'\" should be escaped\u001b[39m \u001b[90m(escape)\u001b[39m
\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 1 | \u001b[39mmodule \u001b[33mCodeFrameModule\u001b[39m {
\u001b[90m | \u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m
Expand Down

0 comments on commit 965ecb5

Please sign in to comment.