Skip to content

Commit 98e2727

Browse files
committed
Text formatter: fix grammatical error with one problem
The summary was incorrectly pluralized and had the wrong verb form when there was only one problem detected.
1 parent 326b50c commit 98e2727

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/formatters/text.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ CSSLint.addFormatter({
3636
return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
3737
}
3838

39-
output = "\n\ncsslint: There are " + messages.length + " problems in " + filename + ".";
39+
output = "\n\ncsslint: There ";
40+
if (messages.length == 1) {
41+
output += "is 1 problem";
42+
} else {
43+
output += "are " + messages.length + " problems";
44+
}
45+
output += " in " + filename + ".";
46+
4047
var pos = filename.lastIndexOf("/"),
4148
shortFilename = filename;
4249

@@ -61,4 +68,4 @@ CSSLint.addFormatter({
6168

6269
return output;
6370
}
64-
});
71+
});

tests/formatters/text.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
Assert.areEqual("\n\ncsslint: No errors in path/to/FILE.", actual);
1414
},
1515

16+
"File with one problem should use proper grammar": function() {
17+
var result = { messages: [
18+
{ type: 'warning', line: 1, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] }
19+
], stats: [] },
20+
error1 = "\n1: warning at line 1, col 1\nBOGUS\nALSO BOGUS",
21+
expected = "\n\ncsslint: There is 1 problem in path/to/FILE.\n\nFILE" + error1,
22+
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
23+
Assert.areEqual(expected, actual);
24+
},
25+
1626
"Should have no output when quiet option is specified and no errors": function() {
1727
var result = { messages: [], stats: [] },
1828
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE", quiet: "true"});

0 commit comments

Comments
 (0)