Skip to content

Commit

Permalink
Filter ktfmt spam
Browse files Browse the repository at this point in the history
  • Loading branch information
artnc committed Nov 14, 2023
1 parent 003fbbb commit b05d47c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,25 @@ const GLOBAL_EXCLUDES = (() => {

/** Prefixes a string to all nonempty lines of input */
const prefixLines = (() => {
const LINES_TO_IGNORE = new RegExp(
[
// Empty lines
/^\s*$/,
// ktfmt spams this for every file that has no violations
/\bDone formatting .+\.kt$/,
// Black 21.12b0 spams this when running on Python 2 source code
/\bDEPRECATION: Python 2 support\b/,
]
.map(regex => regex.source)
.join("|"),
);
const maxPrefixLength = Math.max(
...Object.keys(HOOKS).map(name => name.length),
);
return (prefix: string, lines: string) =>
lines
.split("\n")
.filter(line => line.trim().length)
// Black 21.12b0 spams this when running on Python 2 source code
.filter(line => !line.includes("DEPRECATION: Python 2 support"))
.filter(line => !LINES_TO_IGNORE.test(line))
.map(line => `${prefix}:`.padEnd(maxPrefixLength + 2) + line)
.join("\n");
})();
Expand Down

0 comments on commit b05d47c

Please sign in to comment.