{"id":20396,"library":"prettier-plugin-package-perfection","title":"Prettier Plugin Package Perfection","description":"A Prettier plugin that formats package.json files using the prettier-package-json library for consistent ordering and styling. Version 1.1.0 is the latest stable version, released August 2022 with limited update activity. It requires Prettier ≥2.x and Node.js ≥14.18.0. Differentiators include automatic key sorting, customizable order via options, and seamless integration with Prettier workflows, unlike standalone formatters.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/megabyte-labs/prettier-plugin-package-perfection","tags":["javascript","automatic","fix","format","mblabs","megabytelabs","package","package.json","packagejson","typescript"],"install":[{"cmd":"npm install prettier-plugin-package-perfection","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-package-perfection","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-package-perfection","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for the plugin to function.","package":"prettier","optional":false},{"reason":"Core library used to format the package.json content.","package":"prettier-package-json","optional":false}],"imports":[{"note":"This is a Prettier plugin; you do not import it directly in your code. Install it and add to Prettier config.","wrong":"None","symbol":"default","correct":"No explicit import needed; Prettier auto-loads plugins"},{"note":"Ensure plugin is listed in the 'plugins' array of your Prettier configuration file.","wrong":"{\"plugins\": [\"prettier-plugin-package-perfection\"] }","symbol":"options","correct":"// .prettierrc\n{ \"plugins\": [\"prettier-plugin-package-perfection\"] }"},{"note":"TypeScript types are bundled; import type for option interfaces.","wrong":"const { PackagePerfectionOptions } = require('prettier-plugin-package-perfection')","symbol":"types","correct":"import type { PackagePerfectionOptions } from 'prettier-plugin-package-perfection'"}],"quickstart":{"code":"// Install dependencies\n// npm install --save-dev prettier prettier-plugin-package-perfection\n\n// .prettierrc (JSON)\n{\n  \"plugins\": [\"prettier-plugin-package-perfection\"],\n  \"packagePerfection\": {\n    \"sortAz\": true,\n    \"sortScripts\": false\n  }\n}\n\n// Run Prettier on package.json\n// npx prettier --write package.json","lang":"javascript","description":"Install the plugin, configure it in .prettierrc, and format your package.json with Prettier."},"warnings":[{"fix":"Update Node.js to >=14.18.0.","message":"Requires Node.js >=14.18.0; older versions will fail to load the plugin.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Check prettier-package-json documentation for option changes.","message":"Plugin uses prettier-package-json v2 which may deprecate some options; refer to their docs.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure your target file is exactly named 'package.json'.","message":"The plugin only runs on files named 'package.json'. Other files matching the pattern will not be affected.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use JSON or JavaScript Prettier configuration files.","message":"Some custom Prettier config formats (e.g., YAML) may not parse the plugin correctly; stick to JSON or JS config.","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-package-perfection' and ensure it's in devDependencies.","cause":"Plugin not installed or not in node_modules.","error":"Error: Cannot find module 'prettier-plugin-package-perfection'"},{"fix":"Add '\"plugins\": [\"prettier-plugin-package-perfection\"]' to your .prettierrc file.","cause":"Plugin not added to Prettier's plugins array.","error":"Error: Invalid plugin configuration: 'packagePerfection' option not recognized"},{"fix":"Check the plugin's README for supported options; correct spelling.","cause":"Option name typo or not supported in this version.","error":"Error: Unknown option 'packagePerfection.sortAz'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}