Feat/shell script formatter #79#80
Open
farhanmallik05 wants to merge 3 commits intobetterbugs:developfrom
Open
Feat/shell script formatter #79#80farhanmallik05 wants to merge 3 commits intobetterbugs:developfrom
farhanmallik05 wants to merge 3 commits intobetterbugs:developfrom
Conversation
Resolves betterbugs#52. Implements a Shell Script Formatter using @wasm-fmt/shfmt, Monaco editor for syntax highlighting, and an integrated basic linter.
SyedFahad7
requested changes
Mar 11, 2026
Collaborator
SyedFahad7
left a comment
There was a problem hiding this comment.
Thanks for the PR - I reviewed pr-80 in depth.
Blocking issue
- Build is currently failing due to incorrect WASM init usage in
shellFormatter.tsx.
npm run buildfails with:Type error: This expression is not callable ... mod.default()
- Location:
app/components/developmentToolsComponent/shellFormatter.tsxaround themod.default()call in the format handler. - This needs to be fixed before merge.
Functional review notes
- Binary ops toggle is wired in the WASM path, but not in fallback behavior.
- In WASM format call,
binaryNextLineis passed and works for multiline&&/||. - In heuristic fallback,
binaryNextLineis not implemented, so behavior is inconsistent when WASM fails.
- Fallback formatter can be semantically risky for shell scripts.
- Fallback currently trims each line and re-indents heuristically.
- For edge cases (e.g., heredocs/case bodies/complex nested constructs), this may alter script meaning or intended content.
- Linting is custom heuristic, not ShellCheck integration.
- Warnings render correctly in the UI, but detection logic is regex-based and can produce false positives/negatives.
- Suggest clarifying wording as “ShellCheck-inspired checks” rather than implying full ShellCheck parity.
UI/behavior checks
Format,Copy,Download,Clearbutton flow is implemented correctly.- Output editor is read-only.
- No command execution path found; formatting/linting are string transformations only (good safety posture).
Requested changes before approval
- Fix the WASM initialization/type error so
npm run buildpasses. - Make fallback behavior safer (or disable fallback for unsupported cases) to avoid semantic drift.
- Either:
- implement
binaryNextLinein fallback too, or - disable/hide that option when fallback is active.
- implement
- Keep docs/tool description explicit that linting is heuristic, not full ShellCheck.
Please push an update and I’ll re-review quickly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new development tool: Shell Script Formatter. It uses a WebAssembly (WASM) implementation (
@wasm-fmt/shfmt) to offer professional, customizable formatting for Bash and.shscripts directly in the browser.Key Features:
@wasm-fmt/shfmtfor standard, predictable formatting.cdwithout|| exit(SC2164)rm -rfusage with variables (SC2115)printf(SC2059)Changes Included:
next.config.jsto enable WebpackasyncWebAssembly.@wasm-fmt/shfmttopackage.json.Testing