Skip to content

Commit

Permalink
Add support for JSON with python3 -m json.tool
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Nov 26, 2023
1 parent 731edd2 commit e609203
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].

## Unreleased

### Formatters

* [`python3-json`](https://docs.python.org/3/library/json.html#module-json.tool)
for JSON ([#257]).

## 4.0 (released 2023-11-23)
### Breaking changes
* The order of entries in `apheleia-mode-alist` is no longer as
Expand Down
3 changes: 3 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
"--parser=yaml"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(purs-tidy . ("apheleia-npx" "purs-tidy" "format"))
(python3-json
. ("python3" "-m" "json.tool"
(apheleia-formatters-js-indent "--tab" "--indent")))
(rubocop . ("rubocop" "--stdin" filepath "--auto-correct"
"--stderr" "--format" "quiet" "--fail-level" "fatal"))
(ruby-standard . ("standardrb" "--stdin" filepath "--fix" "--stderr"
Expand Down
1 change: 1 addition & 0 deletions apheleia-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ INDENT-FLAG."
(js2-mode 'js2-basic-offset)
(js2-jsx-mode 'js2-basic-offset)
(js3-mode 'js3-indent-level)
(python-mode 'python-indent-offset)
(tsx-ts-mode 'typescript-ts-mode-indent-offset)
(typescript-mode 'typescript-indent-level)
(typescript-ts-mode 'typescript-ts-mode-indent-offset))))
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/python3-json.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt-get install -y python3
1 change: 1 addition & 0 deletions test/formatters/samplecode/python3-json/in.json
19 changes: 19 additions & 0 deletions test/formatters/samplecode/python3-json/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}

0 comments on commit e609203

Please sign in to comment.