Skip to content

jsonnetfmt chooses weird hanging indent #1009

Open
@fedya-at-db

Description

@fedya-at-db

Perhaps this is working as intended, but I found it quite surprising and it took some trial and error to see what exactly the fmt is focusing on. Both of the below snippets are how jsonnetfmt with no flag overrides chooses to format the code:

local A = {
  foo: true,
} + {
  bar: true,
};
local B = {
            foo: true,
          } +
          {
            bar: true,
          };

true

The key difference is whether we join the two objects with } + { or insert a newline before the {. This can produce some massive horizontal indentation in some nested object definitions as it tries to align everything on the first opening {.

I guess the positive is that you can control this yourself by keeping the { on the same line but it still feels like not a very useful formatted output.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions