Skip to content

Commit

Permalink
feat: add prettier-json-stringify formatter (#183)
Browse files Browse the repository at this point in the history
Adds a new formatter for prettier `prettier-json-stringify` which uses
prettier `json-stringify` parser. `json-stringify` parser is used by
prettier for formatting package.json files
  • Loading branch information
danielpza authored Jan 19, 2025
1 parent fa50cb3 commit e3db0e7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ The format is based on [Keep a Changelog].
## Unreleased
### Formatters
* `biome` ([#339]).
* `prettier-json-stringify` ([#183]).

[#339]: https://github.com/radian-software/apheleia/pull/339
[#183]: https://github.com/radian-software/apheleia/pull/183

## 4.3 (released 2024-11-12)
### Features
Expand Down
4 changes: 4 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=json"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-json-stringify
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=json-stringify"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-markdown
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=markdown"
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/prettier-json-stringify.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm install -g prettier
13 changes: 13 additions & 0 deletions test/formatters/samplecode/prettier-json-stringify/in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "test-package-json",
"version": "1.0.0",
"main": "index.js",
"files": ["index.js"],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
15 changes: 15 additions & 0 deletions test/formatters/samplecode/prettier-json-stringify/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "test-package-json",
"version": "1.0.0",
"main": "index.js",
"files": [
"index.js"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}

0 comments on commit e3db0e7

Please sign in to comment.