chore: bump prettier-plugin-svelte 3.5.2 -> 4.0.0#234
Conversation
The 4.0.0 plugin crashes during `prettier --check` when an `{@const}`
contains a ternary whose expressions involve a `BinaryExpression`
(`Error: unknown node type: BinaryExpression`). Move the `totalProgress`
computation out of the `{@const}` in SendButton.svelte into a script-level
`$derived` so prettier can format the file again, then take the major bump.
Breaking-change audit for 4.0.0:
- Requires Svelte 5 (have ^5.55.9).
- Drops `svelteBracketNewLine` and `svelteStrictMode` options — repo uses
neither in `package.json#prettier`.
Verified locally: `npm run lint`, `svelte-check`, `npm run build` clean.
There was a problem hiding this comment.
Code review
Small, narrowly-scoped dep bump (prettier-plugin-svelte 3.5.2 → 4.0.0) with a single repo-side workaround in SendButton.svelte for an upstream plugin bug. PR description is unusually thorough: documents the upstream crash, names the exact AST trigger (BinaryExpression inside a {@const} ternary), audits both 4.0.0 breaking changes (Svelte 5 requirement: satisfied at ^5.55.9; removed config keys: not in use), and includes lint/svelte-check/build evidence. I reproduced npm run lint, npx svelte-check --threshold warning, and npm run build locally — all clean. The {@const} → $derived rewrite is semantically equivalent for the visible value: percentages is always initialized to [], and the length > 0 guard returns 0 in the empty case, so what gets rendered inside {#if Encrypting} is unchanged. Only the {@const} that tripped the plugin existed in the codebase (verified by grep), so no other latent failures lurk. Engine requirement bumps to node>=20 — CI is on Node 24, so fine. The change is genuinely minimal: 18+/13- across package.json, package-lock.json, and one Svelte file. Nothing I'd block on; a couple of nits worth noting.
Additional nits (not tied to a specific line):
- Implicit Node>=20 floor:
package.jsongains an implicitnode>=20floor via prettier-plugin-svelte 4.0.0'senginesfield, but the repo itself has no top-levelengineskey. CI is fine (Node 24), but a contributor on Node 18 would now get an EBADENGINE warning on install with no documented signal that the floor moved. Optional: add"engines": { "node": ">=20" }topackage.jsonso the requirement is visible without spelunking transitive engine fields. - Upstream tracking link: The upstream prettier-plugin-svelte bug (BinaryExpression inside
{@const}ternary) is real but apparently not referenced by issue # in the PR body or commit message. If it has an upstream tracking link, drop it in the PR body so a future maintainer can tell when the workaround can be reverted. If no upstream issue exists yet, consider filing one — the reproducer is small and you've already isolated the AST trigger. - No automated test for the rewrite: Flagging only for completeness — the repo has no component-level test harness (Playwright is configured for e2e, not for this calculation), and the change is a 1-to-1 expression move, so adding a test scaffold for one expression isn't worth the cost here.
Test results: pass. Ran locally on Node 22.22.2 (CI uses 24): npm ci --legacy-peer-deps (pre-existing svelte-preprocess vs typescript ^6 peer conflict, unrelated to this PR), npx svelte-kit sync, npm run lint (clean), npx svelte-check --threshold warning (0 errors / 0 warnings / 0 files-with-problems across 477 files), npm run build (succeeds). GitHub CI: Svelte Check, Lint, Conventional Commit all green at review time.
Rule compliance
Checked the PR against all applicable rules in ~/dobby-memory/rules/ and the repo-specific notes in ~/dobby-memory/repos/postguard-website/. No rule violations.
Notable compliance highlights:
- Conventional commit title ✓ —
chore: bump prettier-plugin-svelte 3.5.2 -> 4.0.0follows the required format (amannn/action-semantic-pull-request@v5will accept). - PR close-issue keywords ✓ —
Closes #232is on its own line, properly linked. - Dep is used before bumping ✓ —
prettier-plugin-svelteis listed underpackage.json#prettier.pluginsand is required for.svelteparsing in lint-staged. - Tests-required-on-fixes — not applicable; this is a
chore:dep bump with a 1-to-1 expression move, not a product fix. - Docs drift — not applicable; dep bumps are explicitly filtered out by the rule.
- Repo-specific dep-bump gotchas (
dep-bump-gotchas.md) — the 2026-05-20 entry deferred this exact bump because no repo-side workaround was apparent at the time; this PR is the documented follow-up and demonstrates that moving the{@const}ternary into a script-level$derivedis a viable workaround. Once merged, that gotcha entry should be updated/retired. The husky pre-commit gotcha in the same notes file is not triggered —prettier-plugin-svelteis already listed inpackage.json#prettier.plugins.
Verdict: comment (no blockers from code review or rule check).
Summary
prettier-plugin-svelte3.5.2 → 4.0.0, which chore: update dependencies #232 deferred because the 4.0.0 plugin crashed onprettier --check(Error: unknown node type: BinaryExpression) forsrc/lib/components/filesharing/SendButton.svelte.{@const totalProgress = ...}ternary out of the template into a script-level$derived. The plugin can't format aBinaryExpressioninside a{@const}ternary, so the const was the only thing tickling the bug. The rendered behaviour is unchanged.svelteBracketNewLine/svelteStrictModeconfig keys. Neither is set inpackage.json#prettier.Closes #232.
Test plan
npm run lint(prettier --check + eslint) — cleannpx svelte-kit sync && npx svelte-check --threshold warning— 0 errors, 0 warningsnpm run build— succeeds