Skip to content

Commit

Permalink
stylish-formatter: make filename clickable (palantir#3491)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff authored and HyphnKnight committed Apr 9, 2018
1 parent 77d2c1f commit df0158d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/formatters/stylishFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ export class Formatter extends AbstractFormatter {

for (const failure of failures) {
const fileName = failure.getFileName();
const lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
let positionTuple = `${lineAndCharacter.line + 1}:${lineAndCharacter.character + 1}`;

// Output the name of each file once
if (currentFile !== fileName) {
outputLines.push("");
outputLines.push(fileName);
outputLines.push(`${fileName}${chalk.hidden(`:${positionTuple}`)}`);
currentFile = fileName;
}

Expand All @@ -79,9 +81,6 @@ export class Formatter extends AbstractFormatter {
ruleName = chalk.grey(ruleName);

// Lines
const lineAndCharacter = failure.getStartPosition().getLineAndCharacter();

let positionTuple = `${lineAndCharacter.line + 1}:${lineAndCharacter.character + 1}`;
positionTuple = this.pad(positionTuple, positionMaxSize);

positionTuple = failure.getRuleSeverity() === "warning"
Expand Down
2 changes: 1 addition & 1 deletion test/formatters/stylishFormatterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("Stylish Formatter", () => {
const maxPositionTuple = `${maxPositionObj.line + 1}:${maxPositionObj.character + 1}`;

const expectedResult = dedent`
formatters/stylishFormatter.test.ts
formatters/stylishFormatter.test.ts\u001b[8m:1:1\u001b[28m
\u001b[31mERROR: 1:1\u001b[39m \u001b[90mfirst-name\u001b[39m \u001b[33mfirst failure\u001b[39m
\u001b[31mERROR: 1:1\u001b[39m \u001b[90mfull-name \u001b[39m \u001b[33mfull failure\u001b[39m
\u001b[31mERROR: 1:3\u001b[39m \u001b[90mescape \u001b[39m \u001b[33m&<>'\" should be escaped\u001b[39m
Expand Down

0 comments on commit df0158d

Please sign in to comment.