Skip to content

Commit c88a3a0

Browse files
committed
Ignore console.logs in comments
1 parent 78709e1 commit c88a3a0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

.github/workflows/npm-publish.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,36 @@ jobs:
7272
local has_debug=false
7373
local debug_output=""
7474
75-
# Check for $inspect
76-
if grep -n "\$inspect" "$file" > /dev/null; then
77-
match=$(grep -n "\$inspect.*" "$file" | head -n 1)
75+
# Check for $inspect (not in comments)
76+
if grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*\$inspect' "$file" > /dev/null; then
77+
match=$(grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*\$inspect.*' "$file" | head -n 1)
7878
line_num=$(echo "$match" | cut -d: -f1)
7979
statement=$(echo "$match" | cut -d: -f2-)
8080
echo "::error file=$file::Found \$inspect statement on line $line_num: $statement"
8181
has_debug=true
8282
fi
8383
84-
# Check for console.log
85-
if grep -n "console\.log" "$file" > /dev/null; then
86-
match=$(grep -n "console\.log.*" "$file" | head -n 1)
84+
# Check for console.log (not in comments)
85+
if grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*console\.log' "$file" > /dev/null; then
86+
match=$(grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*console\.log.*' "$file" | head -n 1)
8787
line_num=$(echo "$match" | cut -d: -f1)
8888
statement=$(echo "$match" | cut -d: -f2-)
8989
echo "::error file=$file::Found console.log statement on line $line_num: $statement"
9090
has_debug=true
9191
fi
9292
93-
# Check for console.debug
94-
if grep -n "console\.debug" "$file" > /dev/null; then
95-
match=$(grep -n "console\.debug.*" "$file" | head -n 1)
93+
# Check for console.debug (not in comments)
94+
if grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*console\.debug' "$file" > /dev/null; then
95+
match=$(grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*console\.debug.*' "$file" | head -n 1)
9696
line_num=$(echo "$match" | cut -d: -f1)
9797
statement=$(echo "$match" | cut -d: -f2-)
9898
echo "::error file=$file::Found console.debug statement on line $line_num: $statement"
9999
has_debug=true
100100
fi
101101
102-
# Check for debugger statements
103-
if grep -n "debugger;" "$file" > /dev/null; then
104-
match=$(grep -n "debugger;" "$file" | head -n 1)
102+
# Check for debugger statements (not in comments)
103+
if grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*debugger;' "$file" > /dev/null; then
104+
match=$(grep -n -P '^(?!\s*//|\s*/\*|\s*\*).*debugger;' "$file" | head -n 1)
105105
line_num=$(echo "$match" | cut -d: -f1)
106106
statement=$(echo "$match" | cut -d: -f2-)
107107
echo "::error file=$file::Found debugger statement on line $line_num: $statement"

0 commit comments

Comments
 (0)