Type-Safety Enforcer
Instructions
- •Detection:
- •Run
grit check patternName="ban-type-assertions"to findas Type,as any, and!. - •Run
grit check patternName="ban-ts-ignore"to find suppression comments.
- •Run
- •Context Analysis: For each violation, analyze the surrounding code to determine the best remediation strategy.
- •Remediation:
- •External Data: Use
Schema.decodeUnknown(Effect) to validate at the boundary. - •Null Checks: Replace
!with properif (value != null)guards or optional chaining?.. - •Type Widening: Replace
as anywithunknownand proper type narrowing. - •Logic Errors: If a cast is used to hide a bug, refactor the underlying logic.
- •External Data: Use
- •Verification:
- •Run
tsc --noEmitto ensure the codebase is clean. - •Verify that no new linting violations are introduced in
biome check.
- •Run
Guardrails (CRITICAL)
- •NEVER replace
as anywith another unsafe cast. - •ALWAYS prioritize runtime validation for external data.