diff --git a/scripts/check-rule-violations.sh b/scripts/check-rule-violations.sh index 407cf1e1..e143cd3e 100644 --- a/scripts/check-rule-violations.sh +++ b/scripts/check-rule-violations.sh @@ -271,6 +271,16 @@ scan_ts_any_type() { if echo "$evidence" | grep -qE 'catch[[:space:]]*\([^)]*:[[:space:]]*any\)'; then continue fi + # Skip false positives where `:any` is text inside a string literal or JSX + # text content (e.g. `label: 'Energy: any'`, `owner:any`). + # Real TS `: any` type annotations are followed by `,)=;>` or end-of-line; + # string-literal occurrences are followed by alphanumeric / quote / closing + # tag delimiter characters. We use a simple heuristic: if the `:any` is + # immediately preceded by a non-whitespace word character that's not a + # known TS punctuation, treat it as text. + if echo "$evidence" | grep -qE "[a-zA-Z0-9]:[[:space:]]*any[ '\"<]"; then + continue + fi emit_finding "ts-any-type" "minor" "$repo" "$file" "$line" "any type: ${evidence:0:80}" done < <(grep -rnE ':\s*any\b|\bas\s+any\b' "$repo_dir" \ --include='*.ts' --include='*.tsx' \