Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

print nothing when no failures #1553

Merged
merged 2 commits into from
Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions src/formatters/proseFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import {RuleFailure} from "../language/rule/rule";

export class Formatter extends AbstractFormatter {
public format(failures: RuleFailure[]): string {
if (!failures.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TSLint norms is to do an explicit comparison, (failures.length === 0).

Just curious, do you have that feature enabled that lets TSLint maintainers make modifications to your PR branch? I haven't gotten a chance to try it out yet, and something like this is the ideal scenario

return "";
}

const outputLines = failures.map((failure: RuleFailure) => {
const fileName = failure.getFileName();
const failureString = failure.getFailure();
Expand Down
2 changes: 1 addition & 1 deletion test/formatters/proseFormatterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("Prose Formatter", () => {

it("handles no failures", () => {
const result = formatter.format([]);
assert.equal(result, "\n");
assert.equal(result, "");
});

function getPositionString(line: number, character: number) {
Expand Down