{"id":20454,"library":"prettier-plugin-yaml","title":"prettier-plugin-yaml","description":"A Prettier plugin providing additional YAML formatting options beyond Prettier's built-in support. Current stable version is 1.1.3. It adds options like yamlBlockStyle, yamlCollectionStyle, yamlQuoteKeys, and yamlQuoteValues. Released under MIT, it has a frequent release cadence with 6+ versions. Key differentiators: no dependencies beyond Prettier 3+, TypeScript types included, and addresses CVE-2026-33532 in the underlying yaml library. It is ESM-only and requires Node >=20.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/porada/prettier-plugin-yaml","tags":["javascript","formatting","prettier","prettier-plugin","yaml","yml","typescript"],"install":[{"cmd":"npm install prettier-plugin-yaml","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-yaml","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-yaml","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; the plugin requires Prettier version 3 or higher to function.","package":"prettier","optional":false}],"imports":[{"note":"The package is ESM-only. Import named exports; no default export exists since v1.1.2.","wrong":"const Plugin = require('prettier-plugin-yaml')","symbol":"Plugin","correct":"import { Plugin } from 'prettier-plugin-yaml'"},{"note":"Options object with TypeScript types; use named import.","wrong":"const { options } = require('prettier-plugin-yaml')","symbol":"options","correct":"import { options } from 'prettier-plugin-yaml'"},{"note":"PluginOptions is a type, not a value. Use type import for correct TypeScript usage.","wrong":"import { PluginOptions } from 'prettier-plugin-yaml'","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'prettier-plugin-yaml'"}],"quickstart":{"code":"// Install: npm install --save-dev prettier prettier-plugin-yaml\n// Add to .prettierrc:\n{\n  \"plugins\": [\"prettier-plugin-yaml\"],\n  \"yamlQuoteKeys\": true\n}\n// Then run: npx prettier --write file.yaml","lang":"typescript","description":"Shows installation, configuration with yamlQuoteKeys option, and usage with npx."},"warnings":[{"fix":"Add `\"type\": \"module\"` to your package.json or use .mjs files when importing the plugin programmatically.","message":"The package is ESM-only. Use `import` syntax, not `require()`, and ensure `\"type\": \"module\"` in package.json or use .mjs extension.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade to v1.1.2 or later: npm install prettier-plugin-yaml@latest","message":"The `Plugin` named export was incorrectly re-exported as a non-interface in v1.1.1. This was fixed in v1.1.2.","severity":"breaking","affected_versions":"1.1.1"},{"fix":"No action needed.","message":"All options are stable; no known deprecations as of v1.1.3.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure other YAML plugins appear before prettier-plugin-yaml in the plugins array.","message":"If using other YAML Prettier plugins, prettier-plugin-yaml must be listed last in the plugins array to take effect.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you need all strings quoted, consider using yamlQuoteValues with additional manual overrides.","message":"The yamlQuoteValues option does not apply to strings that are valid numeric or boolean representations; those remain unquoted.","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":"Update to v1.1.2+: npm install prettier-plugin-yaml@1.1.2","cause":"Using v1.1.1 where the Plugin export was malformed.","error":"TypeError: The 'Plugin' interface was incorrectly exported"},{"fix":"Use import syntax or set type: module in package.json.","cause":"Attempting to use require() on an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Run npm install --save-dev prettier-plugin-yaml and add 'prettier-plugin-yaml' to the plugins array in .prettierrc.","cause":"Plugin not installed or not configured in Prettier config.","error":"Error: Cannot find module 'prettier-plugin-yaml'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}