Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

refactor(web): drop redundant throw check and explicit return annotation

justin8dcb3261c68a
diff --git a/apps/web/src/lib/is-in-codeblock-language-picker.test.ts b/apps/web/src/lib/is-in-codeblock-language-picker.test.ts
index 8115e2e32..c924c49f6 100644
--- a/apps/web/src/lib/is-in-codeblock-language-picker.test.ts
+++ b/apps/web/src/lib/is-in-codeblock-language-picker.test.ts
@@ -6,13 +6,13 @@ describe("isInCodeBlockLanguagePicker", () => {
expect(isInCodeBlockLanguagePicker(null)).toBe(false);
});
- it("does not throw and returns false when target is a non-Element EventTarget (Text node)", () => {
+ it("returns false when target is a non-Element EventTarget (Text node)", () => {
// Regression: event.relatedTarget can be a Text node (when the pointer
// moves between text runs). Calling .closest() on it throws TypeError,
- // which used to crash handleEditorMouseLeave. The helper's
- // `instanceof Element` guard must short-circuit first.
+ // which used to crash handleEditorMouseLeave. If the helper's
+ // `instanceof Element` guard is missing, this call throws and the
+ // assertion below fails on the thrown error.
const text = document.createTextNode("x");
- expect(() => isInCodeBlockLanguagePicker(text)).not.toThrow();
expect(isInCodeBlockLanguagePicker(text)).toBe(false);
});
diff --git a/apps/web/src/lib/is-in-codeblock-language-picker.ts b/apps/web/src/lib/is-in-codeblock-language-picker.ts
index c6d6680ad..c13211e47 100644
--- a/apps/web/src/lib/is-in-codeblock-language-picker.ts
+++ b/apps/web/src/lib/is-in-codeblock-language-picker.ts
@@ -7,9 +7,7 @@
* `instanceof Element` guard is load-bearing for the mouseleave handlers in
* the comment and task-description editors.
*/
-export function isInCodeBlockLanguagePicker(
- target: EventTarget | null,
-): boolean {
+export function isInCodeBlockLanguagePicker(target: EventTarget | null) {
return (
target instanceof Element &&
target.closest(".kaneo-codeblock-language") !== null