Repository navigation
Closed
Description
🤖 Disclaimer: I had Claude help me write this issue.
feat(sh): ✨ support zsh dialect by upgrading sh-syntax to 0.6.0
🐛 Problem
prettier-plugin-shcannot format valid zsh scripts.- Zsh parameter modifier chains such as
${0:A:h:h}are rejected withternary operator missing ? before :. - Root cause is upstream:
sh-syntaxbundled amvdan/shbuild with no zshLangVariant.
🔁 Reproduction
- Format a file containing a zsh modifier chain:
DIR=${0:A:h:h} - Result with the current pinned
sh-syntax(0.5.8):- Throws
ternary operator missing ? before : LangVariant.LangZshisundefined(no zsh variant exists)
- Throws
📦 Upstream fix (already merged/available)
- Issue: [bug] 🐛 valid zsh errors with
ternary operator missing ? before :— vendoredmvdan/shversion has no zsh dialect sh-syntax#135 - Fix PR: feat: ✨ add zsh dialect support (rebuild wasm against mvdan/sh v3.13.1) sh-syntax#136
- Released in
[email protected](https://www.npmjs.com/package/sh-syntax/v/0.6.0), which:- Rebuilds
main.wasmagainstmvdan/shv3.13.1 (was v3.11.0) - Exposes a new
LangZshvariant - Breaking:
LangVariantis now a bit-flag enum (1 << iota), so numeric values changed:LangBash:0→1LangPOSIX:1→2LangMirBSDKorn:2→4LangBats:3→8LangZsh: (new) →16LangAuto:4→32
- Rebuilds
🛠️ Proposed changes in prettier-plugin-sh
- Bump dependency:
packages/sh/package.json→"sh-syntax": "^0.6.0" - Expose the variant: add
LangVariant.LangZshto thevariantoptionchoicesinpackages/sh/src/index.ts- Without this, Prettier rejects
variant: 16withInvalid variant value. Expected 1, 2, 4, 8 or 32, but received 16.
- Without this, Prettier rejects
- Update tests for the new upstream error wording (
mvdan/shv3.13 now backtick-quotes tokens):test/error.spec.ts:encountered )→encountered `)`test/__snapshots__/fixtures.spec.ts.snap(445.sh):closing quote '→closing quote `'`
✅ Verification
- After applying all three changes locally against
[email protected]:${0:A:h:h}formats correctly withvariant: LangVariant.LangZshfoo(){ echo ${1:t}; }→foo() { echo ${1:t}; }(modifier chains preserved)- Full suite green:
lint:es✅,lint:tsc✅,vitest run✅ (83/83)
⚠️ Note on installing sh-syntax@^0.6.0
- Yarn 4's default
npmMinimalAgeGate(1d) reports newly published versions asquarantinedfor the first 24h after publish. [email protected]was published2026-07-08T05:08:33Z, so a fresh install only resolves cleanly after2026-07-09T05:08:33Z.- Not a blocker for the change itself — just relevant for anyone testing immediately after release.
🙋 Willing to contribute
- I will open a PR with all three changes (dependency bump +
LangZshchoice + test updates) once Yarn's 1-day age-gate moratorium on[email protected]lifts (after2026-07-09T05:08:33Z), so CI can resolve the dependency cleanly.
Metadata
Metadata
Assignees
Labels
No labels
Activity
JounQin commentedon Jul 9, 2026
Thanks, and feel free to add
sh-syntaxinto yarn's pre-approved config.