From 9639773cf0f59779e7ede78c729fe7e8b13dc796 Mon Sep 17 00:00:00 2001 From: Sean Gillespie Date: Tue, 13 Jun 2023 13:18:35 -0700 Subject: [PATCH] Teach jsonnet-lint about optional parameters of std.manifestYamlDoc (#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. --- linter/internal/types/stdlib.go | 2 +- linter/testdata/stdlib_manifestYamlDoc.jsonnet | 3 +++ linter/testdata/stdlib_manifestYamlDoc.linter.golden | 0 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 linter/testdata/stdlib_manifestYamlDoc.jsonnet create mode 100644 linter/testdata/stdlib_manifestYamlDoc.linter.golden diff --git a/linter/internal/types/stdlib.go b/linter/internal/types/stdlib.go index 6548fb21a..08279c9de 100644 --- a/linter/internal/types/stdlib.go +++ b/linter/internal/types/stdlib.go @@ -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"), diff --git a/linter/testdata/stdlib_manifestYamlDoc.jsonnet b/linter/testdata/stdlib_manifestYamlDoc.jsonnet new file mode 100644 index 000000000..333cc718c --- /dev/null +++ b/linter/testdata/stdlib_manifestYamlDoc.jsonnet @@ -0,0 +1,3 @@ +std.manifestYamlDoc({ + hello: 'world', +}, indent_array_in_object=false, quote_keys=true) diff --git a/linter/testdata/stdlib_manifestYamlDoc.linter.golden b/linter/testdata/stdlib_manifestYamlDoc.linter.golden new file mode 100644 index 000000000..e69de29bb