Skip to content
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
11 changes: 9 additions & 2 deletions src/formatters/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ CSSLint.addFormatter({
return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
}

output = "\n\ncsslint: There are " + messages.length + " problems in " + filename + ".";
output = "\n\ncsslint: There ";
if (messages.length == 1) {
output += "is 1 problem";
} else {
output += "are " + messages.length + " problems";
}
output += " in " + filename + ".";

var pos = filename.lastIndexOf("/"),
shortFilename = filename;

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

return output;
}
});
});
10 changes: 10 additions & 0 deletions tests/formatters/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
Assert.areEqual("\n\ncsslint: No errors in path/to/FILE.", actual);
},

"File with one problem should use proper grammar": function() {
var result = { messages: [
{ type: 'warning', line: 1, col: 1, message: 'BOGUS', evidence: 'ALSO BOGUS', rule: [] }
], stats: [] },
error1 = "\n1: warning at line 1, col 1\nBOGUS\nALSO BOGUS",
expected = "\n\ncsslint: There is 1 problem in path/to/FILE.\n\nFILE" + error1,
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
Assert.areEqual(expected, actual);
},

"Should have no output when quiet option is specified and no errors": function() {
var result = { messages: [], stats: [] },
actual = CSSLint.getFormatter("text").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE", quiet: "true"});
Expand Down