{"id":20404,"library":"prettier-plugin-powershell","title":"prettier-plugin-powershell","description":"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.","status":"active","version":"2.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/Nick2bad4u/prettier-plugin-powershell","tags":["javascript","prettier","prettier-plugin","powershell","formatter","formatting","ps1","psm1","psd1","typescript"],"install":[{"cmd":"npm install prettier-plugin-powershell","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-powershell","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-powershell","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: required to run the plugin","package":"prettier","optional":false},{"reason":"optional peer dependency: provides type definitions for custom AST work","package":"typescript","optional":true}],"imports":[{"note":"ESM-only since v2. CommonJS require will fail.","wrong":"const plugin = require('prettier-plugin-powershell')","symbol":"default","correct":"import plugin from 'prettier-plugin-powershell'"},{"note":"Named export for the AST parser; use when you need direct access to the parser object.","wrong":"import { powershell } from 'prettier'","symbol":"powershell","correct":"import { powershell } from 'prettier-plugin-powershell'"},{"note":"Type import for TypeScript users. Plugin interface is not a value export.","wrong":"import { Plugin } from 'prettier-plugin-powershell'","symbol":"Plugin","correct":"import type { Plugin } from 'prettier-plugin-powershell'"}],"quickstart":{"code":"import prettier from 'prettier';\nimport plugin from 'prettier-plugin-powershell';\n\nconst source = `$greeting = \"Hello, World!\"\nWrite-Output $greeting\n`;\n\nconst formatted = await prettier.format(source, {\n  filepath: 'script.ps1',\n  parser: 'powershell',\n  plugins: [plugin],\n  tabWidth: 4,\n  powershellTrailingComma: 'all',\n});\n\nconsole.log(formatted);","lang":"typescript","description":"Formats a simple PowerShell script using the plugin programmatically with custom options."},"warnings":[{"fix":"Use ESM import or dynamic import().","message":"Plugin is ESM-only since v2.0.0. CommonJS require() will throw.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Node.js to 20.11.0 or higher.","message":"Node.js >=20.11.0 required since v2.0.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade Prettier to v3+.","message":"Prettier v3 or higher required since v2.0.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Rename option to powershellRewriteAliases.","message":"Option powershellRewritAliases (note: missing 'e') removed in v2.0.0; use powershellRewriteAliases (correct spelling).","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Set both 'plugins: [\"prettier-plugin-powershell\"]' and 'parser: \"powershell\"' .","message":"Plugin must be listed in Prettier config's `plugins` array AND parser must be set to 'powershell'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use powershellIndentHereStrings option to control indent behavior.","message":"Formatting multi-line strings and here-strings may differ from native PowerShell expectations; always verify output.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev prettier-plugin-powershell` and verify the package is in node_modules.","cause":"Missing plugin in package.json dependencies or incorrect import path.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'prettier-plugin-powershell' imported from..."},{"fix":"Add 'parser: \"powershell\"' to Prettier options or config file.","cause":"Parser not set to 'powershell' when using plugin.","error":"TypeError: Cannot read properties of undefined (reading 'powershell')"},{"fix":"Switch to ESM import (import ... from ...) or use dynamic import().","cause":"Using CommonJS require() with ESM-only package.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}