-
Notifications
You must be signed in to change notification settings - Fork 0
Add TypeScript antipattern detection #129
Copy link
Copy link
Open
Description
Summary
WP-Code-Check currently includes .ts and .tsx in file_patterns for its JS/Node.js/headless pattern categories, but all checks are language-agnostic security and reliability patterns. There are zero TypeScript-specific checks today.
Problem
TypeScript projects have a class of common antipatterns that suppress or circumvent the type system. These are detectable with grep and don't require AST analysis, making them a natural fit for WPCC's zero-dependency design.
Proposed grep-feasible TypeScript checks
| Antipattern | Grep pattern | Why it matters |
|---|---|---|
@ts-ignore |
@ts-ignore |
Silences type errors without fixing them |
@ts-nocheck |
@ts-nocheck |
Disables type checking for entire file |
@ts-expect-error (without comment) |
@ts-expect-error\s*$ |
Suppression without explanation |
as any |
as\s+any |
Unsafe type assertion, defeats type safety |
<any> type assertion |
<any> |
Legacy syntax for the same problem |
: any type annotation |
:\s*any\b |
Explicit opt-out of type safety |
// eslint-disable (broad) |
eslint-disable(?!-next-line) |
File-wide lint suppression |
| Non-null assertion abuse | \w+!\. or \w+!\[ |
Overrides null safety checks |
Checks that are NOT feasible with grep
These require tsc or @typescript-eslint and are out of scope:
- Implicit
any(missing annotations where inference fails) - Missing return types on exported functions
- Unsafe generic usage
strictNullCheckscompliance- Unused type imports
Suggested implementation
- New pattern category:
typescript(or extend existingnodejscategory) - New pattern files:
ts-001-type-suppression.json,ts-002-unsafe-any.json, etc. file_patterns:["*.ts", "*.tsx"]only (not.js)- Severity: advisory/warning — these are code smells, not always bugs
Acceptance criteria
- At least 3-4 new TypeScript-specific pattern definitions
- Patterns target
.ts/.tsxfiles only -
wpcc --featureslists the new patterns - Scans produce actionable findings with clear descriptions
- PATTERN-LIBRARY.json updated with new category/patterns
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels