npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kachick/dprint-plugin-sh

v0.1.3

Published

dprint plugin for Shell formatting using shuck-formatter

Readme

dprint-plugin-sh

npm version CI - Nix Status

dprint Wasm plugin for Shell Scripts using shuck-formatter.

Installation

dprint add kachick/sh

Configuration

Empty works as default

{
  "sh": {
  }
}

Customize if necessary

{
  "sh": {
    "dialect": "auto",
    "indentWidth": 8,
    "useTabs": true,
    "binaryNextLine": false,
    "switchCaseIndent": false,
    "spaceRedirects": false,
    "keepPadding": false,
    "functionNextLine": false,
    "neverSplit": false,
    "simplify": false,
    "minify": false
  }
}

Options

This plugin directly uses default options from the upstream shuck-formatter crate. Current defaults are shown below:

| Option | Type | Default | Description | | ------------------ | ------- | -------- | ---------------------------------------------------------------------------------------- | | dialect | string | "auto" | Shell dialect: "auto", "bash", "posix", "mksh", "zsh". | | indentWidth | number | 8 | Number of spaces for indent. Inherits dprint global config if set, or falls back to 8. | | useTabs | boolean | true | Indent with tabs. Inherits dprint global config if set, or falls back to true. | | binaryNextLine | boolean | false | Put binary operators (&&, \|\|, \|) at start of next line instead of end. | | switchCaseIndent | boolean | false | Indent case pattern arms under the case statement. | | spaceRedirects | boolean | false | Put a space between redirect operators and target (e.g. > file instead of >file). | | keepPadding | boolean | false | Keep column alignment spaces between tokens. | | functionNextLine | boolean | false | Put function opening brace { on a new line (Allman style). | | neverSplit | boolean | false | Keep statements on a single line where possible. | | simplify | boolean | false | Rewrite redundant syntax to simpler forms (e.g. ${foo} to $foo). | | minify | boolean | false | Remove comments and extra whitespace to make code small. |

Indentation and Global Config

In dprint, top-level settings in dprint.json (such as "indentWidth": 2 and "useTabs": false) apply to all plugins by default.

If your project sets global options for other languages (like TypeScript or JSON), this plugin inherits them. If you want shell scripts to keep the standard shfmt style (tabs), override them in the "sh" block:

{
  "indentWidth": 2,
  "useTabs": false,
  "sh": {
    "useTabs": true
  }
}

Dialect Resolution

When dialect is "auto" (default), this plugin chooses the dialect in this order:

  1. Shebang: Reads the first line #!... (e.g., #!/usr/bin/env bash -> Bash, #!/usr/bin/env zsh -> Zsh).
  2. File extension:
    • .bash, .bats -> Bash
    • .zsh -> Zsh
    • .sh, .dash, .ksh -> Posix
    • .mksh -> Mksh
  3. Fallback: Files without an extension (like .envrc) default to Bash.

[!NOTE] .sh files without a shebang resolve to posix by default. If your .sh file uses Bash syntax (such as [[ ]]), parsing will fail in posix mode. To fix this, set "dialect": "bash" in your configuration or add a #!/usr/bin/env bash shebang line.

Supported Files

  • File extensions: .sh, .bash, .zsh, .ksh, .mksh, .dash, .bats
  • File names: .envrc, .bashrc, .bash_profile, .bash_login, .bash_aliases, .bash_logout, .profile, .zshrc, .zshenv, .zprofile, .zlogin, .zlogout

Unix tools often use shell scripts in extensionless files like dotfiles. This repository covers some popular file names above, but does not plan to keep adding more default file names. When formatting other extensionless scripts for your use case, use dprint's shebangs configuration first:

{
  "shebangs": {
    "#!/bin/sh": "sh",
    "#!/usr/bin/env bash": "bash",
    "#!/usr/bin/env zsh": "zsh"
  }
}

[!WARNING] Upstream shuck-formatter only infers dialects from shebangs and file extensions, falling back to Bash for extensionless files. This plugin bridges this gap by detecting known Zsh dotfiles (like .zshrc) and passing zsh dialect upstream. This workaround is heuristic. If you encounter unexpected formatting behavior, set "dialect": "zsh" explicitly.

Non-shell files such as Makefile are not supported.

Tips

To format code blocks in markdown, use the tags option in the official markdown plugin:

dprint add markdown

In tags:

  • Key: The code block language tag in Markdown (e.g. bash).
  • Value: The target file extension (without a period) that tells this plugin how to format the code.

For example, .envrc is a file name, not an extension. So map "envrc" to "bash".

{
  "markdown": {
    "tags": {
      "sh": "sh",
      "bash": "bash",
      "zsh": "zsh",
      "envrc": "bash",
      "shell": "sh",
      "shell-script": "sh"
    }
  }
}

This list satisfies linguist mapping.

Acknowledgments

  • Thanks to shuck for making it easy to use as a dprint Wasm plugin.
  • Thanks to shfmt for the reference and the original formatter.