Skip to content

Commit

Permalink
Merge pull request CSSLint#356 from mo/print_rule_id_in_compact_mode
Browse files Browse the repository at this point in the history
Print rule ID for each error/warning in compact mode
  • Loading branch information
stubbornella committed Nov 2, 2013
2 parents f1ef64d + 60ddf66 commit c7fa61a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/formatters/compact.js
Expand Up @@ -50,10 +50,10 @@ CSSLint.addFormatter({
output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
} else {
output += filename + ": " + "line " + message.line +
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n";
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
}
});

return output;
}
});
});
16 changes: 8 additions & 8 deletions tests/formatters/compact.js
Expand Up @@ -20,23 +20,23 @@

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

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

0 comments on commit c7fa61a

Please sign in to comment.