Skip to content

Feat/shell script formatter#79

Closed
farhanmallik05 wants to merge 1 commit intobetterbugs:developfrom
farhanmallik05:feat/shell-script-formatter
Closed

Feat/shell script formatter#79
farhanmallik05 wants to merge 1 commit intobetterbugs:developfrom
farhanmallik05:feat/shell-script-formatter

Conversation

@farhanmallik05
Copy link

Description

Resolves #52

This PR implements a new development tool: Shell Script (Bash/Sh) Formatter, along with a basic linter to catch common shell script pitfalls. It provides a basic web-based interface for developers to paste, review, and format their shell scripts cleanly.

Key Changes

  • Dependency Added: Incorporated @wasm-fmt/shfmt to run the powerful shfmt engine directly in the browser via WebAssembly.
  • Component Implementation (shellFormatter.tsx):
    • Integrated Monaco Editor for clean input and output syntax highlighting of bash/shell code.
    • Built a fallback regex-based formatting engine in case the WASM file fails to load.
    • Implemented configurable formatting options (Indent Size, Tabs vs. Spaces, Binary Ops Next Line).
  • Basic Linter Engine:
    • Added ShellCheck-inspired instant lint warnings beneath the editor.
    • Flags dangerous SC2086 (Unquoted variables), SC2006 (Legacy backticks), SC2046 (Unquoted command substitutions), SC2164 (Unsafe cd without fallbacks), SC2115 (Dangerous rm -rf variables), and SC2059 (Direct variable prints in printf).
  • Webpack / Next.js Setup: Added experiments.asyncWebAssembly: true to next.config.js to enable seamless bundling of the .wasm binary within Next.js 14 production builds.
  • Routing & SEO (constants.tsx, developmentToolsConstant.tsx):
    • Grouped under Category178.
    • Configured developmentToolsRoutes and PATHS for the /shell-script-formatter route.
    • Populated comprehensive SEO metadata, Hero sections, Step-by-step guides, and "How it's Used" details matching existing tools.

Testing Done

  • Checked formatting functionality with various shell snippets.
  • Validated Monaco Editor loads correctly and highlights Bash semantics.
  • Verified that basic linting appropriately recognizes unquoted identifiers and unsafe operations.
  • Ran npm run lint and npm run build locally, ensuring successful static page generation without webpack compilation errors.

@SyedFahad7
Copy link
Collaborator

rebase with latest develop branch
keep this pr focused to adding shell script formatter and not the '[search, categorization logic, and associated UI styling' commits

@farhanmallik05 farhanmallik05 force-pushed the feat/shell-script-formatter branch from 129d526 to 6d2c149 Compare March 9, 2026 10:02
@SyedFahad7 SyedFahad7 self-requested a review March 9, 2026 21:10
Copy link
Collaborator

@SyedFahad7 SyedFahad7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the Shell Formatter work. I reviewed this update and there are still scope blockers.

Requested changes before approval:

  1. Keep this PR focused to Shell Script Formatter only
  • app/page.tsx currently includes search/categorization/highlight behavior changes (HighlightText, <mark>, category classification updates, keyboard shortcut handling, broader search matching).
  • app/developmentToolsStyles.module.scss adds search highlight/keyboard hint styles.
    These are unrelated to shell formatter and should be moved to a separate PR as requested earlier.
  1. Formatter options are not wired to shfmt
  • In shellFormatter.tsx, options are captured in state, but shfmt.format(input) is called without applying those options.
    Please either:
  • wire options into shfmt formatting call, or
  • remove non-functional options from UI for now.
  1. Remove debug file from PR
  • test-shfmt.js should not be part of this feature PR.

Also please rebase on latest develop (instead of merge commit) and force-push cleaned history.

@farhanmallik05 farhanmallik05 force-pushed the feat/shell-script-formatter branch from 0e6c060 to b8d521f Compare March 10, 2026 21:11
@SyedFahad7 SyedFahad7 closed this Mar 11, 2026
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.

feat(tools): add Shell Script (Bash/Sh) Formatter

2 participants