{"_id":"@aforemendude/prettier-plugin-json-utils","name":"@aforemendude/prettier-plugin-json-utils","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"author":{"name":"aforemendude"},"bugs":{"url":"https://github.com/aforemendude/prettier-plugin-json-utils/issues"},"description":"A Prettier plugin for sorting JSON keys, with specialized modes for VS Code settings and package.json files.","devDependencies":{"@types/node":"20.19.43","prettier":"3.9.6","typescript":"7.0.2","vite":"8.2.2","vitest":"4.1.11"},"devEngines":{"runtime":{"name":"node","version":">=22.12.0"}},"engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"homepage":"https://github.com/aforemendude/prettier-plugin-json-utils","keywords":["prettier","prettier-plugin","json","package-json","vscode"],"license":"MIT","main":"./dist/index.js","name":"@aforemendude/prettier-plugin-json-utils","peerDependencies":{"prettier":">=3.9.0 <4.0.0"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/aforemendude/prettier-plugin-json-utils.git"},"scripts":{"build":"npm run clean && tsc -p tsconfig.build.json","clean":"node scripts/clean.mjs","format":"prettier --write --cache --cache-strategy metadata .","format:check":"prettier --check --cache --cache-strategy metadata .","format:nocache":"prettier --write .","prepack":"npm install && git diff --exit-code -- package-lock.json && npm run verify","test":"vitest run","test:integration":"vitest run test/integration","test:unit":"vitest run test/unit","typecheck":"tsc -p tsconfig.json","verify":"prettier --check . && npm run typecheck && npm run build && npm run test"},"type":"module","types":"./dist/index.d.ts","version":"1.0.0","gitHead":"3140eaaf9993756ea375282adc0ac40d6088a6af","_id":"@aforemendude/prettier-plugin-json-utils@1.0.0","_nodeVersion":"24.20.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-4aBtMDcC5WvgCCcP1nYVibDiOukZhh6cQ734WRbyQcrc31lsVWWOPDJgaUcxqVAG/69ZS6uAQ5VZbxY4hUoNOg==","shasum":"a0ba54838ad0156562e228a0a6ca818ce4304dca","tarball":"https://registry.npmjs.org/@aforemendude/prettier-plugin-json-utils/-/prettier-plugin-json-utils-1.0.0.tgz","fileCount":25,"unpackedSize":24605,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDVJCbdXsGwedLgE6jPRg48wx4ucgvaZcaxo0YgCKdCAAiEAgU8f77I6K1NgXBBcrKlJkMBUkAmP/hPOGOABnbDPSYs="}]},"_npmUser":{"name":"aforemendude","email":"aforementioned.dude@gmail.com"},"directories":{},"maintainers":[{"name":"aforemendude","email":"aforementioned.dude@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prettier-plugin-json-utils_1.0.0_1788784462759_0.2595866377096152"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-07T12:34:22.527Z","1.0.0":"2026-09-07T12:34:22.890Z","modified":"2026-09-07T12:34:23.081Z"},"maintainers":[{"name":"aforemendude","email":"aforementioned.dude@gmail.com"}],"description":"A Prettier plugin for sorting JSON keys, with specialized modes for VS Code settings and package.json files.","homepage":"https://github.com/aforemendude/prettier-plugin-json-utils","keywords":["prettier","prettier-plugin","json","package-json","vscode"],"repository":{"type":"git","url":"git+https://github.com/aforemendude/prettier-plugin-json-utils.git"},"author":{"name":"aforemendude"},"bugs":{"url":"https://github.com/aforemendude/prettier-plugin-json-utils/issues"},"license":"MIT","readme":"# Prettier Plugin JSON Utils\n\nA Prettier plugin for sorting JSON keys, with specialized modes for VS Code settings and `package.json` files.\n\nThe plugin has three modes:\n\n- `sort-keys` (default) recursively sorts object keys while preserving array order and values.\n- `vscode-settings` recursively sorts object keys and normalizes selected Code Spell Checker word lists.\n- `package-json` recursively sorts object keys while preserving the order-sensitive conditional keys below `exports` and\n  `imports`.\n\n## Requirements\n\n- Node.js 20 or newer\n- Prettier 3.9.0 or newer within version 3\n\n## Installation\n\n```sh\nnpm install --save-dev @aforemendude/prettier-plugin-json-utils\n```\n\n## Configuration\n\nLoad the plugin in your Prettier configuration:\n\n```json\n{\n  \"plugins\": [\"@aforemendude/prettier-plugin-json-utils\"]\n}\n```\n\nWith no additional configuration, the plugin uses `sort-keys` for all supported JSON files. You can also select it\nexplicitly:\n\n```json\n{\n  \"jsonUtilsMode\": \"sort-keys\",\n  \"plugins\": [\"@aforemendude/prettier-plugin-json-utils\"]\n}\n```\n\nModes are never inferred from filenames or parsers. To use the specialized modes, set `jsonUtilsMode` globally or in an\noverride. For example:\n\n```json\n{\n  \"overrides\": [\n    {\n      \"files\": \"**/settings.json\",\n      \"options\": {\n        \"jsonUtilsMode\": \"vscode-settings\"\n      }\n    },\n    {\n      \"files\": \"**/package.json\",\n      \"options\": {\n        \"jsonUtilsMode\": \"package-json\"\n      }\n    }\n  ],\n  \"plugins\": [\"@aforemendude/prettier-plugin-json-utils\"]\n}\n```\n\nThe plugin wraps Prettier's `json`, `jsonc`, `json5`, and `json-stringify` parsers. The default is `sort-keys` for all\nfour parsers, including when calling `prettier.format()` without a `filepath`.\n\nWhen loaded after another JSON plugin, this plugin delegates to the nearest preceding parser with the same `astFormat`\nas Prettier's built-in parser. Parsers with a different or missing `astFormat` and their preprocessors are skipped. If\nno compatible parser is found, Prettier's built-in parser is used.\n\nIf you previously relied on automatic mode selection, add explicit overrides like those above to retain the specialized\nbehavior. Files with nonstandard names can use the same options.\n\n## Sort Keys Mode (Default)\n\nAll object keys are sorted recursively with JavaScript's case-sensitive lexicographic ordering, including objects inside\narrays. Array elements retain their order and string values retain their case. Comments are preserved and move with the\nproperties they describe.\n\nThis mode also sorts keys inside `exports` and `imports`. Select `package-json` for package manifests that need\nconditional key order preserved, and `vscode-settings` to normalize supported `cSpell` word lists.\n\n## VS Code Settings Mode\n\nAll object keys are sorted recursively with JavaScript's case-sensitive lexicographic ordering. Normal array order is\npreserved, and object keys inside arrays are still sorted.\n\nArrays assigned to these exact property names are additionally lowercased and sorted:\n\n- `cSpell.flagWords`\n- `cSpell.ignoreWords`\n- `cSpell.userWords`\n- `cSpell.words`\n\nThe normalization applies at any nesting level and retains duplicate entries. If one of these settings is not an array\nof strings, its array contents are left unchanged. Because sorting occurs on Prettier's JSON AST, comments in JSON and\nJSONC settings files are preserved and move with the values they describe.\n\n## Package JSON Mode\n\nObject keys are sorted recursively and array elements retain their original order, matching the JSON serialization\npolicy in `upgrade-npm-packages` with these order-sensitive exceptions:\n\n- Subpath keys in the root `exports` object are sorted.\n- A root `exports` object containing only condition keys retains its order.\n- Specifier keys in the root `imports` object are sorted.\n- Conditional keys and all nested objects below `exports` and `imports` retain their order.\n\nConditional order is semantically significant in Node.js, so a sequence such as `types`, `import`, `require`, `default`\nis never alphabetized by this mode.\n\n## Development\n\nWorking on this repository requires Node.js 22.12.0 or newer. The published plugin requires Node.js 20 or newer.\n\n```sh\nnpm install\nnpm run format:check\nnpm run typecheck\nnpm run test\nnpm run build\n```\n\n`npm run test` runs the TypeScript unit and integration suites with Vitest. `npm run build` removes and recreates\n`dist`, and `npm run verify` runs formatting, type checking, the build, and all tests.\n","readmeFilename":"README.md","_rev":"1-943ec701815d65f7c2b567fccb191732"}