Skip to content

Commit

Permalink
chore: fix empty string checker to correctly count violations
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Oct 8, 2024
1 parent 1f2e6d4 commit bbfb46f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/empty-string-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ function parseDiffForEmptyStrings(diff: string) {
}

if (inHunk && line.startsWith("+")) {
// Check for various forms of empty strings, including at the start of the line
if (/^\+.*?(?:=\s*["'`]{2}|["'`]\s*:\s*["'`]|:\s*["'`]{2})/.test(line)) {
// Ignore package.json version numbers and ternary expressions
if (currentFile.endsWith("package.json") || /\? .+ : .+/.test(line)) {
headLine++;
return;
}

// Check for various forms of empty strings, excluding version numbers and valid use cases
if (/^\+.*?(?:=\s*["'`]{2}(?!\s*[,;])|["'`]\s*:\s*["'`](?!\s*[,;])|:\s*["'`]{2}(?!\s*[,;]))/.test(line)) {
violations.push({
file: currentFile,
line: headLine,
Expand Down

0 comments on commit bbfb46f

Please sign in to comment.