From 9d969bb72301a05734524daa5a2e165093b2b756 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:50:22 +0000 Subject: [PATCH] chore: fix formatting and clippy unused imports - Applied `biome format` to typescript files (`goto-line.test.ts`, `goto-line.ts`, `search-panel.ts`) on the frontend. - Applied `cargo clippy --fix` on `pkgs/id` to drop unused imports and variables in `repl.rs`, `world_doctor.rs`, `world_session/mod.rs`, and `world_store.rs`. - Fixed CI formatting checks for `cargo-fmt`, `treefmt-check`, and `clippy-lint`. Co-authored-by: dezren39 <11225574+dezren39@users.noreply.github.com> --- pkgs/id/src/commands/repl.rs | 4 +- pkgs/id/src/world_doctor.rs | 2 +- pkgs/id/src/world_session/mod.rs | 2 +- pkgs/id/src/world_store.rs | 4 +- pkgs/id/web/src/goto-line.test.ts | 124 +++++++++++++++++++++--------- pkgs/id/web/src/goto-line.ts | 10 ++- pkgs/id/web/src/search-panel.ts | 33 +++++--- 7 files changed, 126 insertions(+), 53 deletions(-) diff --git a/pkgs/id/src/commands/repl.rs b/pkgs/id/src/commands/repl.rs index bdf65b5dfd..82fe234294 100644 --- a/pkgs/id/src/commands/repl.rs +++ b/pkgs/id/src/commands/repl.rs @@ -95,8 +95,8 @@ use crate::commands::tag::{self as tag, TagDisplayOptions}; use crate::local::LocalNode; use crate::meta_client::{MetaRequester, expect_ok, read_capped_response, request_over}; use crate::{ - CLIENT_KEY_FILE, FindMatch, META_ALPN, MatchKind, MetaRequest, MetaResponse, StoreType, - export_blob, is_node_id, load_or_create_keypair, open_store, + CLIENT_KEY_FILE, FindMatch, META_ALPN, MetaRequest, MetaResponse, StoreType, export_blob, + is_node_id, load_or_create_keypair, open_store, }; /// REPL execution context managing connections and store access. diff --git a/pkgs/id/src/world_doctor.rs b/pkgs/id/src/world_doctor.rs index 0f577c4b2b..63212516df 100644 --- a/pkgs/id/src/world_doctor.rs +++ b/pkgs/id/src/world_doctor.rs @@ -199,7 +199,7 @@ pub fn check_toolchain(inputs: &DoctorInputs) -> Finding { }; // A configured binary must exist. A bare name resolves through PATH. let exists = if roc_bin.contains('/') { - std::path::Path::new(roc_bin).is_file() + Path::new(roc_bin).is_file() } else { std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default()) .map(|dir| dir.join(roc_bin)) diff --git a/pkgs/id/src/world_session/mod.rs b/pkgs/id/src/world_session/mod.rs index 1600957577..6befeb0d26 100644 --- a/pkgs/id/src/world_session/mod.rs +++ b/pkgs/id/src/world_session/mod.rs @@ -51,7 +51,7 @@ mod tests; mod types; pub(crate) use types::{ - CAPS_CEILING_NOTICE, ClientFrame, CompileFile, MAX_ADMIN_TOKEN_BYTES, MAX_CAPABILITY_BYTES, + CAPS_CEILING_NOTICE, ClientFrame, MAX_ADMIN_TOKEN_BYTES, MAX_CAPABILITY_BYTES, MAX_CONCURRENT_MODULE_UPLOADS, ServerFrame, invite_bounds, }; pub use types::{ diff --git a/pkgs/id/src/world_store.rs b/pkgs/id/src/world_store.rs index 7d9d7e28a0..5bbf31ae9e 100644 --- a/pkgs/id/src/world_store.rs +++ b/pkgs/id/src/world_store.rs @@ -28,8 +28,8 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, bail, ensure}; use crate::world::{ - JOURNAL_VERSION, JOURNAL_VERSION_EXECUTION_PROFILE, JournalEntry, WorldCore, WorldEventKind, - WorldHandle, WorldJournal, WorldLimits, WorldProgram, journal_version_required_by, + JOURNAL_VERSION, JournalEntry, WorldCore, WorldEventKind, WorldHandle, WorldJournal, + WorldLimits, WorldProgram, journal_version_required_by, }; use crate::world_session::{WorldService, module_hash}; diff --git a/pkgs/id/web/src/goto-line.test.ts b/pkgs/id/web/src/goto-line.test.ts index 0b18ed5725..94168ccef2 100644 --- a/pkgs/id/web/src/goto-line.test.ts +++ b/pkgs/id/web/src/goto-line.test.ts @@ -17,7 +17,13 @@ import { createGotoLinePlugin, destroyGotoLineDialog } from "./goto-line"; function createStateWithGotoLine(docContent?: string): EditorState { const plugin = createGotoLinePlugin(); const doc = docContent - ? rawSchema.node("doc", null, [rawSchema.node("code_block", null, docContent ? [rawSchema.text(docContent)] : [])]) + ? rawSchema.node("doc", null, [ + rawSchema.node( + "code_block", + null, + docContent ? [rawSchema.text(docContent)] : [], + ), + ]) : undefined; return EditorState.create({ schema: rawSchema, @@ -27,7 +33,10 @@ function createStateWithGotoLine(docContent?: string): EditorState { } /** Create an EditorView in a container div with the goto-line plugin. */ -function createViewWithGotoLine(docContent?: string): { view: EditorView; container: HTMLElement } { +function createViewWithGotoLine(docContent?: string): { + view: EditorView; + container: HTMLElement; +} { const container = document.createElement("div"); document.body.appendChild(container); const state = createStateWithGotoLine(docContent); @@ -44,7 +53,11 @@ function triggerGotoLine(view: EditorView): boolean { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- handleKeyDown this context workaround const handler = (plugin.props as any).handleKeyDown; if (!handler) return false; - return handler.call(plugin, view, new KeyboardEvent("keydown", { key: "g", ctrlKey: true })); + return handler.call( + plugin, + view, + new KeyboardEvent("keydown", { key: "g", ctrlKey: true }), + ); } // ── Tracked resources for cleanup ────────────────────────────────── @@ -191,7 +204,9 @@ describe("go-to-line command", () => { triggerGotoLine(view); - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; expect(input).not.toBeNull(); // 3 lines in doc → placeholder should contain "3" expect(input.placeholder).toContain("3"); @@ -224,9 +239,13 @@ describe("dialog input interaction", () => { const dialog = container.querySelector(".goto-line-dialog") as HTMLElement; expect(dialog).not.toBeNull(); - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; // Simulate pressing Escape on the input - input.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true })); + input.dispatchEvent( + new KeyboardEvent("keydown", { key: "Escape", bubbles: true }), + ); expect(dialog.style.display).toBe("none"); }); @@ -239,10 +258,14 @@ describe("dialog input interaction", () => { triggerGotoLine(view); const dialog = container.querySelector(".goto-line-dialog") as HTMLElement; - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; input.value = "1"; - input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); + input.dispatchEvent( + new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), + ); expect(dialog.style.display).toBe("none"); }); @@ -253,13 +276,17 @@ describe("dialog input interaction", () => { triggerGotoLine(view); - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; input.value = "2"; // Before: cursor is at default position const _posBefore = view.state.selection.from; - input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); + input.dispatchEvent( + new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), + ); // After: cursor should have moved (to line 2 start) // In rawSchema: doc > code_block > text "first\nsecond\nthird" @@ -277,25 +304,36 @@ describe("dialog input interaction", () => { ["2.9", "fractional"], ["999", "out of range"], ["", "empty"], - ])("Enter with %s (%s) does not move the cursor and keeps the dialog open", (value) => { - const { view, container } = createViewWithGotoLine("first\nsecond\nthird"); - views.push(view); - containers.push(container); - - triggerGotoLine(view); - - const dialog = container.querySelector(".goto-line-dialog") as HTMLElement; - const input = container.querySelector(".goto-line-input") as HTMLInputElement; - input.value = value; - const posBefore = view.state.selection.from; - - input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); - - // #712: invalid input must not be silently reinterpreted (0 -> line 1, - // 2.9 -> line 2) or swallowed (999) — no move, dialog stays open. - expect(view.state.selection.from).toBe(posBefore); - expect(dialog.style.display).not.toBe("none"); - }); + ])( + "Enter with %s (%s) does not move the cursor and keeps the dialog open", + (value) => { + const { view, container } = createViewWithGotoLine( + "first\nsecond\nthird", + ); + views.push(view); + containers.push(container); + + triggerGotoLine(view); + + const dialog = container.querySelector( + ".goto-line-dialog", + ) as HTMLElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; + input.value = value; + const posBefore = view.state.selection.from; + + input.dispatchEvent( + new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), + ); + + // #712: invalid input must not be silently reinterpreted (0 -> line 1, + // 2.9 -> line 2) or swallowed (999) — no move, dialog stays open. + expect(view.state.selection.from).toBe(posBefore); + expect(dialog.style.display).not.toBe("none"); + }, + ); it("Enter with line 1 moves cursor to the first line start", () => { const { view, container } = createViewWithGotoLine("first\nsecond"); @@ -304,10 +342,14 @@ describe("dialog input interaction", () => { triggerGotoLine(view); - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; input.value = "1"; - input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); + input.dispatchEvent( + new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), + ); // Line 1 starts at the code_block's content start: the block sits // at pos 0, so its text starts at doc pos 1 (#745 doc-walk mapping). @@ -341,9 +383,13 @@ describe("go-to-line across textblocks (#745)", () => { } function gotoLine(container: HTMLElement, value: string): void { - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; input.value = value; - input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true })); + input.dispatchEvent( + new KeyboardEvent("keydown", { key: "Enter", bubbles: true }), + ); } it("rich doc of three paragraphs reports 3 lines and jumps to the second paragraph", () => { @@ -355,7 +401,9 @@ describe("go-to-line across textblocks (#745)", () => { const { view, container } = createViewFromDoc(richSchema, doc); triggerGotoLine(view); - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; // textContent is "alphabetagamma" (no separators) — the old count said 1. expect(input.placeholder).toContain("3"); expect(input.max).toBe("3"); @@ -373,7 +421,9 @@ describe("go-to-line across textblocks (#745)", () => { const { view, container } = createViewFromDoc(rawSchema, doc); triggerGotoLine(view); - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; expect(input.max).toBe("4"); gotoLine(container, "3"); @@ -395,7 +445,9 @@ describe("go-to-line across textblocks (#745)", () => { const { view, container } = createViewFromDoc(richSchema, doc); triggerGotoLine(view); - const input = container.querySelector(".goto-line-input") as HTMLInputElement; + const input = container.querySelector( + ".goto-line-input", + ) as HTMLInputElement; expect(input.max).toBe("4"); gotoLine(container, "3"); diff --git a/pkgs/id/web/src/goto-line.ts b/pkgs/id/web/src/goto-line.ts index 1c410d5e5e..544310faef 100644 --- a/pkgs/id/web/src/goto-line.ts +++ b/pkgs/id/web/src/goto-line.ts @@ -99,14 +99,20 @@ function openGotoLine(view: EditorView): void { const line = Number(raw); const lineCount = activeView ? getLineCount(activeView) : 0; const pos = - activeView && raw !== "" && Number.isInteger(line) && line >= 1 && line <= lineCount + activeView && + raw !== "" && + Number.isInteger(line) && + line >= 1 && + line <= lineCount ? getLineStartPos(activeView, line) : null; if (pos === null || !activeView) { dialogInput?.select(); return; } - const tr = activeView.state.tr.setSelection(TextSelection.create(activeView.state.doc, pos)); + const tr = activeView.state.tr.setSelection( + TextSelection.create(activeView.state.doc, pos), + ); activeView.dispatch(tr); activeView.focus(); // Scroll the cursor into view diff --git a/pkgs/id/web/src/search-panel.ts b/pkgs/id/web/src/search-panel.ts index 07e9155de3..4a044bf9a7 100644 --- a/pkgs/id/web/src/search-panel.ts +++ b/pkgs/id/web/src/search-panel.ts @@ -69,15 +69,18 @@ function updateMatchCount(view: EditorView): void { return; } const total = countMatches(view); - panelState.matchCountEl.textContent = total === 0 ? "No results" : `${total} match${total === 1 ? "" : "es"}`; + panelState.matchCountEl.textContent = + total === 0 ? "No results" : `${total} match${total === 1 ? "" : "es"}`; } /** Push current input values into prosemirror-search state. */ function syncQuery(view: EditorView): void { const searchText = panelState.searchInput?.value ?? ""; const replaceText = panelState.replaceInput?.value ?? ""; - const caseCheckbox = panelState.panelEl?.querySelector("#search-case"); - const regexCheckbox = panelState.panelEl?.querySelector("#search-regex"); + const caseCheckbox = + panelState.panelEl?.querySelector("#search-case"); + const regexCheckbox = + panelState.panelEl?.querySelector("#search-regex"); const query = new SearchQuery({ search: searchText, @@ -189,8 +192,12 @@ function setupPanelEvents(): void { }); // Case/regex toggles - panelEl.querySelector("#search-case")?.addEventListener("change", () => syncQuery(view)); - panelEl.querySelector("#search-regex")?.addEventListener("change", () => syncQuery(view)); + panelEl + .querySelector("#search-case") + ?.addEventListener("change", () => syncQuery(view)); + panelEl + .querySelector("#search-regex") + ?.addEventListener("change", () => syncQuery(view)); } /** Open find panel, optionally showing replace. */ @@ -203,16 +210,24 @@ function openPanel(view: EditorView, showReplace: boolean): void { // is detached with the old container and its handlers still point at the // destroyed view — and no production code calls destroySearchPanel() on // teardown. Rebind instead of "opening" a detached node (#718). - if (panelState.panelEl && (panelState.view !== view || panelState.panelEl.parentElement !== container)) { + if ( + panelState.panelEl && + (panelState.view !== view || panelState.panelEl.parentElement !== container) + ) { destroySearchPanel(); } if (!panelState.panelEl) { panelState.panelEl = createPanel(container); panelState.searchInput = panelState.panelEl.querySelector("#search-input"); - panelState.replaceInput = panelState.panelEl.querySelector("#replace-input"); - panelState.matchCountEl = panelState.panelEl.querySelector("#search-match-count"); - panelState.replaceRow = panelState.panelEl.querySelector("#search-replace-row"); + panelState.replaceInput = + panelState.panelEl.querySelector("#replace-input"); + panelState.matchCountEl = panelState.panelEl.querySelector( + "#search-match-count", + ); + panelState.replaceRow = panelState.panelEl.querySelector( + "#search-replace-row", + ); panelState.view = view; setupPanelEvents(); }