From a0eb0104568e1c2572a19eec395b76e570dc0c66 Mon Sep 17 00:00:00 2001 From: rebornix Date: Wed, 17 Feb 2021 08:48:34 -0800 Subject: [PATCH] avoid stray console log in code. --- build/hygiene.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build/hygiene.js b/build/hygiene.js index 9d6756dbc86d73..e17fadc17ce816 100644 --- a/build/hygiene.js +++ b/build/hygiene.js @@ -107,6 +107,22 @@ function hygiene(some, linting = true) { ); }); + const consoleLog = es.through(function (file) { + const lines = file.__lines; + + for (let i = 0; i < lines.length; i++) { + if (/^\s*console\.log/.test(lines[i])) { + console.error( + file.relative + '(' + (i + 1) + ',1): Stray console.log' + ); + errorCount++; + break; + } + } + + this.emit('data', file); + }); + let input; if (Array.isArray(some) || typeof some === 'string' || !some) { @@ -130,7 +146,9 @@ function hygiene(some, linting = true) { .pipe(filter(indentationFilter)) .pipe(indentation) .pipe(filter(copyrightFilter)) - .pipe(copyrights); + .pipe(copyrights) + .pipe(filter(tsHygieneFilter)) + .pipe(consoleLog); const streams = [ result.pipe(filter(tsHygieneFilter)).pipe(formatting)