Skip to content

Commit

Permalink
Teach jsonnet-lint about optional parameters of std.manifestYamlDoc (g…
Browse files Browse the repository at this point in the history
…oogle#705)

manifestYamlDoc takes two optional parameters, `indent_array_in_object` and `quote_keys`. This commit teaches jsonnet-lint about them so that it doesn't raise errors when you use them.

There are other stdlib library functions with this problem; the true solution is probably to auto-generate this from the stdlib AST, but this at least gets the linter happy with this particular function.
  • Loading branch information
swgillespie authored Jun 13, 2023
1 parent 16a10df commit 9639773
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion linter/internal/types/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func prepareStdlib(g *typeGraph) {
"manifestTomlEx": g.newSimpleFuncType(stringType, "value", "indent"),
"manifestJsonEx": g.newSimpleFuncType(stringType, "value", "indent"),
"manifestJsonMinified": g.newSimpleFuncType(stringType, "value"),
"manifestYamlDoc": g.newSimpleFuncType(stringType, "value"),
"manifestYamlDoc": g.newFuncType(stringType, []ast.Parameter{required("value"), optional("indent_array_in_object"), optional("quote_keys")}),
"manifestYamlStream": g.newSimpleFuncType(stringType, "value"),
"manifestXmlJsonml": g.newSimpleFuncType(stringType, "value"),

Expand Down
3 changes: 3 additions & 0 deletions linter/testdata/stdlib_manifestYamlDoc.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
std.manifestYamlDoc({
hello: 'world',
}, indent_array_in_object=false, quote_keys=true)
Empty file.

0 comments on commit 9639773

Please sign in to comment.