Skip to content

Commit

Permalink
attempt to fix more
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Feb 21, 2024
1 parent 7664399 commit c432a42
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/eslint-plugin/test/eslint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,23 @@ for (const fixture of allFixtures) {
const resultText = stripAnsi(formatted).trim() || "No errors";
expect(resultText).not.toContain("Parsing error");
const newOutput = formatResultsWithInlineErrors(results);
expect(resultText + "\n\n" + newOutput).toMatchFile(getLintSnapshotPath(fixture));
expect(normalizeSnapshot(resultText + "\n\n" + newOutput)).toMatchFile(getLintSnapshotPath(fixture));
});
});
}

function normalizeSnapshot(snapshot: string): string {
return snapshot
.split(/\r?\n/g)
.map((line) => {
if (line.startsWith("types\\")) {
return normalizeSlashes(line);
}
return line;
})
.join("\n");
}

function formatResultsWithInlineErrors(results: ESLint.LintResult[]): string {
const output: string[] = [];

Expand Down Expand Up @@ -108,12 +120,7 @@ function formatResultsWithInlineErrors(results: ESLint.LintResult[]): string {
output.push("");
}

return (
output
.map((o) => o.replace(/\r?\n/g, "\n"))
.join("\n")
.trim() + "\n"
);
return output.join("\n").trim() + "\n";
}

// Similar to https://github.com/storybookjs/storybook/blob/df357020e010f49e7c325942f0c891e6702527d6/code/addons/storyshots-core/src/api/integrityTestTemplate.ts
Expand Down

0 comments on commit c432a42

Please sign in to comment.