Skip to content

Add TypeScript antipattern detection #129

@mrtwebdesign

Description

@mrtwebdesign

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
  • strictNullChecks compliance
  • Unused type imports

Suggested implementation

  • New pattern category: typescript (or extend existing nodejs category)
  • 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/.tsx files only
  • wpcc --features lists the new patterns
  • Scans produce actionable findings with clear descriptions
  • PATTERN-LIBRARY.json updated with new category/patterns

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions