From 96f9942a91ecc40499f2841588ba3692e6025f86 Mon Sep 17 00:00:00 2001 From: tupe12334 Date: Thu, 18 Jun 2026 21:50:59 +0300 Subject: [PATCH] chore(lint): enable @typescript-eslint/no-non-null-assertion 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) --- eslint.config.mjs | 13 ++++++++++++- src/app/open/use-auto-close.ts | 3 +-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 71732a6..a2aba3b 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -8,4 +8,15 @@ const urlConstantsOverride = { }, }; -export default [...config, urlConstantsOverride]; +// Forbid non-null assertions (`value!`). The `!` operator silently tells the +// type checker a value can't be null/undefined without any runtime guarantee, +// so a wrong assumption surfaces as a runtime crash instead of a compile error. +// `eslint-config-agent` does not ship this rule. Prefer an explicit guard, +// optional chaining, or narrowing instead. +const noNonNullAssertion = { + rules: { + "@typescript-eslint/no-non-null-assertion": "error", + }, +}; + +export default [...config, urlConstantsOverride, noNonNullAssertion]; diff --git a/src/app/open/use-auto-close.ts b/src/app/open/use-auto-close.ts index bb1ee53..11ff353 100644 --- a/src/app/open/use-auto-close.ts +++ b/src/app/open/use-auto-close.ts @@ -22,8 +22,7 @@ export function useAutoClose(active: boolean) { intervalRef.current = setInterval(() => { setCountdown((prev) => { if (prev <= 1) { - clearInterval(intervalRef.current!); - intervalRef.current = null; + clearTimer(); window.close(); return 0; }