Tooling

Aside from the Jsonnet interpreters (which execute the Jsonnet code) there is other softare that can be used to get the most out of Jsonnet.

  • Formatter, for automatically fixing stylistic problems
  • Linter, for drawing attention to red flags that cannot be fixed automatically
  • Bazel rules, for config generation as part of your build system
  • Editor integration for syntax highlighting and other features

Formatter Demo

The formatter is a command-line utility bundled with the C++ build of Jsonnet. You can reformat files in place as so:

jsonnet fmt -i *.jsonnet

It will manage indenting and horizontal spacing within a line and remove excess vertical spacing. It will convert string literals, comments, fields and some operators into canonical forms as well as enforcing trailing commas. It will sort imports and remove excess nesting of parentheses. It will break lines in certain places.

output.jsonnet

Linter

The linter is another command-line utility bundled with the Go build of Jsonnet. You can check files as so:

jsonnet-lint file.jsonnet

Currently it is rudimentary and only checks for unused variables.

Bazel Jsonnet Rules

TODO