Prettier plugin (v2.1.0, monthly releases) for formatting PowerShell source files (.ps1, .psm1, .psd1) with idiomatic defaults. Supports fine-grained configuration like indentation style/width, trailing commas, brace style, alias rewriting, and keyword casing. Requires Node.js >=20.11.0, Prettier >=3, and has an optional peer dependency on TypeScript ^6.0.3 for types. Extensively tested with ≥95% coverage, ready for CI/CD pipelines. Differentiator: first-class Prettier integration with options beyond basic PowerShell formatters.
npm install prettier-plugin-powershellVerified import paths — ran on the pinned version, not inferred.
Formats a simple PowerShell script using the plugin programmatically with custom options.
Use ESM import or dynamic import().
Upgrade Node.js to 20.11.0 or higher.
Upgrade Prettier to v3+.
Rename option to powershellRewriteAliases.
Set both 'plugins: ["prettier-plugin-powershell"]' and 'parser: "powershell"' .
Use powershellIndentHereStrings option to control indent behavior.
Run `npm install --save-dev prettier-plugin-powershell` and verify the package is in node_modules.
Add 'parser: "powershell"' to Prettier options or config file.
Switch to ESM import (import ... from ...) or use dynamic import().