Skip to content

feat(prettier-plugin-sh): ✨ support zsh dialect via sh-syntax@^0.6.0 - #512

Merged
JounQin merged 1 commit into
un-ts:masterfrom
jjloneman:feature/gh-511-add-zsh-support-prettier-plugin-sh
Jul 10, 2026
Merged

JounQin merged 1 commit into
un-ts:masterfrom
jjloneman:feature/gh-511-add-zsh-support-prettier-plugin-sh

Conversation

@jjloneman

@jjloneman jjloneman commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Disclaimer: I had Claude help me generate this description.

🎯 Summary

🔗 Upstream

🛠️ Changes

  • Dependency: bump sh-syntax ^0.5.8 → ^0.6.0 (packages/sh/package.json, yarn.lock).
  • Option: add LangVariant.LangZsh to the variant option choices in packages/sh/src/index.ts.
    • Without it, Prettier rejects the value with Invalid variant value. Expected 1, 2, 4, 8 or 32, but received 16.
  • Test: add packages/sh/test/zsh.spec.ts covering the LangZsh constant and formatting of a zsh modifier chain.
  • Tests (upstream wording): mvdan/sh v3.13 now backtick-quotes tokens in parse errors, so:
    • test/error.spec.ts: encountered ) → encountered `)`
    • test/__snapshots__/fixtures.spec.ts.snap (445.sh): closing quote ' → closing quote `'`
  • Changeset: minor bump for prettier-plugin-sh.

✅ Verification

  • yarn build ✅
  • yarn lint:es ✅
  • yarn lint:tsc ✅
  • yarn test ✅ (83/83)
  • Manual check: foo(){ echo ${1:t}; } → foo() { echo ${1:t}; }, ${0:A:h:h} preserved.

📝 Notes

  • The LangVariant numeric values changed upstream (now 1 << iota bit flags), but this plugin references the exported constants, so no numeric values are hard-coded here.
  • No new file type/extension is registered — this only adds the zsh parser variant — so the generated languages.ts is unaffected.

Summary by CodeRabbit

  • New Features

    • Added support for the Zsh shell dialect in shell formatting.
  • Bug Fixes

    • Improved handling of Zsh-style modifier chains so they format correctly.
    • Updated an error message expectation to match the latest output formatting.

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad408bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
prettier-plugin-sh Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Upgrades the sh-syntax dependency to ^0.6.0 to support the zsh dialect, adds a LangZsh choice to the variant option in prettier-plugin-sh, updates a test's expected error message wording, and adds a new test file verifying zsh modifier-chain formatting.

Changes

Zsh dialect support

Layer / File(s) Summary
Dependency upgrade and changeset
packages/sh/package.json, .changeset/gh-511-add-zsh-support.md
Bumps sh-syntax from ^0.5.8 to ^0.6.0 and adds a patch changeset describing the zsh dialect support addition.
Expose LangZsh variant option
packages/sh/src/index.ts
Adds a new LangZsh entry to the variant.choices array with a description and value: LangVariant.LangZsh, inserted between LangBats and LangAuto.
Test updates for new behavior
packages/sh/test/error.spec.ts, packages/sh/test/zsh.spec.ts
Updates the expected parse error message to backtick-quote the unexpected token, and adds a new spec verifying LangVariant.LangZsh is defined and that formatting preserves ${0:A:h:h} modifier chains.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: enhancement, feature

Suggested reviewers: JounQin

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive Core requirements are implemented, but the snapshot wording update cannot be verified because packages/sh/test/snapshots/fixtures.spec.ts.snap was excluded by !**/*.snap. Provide the excluded snapshot file or remove the path filter so the error-message update can be verified.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes stay focused on zsh support, dependency bumping, and related tests/metadata with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding zsh dialect support through sh-syntax 0.6.0.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@codesandbox-ci

codesandbox-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedsh-syntax@​0.5.8 ⏵ 0.6.0100 +1100100 +187 +7100

View full report

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jjloneman

Copy link
Copy Markdown
Contributor Author

I ran build and lint locally and it seemed to pass:

$ yarn build && echo "✅ build" && yarn lint && echo "✅ lint"

✅ build
✅ lint

@JounQin, would you mind running the CI actions? Thanks!

@pkg-pr-new

pkg-pr-new Bot commented Jul 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

prettier-plugin-autocorrect

npm i https://pkg.pr.new/prettier-plugin-autocorrect@512

prettier-plugin-pkg

npm i https://pkg.pr.new/prettier-plugin-pkg@512

prettier-plugin-sh

npm i https://pkg.pr.new/prettier-plugin-sh@512

prettier-plugin-sql

npm i https://pkg.pr.new/prettier-plugin-sql@512

prettier-plugin-toml

npm i https://pkg.pr.new/prettier-plugin-toml@512

commit: ad408bc

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.28%. Comparing base (4323d8c) to head (ad408bc).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #512   +/-   ##
=======================================
  Coverage   87.28%   87.28%           
=======================================
  Files          10       10           
  Lines         236      236           
  Branches       66       66           
=======================================
  Hits          206      206           
  Misses         29       29           
  Partials        1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JounQin
JounQin merged commit 733fcfd into un-ts:master Jul 10, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[prettier-plugin-sh] ⬆️ support zsh dialect by upgrading sh-syntax to 0.6.0

2 participants