Commit b1306a4a authored by David Sveningsson's avatar David Sveningsson

fix(reporter): require {error,warning}Count to be present in Result

parent 646df97d
......@@ -40,6 +40,8 @@ const report: Report = {
warningCount: 0,
},
],
errorCount: 1,
warningCount: 0,
};
describe("cli/formatters", () => {
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`json formatter should empty messages 1`] = `"[{\\"filePath\\":\\"empty.html\\",\\"messages\\":[]}]"`;
exports[`json formatter should empty messages 1`] = `"[{\\"filePath\\":\\"empty.html\\",\\"messages\\":[],\\"errorCount\\":0,\\"warningCount\\":0}]"`;
exports[`json formatter should empty result 1`] = `"[]"`;
exports[`json formatter should generate json 1`] = `"[{\\"filePath\\":\\"regular.html\\",\\"messages\\":[{\\"ruleId\\":\\"foo\\",\\"severity\\":2,\\"message\\":\\"An error\\",\\"offset\\":4,\\"line\\":1,\\"column\\":5,\\"size\\":1},{\\"ruleId\\":\\"bar\\",\\"severity\\":1,\\"message\\":\\"A warning\\",\\"offset\\":12,\\"line\\":2,\\"column\\":4,\\"size\\":1}]},{\\"filePath\\":\\"edge-cases.html\\",\\"messages\\":[{\\"ruleId\\":\\"baz\\",\\"severity\\":2,\\"message\\":\\"Another error\\",\\"offset\\":14,\\"line\\":3,\\"column\\":3,\\"size\\":1}]}]"`;
exports[`json formatter should generate json 1`] = `"[{\\"filePath\\":\\"regular.html\\",\\"errorCount\\":1,\\"warningCount\\":1,\\"messages\\":[{\\"ruleId\\":\\"foo\\",\\"severity\\":2,\\"message\\":\\"An error\\",\\"offset\\":4,\\"line\\":1,\\"column\\":5,\\"size\\":1},{\\"ruleId\\":\\"bar\\",\\"severity\\":1,\\"message\\":\\"A warning\\",\\"offset\\":12,\\"line\\":2,\\"column\\":4,\\"size\\":1}]},{\\"filePath\\":\\"edge-cases.html\\",\\"errorCount\\":1,\\"warningCount\\":0,\\"messages\\":[{\\"ruleId\\":\\"baz\\",\\"severity\\":2,\\"message\\":\\"Another error\\",\\"offset\\":14,\\"line\\":3,\\"column\\":3,\\"size\\":1}]}]"`;
......@@ -6,6 +6,8 @@ describe("checkstyle formatter", () => {
const results: Result[] = [
{
filePath: "regular.html",
errorCount: 1,
warningCount: 0,
messages: [
{
ruleId: "foo",
......@@ -29,6 +31,8 @@ describe("checkstyle formatter", () => {
},
{
filePath: "edge-cases.html",
errorCount: 2,
warningCount: 0,
messages: [
{
ruleId: "foo",
......@@ -69,7 +73,9 @@ describe("checkstyle formatter", () => {
});
it("should empty messages", () => {
const results: Result[] = [{ filePath: "empty.html", messages: [] }];
const results: Result[] = [
{ filePath: "empty.html", messages: [], errorCount: 0, warningCount: 0 },
];
expect(formatter(results)).toMatchSnapshot();
});
});
......@@ -70,7 +70,9 @@ describe("codeframe formatter", () => {
});
it("should empty messages", () => {
const results: Result[] = [{ filePath: "empty.html", messages: [] }];
const results: Result[] = [
{ filePath: "empty.html", messages: [], errorCount: 0, warningCount: 0 },
];
expect(formatter(results)).toMatchSnapshot();
});
});
......@@ -6,6 +6,8 @@ describe("json formatter", () => {
const results: Result[] = [
{
filePath: "regular.html",
errorCount: 1,
warningCount: 1,
messages: [
{
ruleId: "foo",
......@@ -29,6 +31,8 @@ describe("json formatter", () => {
},
{
filePath: "edge-cases.html",
errorCount: 1,
warningCount: 0,
messages: [
{
ruleId: "baz",
......@@ -51,7 +55,9 @@ describe("json formatter", () => {
});
it("should empty messages", () => {
const results: Result[] = [{ filePath: "empty.html", messages: [] }];
const results: Result[] = [
{ filePath: "empty.html", messages: [], errorCount: 0, warningCount: 0 },
];
expect(formatter(results)).toMatchSnapshot();
});
});
......@@ -63,7 +63,9 @@ describe("stylish formatter", () => {
});
it("should empty messages", () => {
const results: Result[] = [{ filePath: "empty.html", messages: [] }];
const results: Result[] = [
{ filePath: "empty.html", messages: [], errorCount: 0, warningCount: 0 },
];
expect(formatter(results)).toMatchSnapshot();
});
});
......@@ -6,6 +6,8 @@ describe("text formatter", () => {
const results: Result[] = [
{
filePath: "regular.html",
errorCount: 1,
warningCount: 1,
messages: [
{
ruleId: "foo",
......@@ -29,6 +31,8 @@ describe("text formatter", () => {
},
{
filePath: "edge-cases.html",
errorCount: 1,
warningCount: 0,
messages: [
{
ruleId: "baz",
......@@ -51,7 +55,9 @@ describe("text formatter", () => {
});
it("should empty messages", () => {
const results: Result[] = [{ filePath: "empty.html", messages: [] }];
const results: Result[] = [
{ filePath: "empty.html", messages: [], errorCount: 0, warningCount: 0 },
];
expect(formatter(results)).toMatchSnapshot();
});
});
......@@ -190,6 +190,8 @@ function createResult(filename: string, messages: string[]): Result {
return {
filePath: filename,
messages: messages.map(cur => createMessage(cur)),
errorCount: messages.length,
warningCount: 0,
};
}
......
......@@ -38,8 +38,8 @@ export interface Message {
export interface Result {
messages: Message[];
filePath: string;
errorCount?: number;
warningCount?: number;
errorCount: number;
warningCount: number;
source?: string;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment