Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Output code warnings in yellow instead of red #3402

Merged
merged 2 commits into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add a test for this in test/formatters/codeFrameFormatterTests.ts?


// 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