Skip to content

feat: add shell simplification option - #143

Merged
JounQin merged 2 commits into
un-ts:mainfrom
celluj34:feat/simplify-option
Sep 24, 2026
Merged

JounQin merged 2 commits into
un-ts:mainfrom
celluj34:feat/simplify-option

Conversation

@celluj34

@celluj34 celluj34 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Adds an opt-in simplify print option backed by mvdan/sh/syntax.Simplify.

The option is carried through the TypeScript API and WASM boundary, applied after parsing and before printing, and enabled implicitly by minify to match shfmt behavior. The committed WASM artifact and focused coverage are updated.

This enables downstream formatters such as prettier-plugin-sh to expose mvdan's syntax simplification without invoking the shfmt CLI.

Validation:

  • yarn build
  • yarn test
  • yarn lint
  • Prettier check

Summary by CodeRabbit

  • New Features
    • Added a simplify print option that removes redundant shell syntax. It is disabled by default and can be used alongside existing print options.

@changeset-bot

changeset-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 77b64bc

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

This PR includes changesets to release 1 package
Name Type
sh-syntax 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 Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: a1c9c27c-8817-4f25-8922-22a92dc6376c

📥 Commits

Reviewing files that changed from the base of the PR and between d5a8e66 and 77b64bc.

⛔ Files ignored due to path filters (1)
  • main.wasm is excluded by !**/*.wasm
📒 Files selected for processing (6)
  • .changeset/tender-shells-simplify.md
  • main.go
  • processor/main.go
  • src/processor.ts
  • src/types.ts
  • test/basic.spec.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The print API adds a simplify option and passes it to the Go printer. The printer simplifies the syntax tree when simplify or minify is enabled. Tests cover output with the default, simplify, and minify options.

Changes

Shell syntax simplification

Layer / File(s) Summary
Expose and pass the simplify option
src/types.ts, src/processor.ts, main.go, processor/main.go
Adds the optional simplify setting to the TypeScript printer options and passes it through the WebAssembly process call to processor.PrinterOptions.
Simplify the syntax tree before printing
processor/main.go, test/basic.spec.ts, .changeset/tender-shells-simplify.md
Calls syntax.Simplify(file) when Simplify or Minify is enabled. Adds output expectations for default, simplify, and minify printing, and a Changeset entry.

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

Sequence Diagram(s)

sequenceDiagram
  participant TypeScriptProcessor
  participant GoProcess
  participant Printer
  participant SyntaxSimplify
  TypeScriptProcessor->>GoProcess: Pass simplify option
  GoProcess->>Printer: Set PrinterOptions.Simplify
  Printer->>SyntaxSimplify: Simplify file when Simplify or Minify is enabled
  SyntaxSimplify-->>Printer: Return simplified syntax tree
  Printer-->>TypeScriptProcessor: Return printed output
Loading

Suggested reviewers: jounqin

Merge Risk: ⚪ Minimal · up to 77b64

No actionable merge-blocking issue was identified. The focused test remains unrun because dependencies are unavailable, so verify it in the normal project environment.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an opt-in shell simplification option.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 5 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 golangci-lint (2.13.2)

level=error msg="[linters_context] typechecking error: build constraints exclude all Go files in "

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/processor.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/types.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

test/basic.spec.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


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

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
lib/browser.js 99 B (0%)
lib/index.js 334 B (0%)

@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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/sh-syntax@143

commit: 77b64bc

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d5a8e66) to head (77b64bc).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #143   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines           76        77    +1     
  Branches        29        30    +1     
=========================================
+ Hits            76        77    +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 ea9643f into un-ts:main Sep 24, 2026
24 checks passed
@celluj34
celluj34 deleted the feat/simplify-option branch September 24, 2026 04:49
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.

2 participants