Browse Source

build: provide line numbers of bad patch lines when linting (#28666)

Samuel Attard 4 years ago
parent
commit
9236e56ddc
1 changed files with 3 additions and 3 deletions
  1. 3 3
      script/lint.js

+ 3 - 3
script/lint.js

@@ -207,9 +207,9 @@ const LINTERS = [{
         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.`);
         return false;
       }
-      const trailingWhitespace = patchText.split(/\r?\n/).some(line => line.startsWith('+') && /\s+$/.test(line));
-      if (trailingWhitespace) {
-        console.warn(`Patch file '${f}' has trailing whitespace on some lines.`);
+      const trailingWhitespaceLines = patchText.split(/\r?\n/).map((line, index) => [line, index]).filter(([line]) => line.startsWith('+') && /\s+$/.test(line)).map(([, lineNumber]) => lineNumber + 1);
+      if (trailingWhitespaceLines.length > 0) {
+        console.warn(`Patch file '${f}' has trailing whitespace on some lines (${trailingWhitespaceLines.join(',')}).`);
         return false;
       }
       return true;