prettier-plugin-expand-json
v1.1.0
Published
Expand JSON arrays and objects into multi-line format with Prettier
Maintainers
Readme
Overview
This plugin expands all JSON arrays and objects into a consistent multi-line format.
- Works with both JSON and JSONC files.
- Supports files that Prettier treats as special cases, including
package.json,composer.json, and others. - Comes without any additional dependencies.
Example
{
"extends": "@standard-config/tsconfig",
"compilerOptions": {
"types": ["node", "vitest/globals"]
}
}…will always be formatted as:
{
"extends": "@standard-config/tsconfig",
"compilerOptions": {
"types": [
"node",
"vitest/globals"
]
}
}Install
npm install --save-dev prettier-plugin-expand-jsonpnpm add --save-dev prettier-plugin-expand-jsonUsage
Reference prettier-plugin-expand-json in your Prettier config:
{
"plugins": [
"prettier-plugin-expand-json"
]
}If you’re using any other JSON plugins, make sure prettier-plugin-expand-json is listed last. This applies to each overrides entry as well.
{
"plugins": [
"prettier-plugin-sort-json",
"prettier-plugin-expand-json"
]
}{
"overrides": [
{
"files": "**/package.json",
"options": {
"plugins": [
"prettier-plugin-pkg",
"prettier-plugin-expand-json"
]
}
}
]
}Related
License
MIT © Dom Porada
