Skip to content

Commit 9236e56

Browse files
build: provide line numbers of bad patch lines when linting (electron#28666)
1 parent 5ee906f commit 9236e56

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

script/lint.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ const LINTERS = [{
207207
console.warn(`Patch file '${f}' has no description. Every patch must contain a justification for why the patch exists and the plan for its removal.`);
208208
return false;
209209
}
210-
const trailingWhitespace = patchText.split(/\r?\n/).some(line => line.startsWith('+') && /\s+$/.test(line));
211-
if (trailingWhitespace) {
212-
console.warn(`Patch file '${f}' has trailing whitespace on some lines.`);
210+
const trailingWhitespaceLines = patchText.split(/\r?\n/).map((line, index) => [line, index]).filter(([line]) => line.startsWith('+') && /\s+$/.test(line)).map(([, lineNumber]) => lineNumber + 1);
211+
if (trailingWhitespaceLines.length > 0) {
212+
console.warn(`Patch file '${f}' has trailing whitespace on some lines (${trailingWhitespaceLines.join(',')}).`);
213213
return false;
214214
}
215215
return true;

0 commit comments

Comments
 (0)