An opinionated shell script formatter for Prettier, extending support to Dockerfile, .properties, .gitignore, .env, hosts, and JVM options files. Current stable version is 0.18.1, maintained actively with minor updates every few months. It leverages mvdan-sh and dockerfmt under the hood, providing a consistent shell formatting experience within Prettier's ecosystem. Unlike standalone shell formatters, it integrates seamlessly with Prettier's plugin system and respects project-wide formatting configuration. Supports Prettier ^3.6.0 and Node 16+. Ships TypeScript definitions.
npm install prettier-plugin-shVerified import paths — ran on the pinned version, not inferred.
Configuration to enable shell script formatting via Prettier using the prettier-plugin-sh plugin. Shows setup in .prettierrc and basic CLI usage.
Use dynamic import() if needed, or let Prettier load the plugin automatically via the plugins config in .prettierrc.
Update Node to v16 or later.
Update prettier to ^3.6.0 or later.
Manually check formatted ignore files for correctness. Avoid relying on this plugin for ignore files.
Remove keepComments from configuration if previously set to false.
Use import() or let Prettier load the plugin automatically via .prettierrc. For legacy scripts, switch to ESM by adding 'type': 'module' to package.json or use dynamic import.
npm install prettier-plugin-sh --save-dev and add 'prettier-plugin-sh' to the plugins array in .prettierrc.
Update prettier to ^3.6.0: npm install prettier@^3.6.0 --save-dev
Ensure the file extension is .sh, .bash, .env, etc. Use the 'overrides' option to specify parser explicitly.