From 2b533f1521f9d41f77481908e317c56934d2ebd7 Mon Sep 17 00:00:00 2001 From: Jeremy Morton Date: Thu, 26 Oct 2017 21:11:10 +0100 Subject: [PATCH 1/2] Output code warnings in yellow instead of red --- src/formatters/codeFrameFormatter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/formatters/codeFrameFormatter.ts b/src/formatters/codeFrameFormatter.ts index f48c35c8525..e81e3ffc8e1 100644 --- a/src/formatters/codeFrameFormatter.ts +++ b/src/formatters/codeFrameFormatter.ts @@ -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(); From 712a0d328baa2112a7c54ffda4ddbfe75da6ee01 Mon Sep 17 00:00:00 2001 From: Jeremy Morton Date: Thu, 26 Oct 2017 23:39:30 +0100 Subject: [PATCH 2/2] Added warning output test. --- test/formatters/codeFrameFormatterTests.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/formatters/codeFrameFormatterTests.ts b/test/formatters/codeFrameFormatterTests.ts index c9ec0dae421..cdc1161d929 100644 --- a/test/formatters/codeFrameFormatterTests.ts +++ b/test/formatters/codeFrameFormatterTests.ts @@ -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 = @@ -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