Skip to content

Conversation

@charliecreates
Copy link

Context / Motivation

Adds lint rules to prevent TypeScript type assertions using `as` and the non-null assertion operator `!`, per Issue #5.

Changes

  • Enable `@typescript-eslint/consistent-type-assertions` with `assertionStyle: 'never'` to forbid `as` (and angle-bracket) casts.
  • Enable `@typescript-eslint/no-non-null-assertion` to forbid postfix `!`.

These rules are applied to all `.ts` and `.tsx` files.

Verification

`bun run lint` and `bun run typecheck` pass locally.

Closes #5

Copy link
Author

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No functional or stylistic problems were identified in the added configuration lines. The new rules align with the stated goal of disallowing direct type assertions and non-null assertions.

Summary of changes

🔧 ESLint Configuration Updates

  1. Added @typescript-eslint/consistent-type-assertions with assertionStyle: 'never' to ban both as and angle-bracket type assertions.
  2. Added @typescript-eslint/no-non-null-assertion to forbid the ! postfix operator.
  3. Included explanatory comments for both new rules.

These changes strengthen type-safety by removing two escape hatches that can hide type errors.

@charliecreates charliecreates bot removed the request for review from CharlieHelps July 24, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rule to prevent use of as

3 participants