Skip to content

Commit

Permalink
avoid stray console log in code. (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: rebornix <[email protected]>
  • Loading branch information
meslubi2021 and rebornix authored Aug 10, 2024
1 parent 664d9a9 commit 811b123
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion build/hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,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) {
Expand Down Expand Up @@ -174,7 +190,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(tsFormattingFilter)).pipe(formatting)
Expand Down

0 comments on commit 811b123

Please sign in to comment.