Skip to content

Enable @typescript-eslint/no-non-null-assertion lint rule #35

Closed

Description

@tupe12334

Enable the @typescript-eslint/no-non-null-assertion ESLint rule

What

Turns on @typescript-eslint/no-non-null-assertion at error level, forbidding the non-null assertion operator (value!).

Why

The ! operator asserts to the type checker that a value is not null/undefined while providing no runtime guarantee. When the assumption is wrong, TypeScript stays silent at compile time and the code crashes at runtime (Cannot read properties of null) — exactly the class of bug the type system is supposed to prevent. Banning ! forces an explicit guard, optional chaining, or proper narrowing, so null-safety is enforced rather than assumed.

eslint-config-agent does not ship this rule, so non-null assertions were previously unchecked.

Scope

  • One existing violation in src/app/open/use-auto-close.ts (a clearInterval(intervalRef.current!)) — the file already has a null-checked clearTimer() helper, so the assertion can be replaced with a safe guarded call.
  • Implemented in the accompanying PR. pnpm lint, tsc --noEmit, and next build all pass.

No other rules are changed.


This issue was opened by the Add lint rule → issue + PR (owned repos + my orgs) → Slack routine of moadim. cc @tupe12334

Activity

  1. github-actions commented on Jun 18, 2026

    @github-actions

    A workspace is ready for this issue.

    Open workspace →

    Powered by Worktree · Install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions