Skip to content

Commit c7fa61a

Browse files
committed
Merge pull request #356 from mo/print_rule_id_in_compact_mode
Print rule ID for each error/warning in compact mode
2 parents f1ef64d + 60ddf66 commit c7fa61a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/formatters/compact.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ CSSLint.addFormatter({
5050
output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
5151
} else {
5252
output += filename + ": " + "line " + message.line +
53-
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n";
53+
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
5454
}
5555
});
5656

5757
return output;
5858
}
59-
});
59+
});

tests/formatters/compact.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@
2020

2121
"File with problems should list them": function() {
2222
var result = { messages: [
23-
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
24-
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
23+
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } },
24+
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } }
2525
], stats: [] },
26-
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR\n",
27-
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING\n",
26+
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR (BOGUS_RULE_ID)\n",
27+
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING (BOGUS_RULE_ID)\n",
2828
expected = err + warning,
2929
actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
3030
Assert.areEqual(expected, actual);
3131
},
3232

3333
"Should output relative file paths": function() {
3434
var result = { messages: [
35-
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: [] },
36-
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: [] }
35+
{ type: 'error', line: 2, col: 1, message: 'BOGUS ERROR', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } },
36+
{ type: 'warning', line: 1, col: 1, message: 'BOGUS WARNING', evidence: 'BOGUS', rule: { id: 'BOGUS_RULE_ID' } }
3737
], stats: [] },
38-
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR\n",
39-
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING\n",
38+
err = "path/to/FILE: line 2, col 1, Error - BOGUS ERROR (BOGUS_RULE_ID)\n",
39+
warning = "path/to/FILE: line 1, col 1, Warning - BOGUS WARNING (BOGUS_RULE_ID)\n",
4040
expected = err + warning,
4141
actual = CSSLint.getFormatter("compact").formatResults(result, "path/to/FILE", {fullPath: "/absolute/path/to/FILE"});
4242
Assert.areEqual(expected, actual);

0 commit comments

Comments
 (0)