Skip to content

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

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

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