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
Enable the
@typescript-eslint/no-non-null-assertionESLint ruleWhat
Turns on
@typescript-eslint/no-non-null-assertionaterrorlevel, forbidding the non-null assertion operator (value!).Why
The
!operator asserts to the type checker that a value is notnull/undefinedwhile 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-agentdoes not ship this rule, so non-null assertions were previously unchecked.Scope
src/app/open/use-auto-close.ts(aclearInterval(intervalRef.current!)) — the file already has a null-checkedclearTimer()helper, so the assertion can be replaced with a safe guarded call.pnpm lint,tsc --noEmit, andnext buildall 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