Skip to content

chore(lint): enable @typescript-eslint/no-non-null-assertion#36

Open
tupe12334 wants to merge 1 commit into
mainfrom
lint/enable-no-non-null-assertion
Open

chore(lint): enable @typescript-eslint/no-non-null-assertion#36
tupe12334 wants to merge 1 commit into
mainfrom
lint/enable-no-non-null-assertion

Conversation

@tupe12334

Copy link
Copy Markdown
Member

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

Closes #35

What

Enables @typescript-eslint/no-non-null-assertion: "error" in eslint.config.mjs, forbidding the non-null assertion operator (value!).

Why

! tells the type checker a value is not null/undefined with no runtime guarantee. A wrong assumption compiles clean and crashes at runtime — the exact bug class the type system exists to catch. The rule forces an explicit guard, optional chaining, or narrowing instead. eslint-config-agent does not ship this rule, so ! was previously unchecked. Set at error so regressions fail lint.

Change

  • eslint.config.mjs: add the rule (with an explanatory comment).
  • src/app/open/use-auto-close.ts: the one violation was clearInterval(intervalRef.current!). Replaced with the file's existing null-checked clearTimer() helper, which clears the interval and resets the ref — behavior-preserving and assertion-free.

Verification

  • pnpm lint → clean (0 errors).
  • tsc --noEmit → clean.
  • next build → succeeds (all routes prerendered).

No other rules changed.


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

Forbid non-null assertions (`value!`), which assert non-null to the type
checker with no runtime guarantee and turn a wrong assumption into a
runtime crash. eslint-config-agent does not ship this rule.

Fixes the single violation in use-auto-close.ts by using the existing
null-checked clearTimer() helper instead of `clearInterval(intervalRef.current!)`.

Closes #35

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

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

1 participant