Auto-replace implicit + with explicit + in jsonnetfmt.
- Dominant language
- Go
- Stars
- 1.8k
- Forks
- 263
- PR merge metrics
- No merged PRs in 30d
Description
Consider following example:
```
❯ cat example.jsonnet
[
{ key1: "something", key2: "something" }
{ key1: "something_else", key2: "something_else" },
]
❯ jsonnet example.jsonnet
[
{
"key1": "something_else",
"key2": "something_else"
}
]
```
In the example above, there is a missing comma which results in the two objects being merged together. Since the objects have the same fields, the first object simply disappears from the output. Errors like this one are very hard to spot.
I'm wondering why is the "plus sign" / "merge operator" optional. Requiring the operator would make it obvious if the programmer wants to merge objects or if they just forgot a comma. Is there a recommended way to avoid errors like this one? Am I missing something?
Follow up question:
Would it make sense to have an option for `jsonnetfmt` that produces Jsonnet code that includes the optional "merge operators"?
PS: Sorry if Github issues are a bad place for questions like this one. Feel free to direct me elsewhere.
Contributor guide
Assessment
This issue has not been assessed yet.