-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create jqfmt to format jq scripts #2366
Comments
This could also morph into a bit of a linter/best practice recommender, as reading through builtin.jq has taught me that I'm not using the built-ins very efficiently in my long template! |
jq program is usually very short, I mean 100 lines of jq program is like very big. Manually formatting isn't a big deal, I guess that's why nobody is working on it. I remember there is vscode plugin that can format jq program, maybe you should try it. |
Hi, @colindean. I took a stab at |
Are there even any formatting guidelines written in prose anywhere? For example, it seems everyone has different opinions on whether |
Not that i know of. I personally prefer and have setteled on a quite verbose "haskell"-style for bigger jq programs, see https://github.com/wader/jqjq for example how it looks. |
I've written an appreciably long jq template that I'm rationally storing in a file in invoking with
jq --from-file script.jq
. Frustratingly, I had to format it myself by hand in order to understand and edit it better. It'd be convenient if there was ajqfmt
binary orjq fmt
command built-in that could take a template and parse it, then output it in the standard formatting, kinda like gofmt, scalafmt, rustfmt, Black for Python, etc.Example, about 13 lines from my long script bordering on "I probably should have done this in $language instead of jq":
would become something like
with a "pretty print" option or remain like it was (manually adjusted from the latter in this example) in a "compressed" one-liner.
The text was updated successfully, but these errors were encountered: