From fed90cd9cd733a87f9fb27cfb32a3e08a7695603 Mon Sep 17 00:00:00 2001 From: zephyros-dev <67867662+zephyros-dev@users.noreply.github.com> Date: Tue, 27 Jun 2023 02:40:39 +0700 Subject: [PATCH] fix: add std.objectKeysValues to jsonnet-lint (#706) --- linter/internal/types/stdlib.go | 26 ++++++++++++++------------ testdata/stdlib_smoke_test.golden | 2 ++ testdata/stdlib_smoke_test.jsonnet | 2 ++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/linter/internal/types/stdlib.go b/linter/internal/types/stdlib.go index 08279c9..63c0eed 100644 --- a/linter/internal/types/stdlib.go +++ b/linter/internal/types/stdlib.go @@ -25,18 +25,20 @@ func prepareStdlib(g *typeGraph) { "extVar": g.newSimpleFuncType(anyType, "x"), // Types and reflection - "thisFile": stringType, - "type": g.newSimpleFuncType(stringType, "x"), - "length": g.newSimpleFuncType(numberType, "x"), - "objectHas": g.newSimpleFuncType(boolType, "o", "f"), - "objectFields": g.newSimpleFuncType(arrayOfString, "o"), - "objectValues": g.newSimpleFuncType(anyArrayType, "o"), - "objectHasAll": g.newSimpleFuncType(boolType, "o", "f"), - "objectFieldsAll": g.newSimpleFuncType(arrayOfString, "o"), - "objectValuesAll": g.newSimpleFuncType(anyArrayType, "o"), - "prune": g.newSimpleFuncType(anyObjectType, "a"), - "mapWithKey": g.newSimpleFuncType(anyObjectType, "func", "obj"), - "get": g.newFuncType(anyType, []ast.Parameter{required("o"), required("f"), optional("default"), optional("inc_hidden")}), + "thisFile": stringType, + "type": g.newSimpleFuncType(stringType, "x"), + "length": g.newSimpleFuncType(numberType, "x"), + "objectHas": g.newSimpleFuncType(boolType, "o", "f"), + "objectFields": g.newSimpleFuncType(arrayOfString, "o"), + "objectValues": g.newSimpleFuncType(anyArrayType, "o"), + "objectKeysValues": g.newSimpleFuncType(anyArrayType, "o"), + "objectHasAll": g.newSimpleFuncType(boolType, "o", "f"), + "objectFieldsAll": g.newSimpleFuncType(arrayOfString, "o"), + "objectValuesAll": g.newSimpleFuncType(anyArrayType, "o"), + "objectKeysValuesAll": g.newSimpleFuncType(anyArrayType, "o"), + "prune": g.newSimpleFuncType(anyObjectType, "a"), + "mapWithKey": g.newSimpleFuncType(anyObjectType, "func", "obj"), + "get": g.newFuncType(anyType, []ast.Parameter{required("o"), required("f"), optional("default"), optional("inc_hidden")}), // isSomething "isArray": g.newSimpleFuncType(boolType, "v"), diff --git a/testdata/stdlib_smoke_test.golden b/testdata/stdlib_smoke_test.golden index 7bc0b66..b2e507f 100644 --- a/testdata/stdlib_smoke_test.golden +++ b/testdata/stdlib_smoke_test.golden @@ -140,6 +140,8 @@ "objectFieldsAll": [ ], "objectHas": false, "objectHasAll": false, + "objectKeysValues": [ ], + "objectKeysValuesAll": [ ], "objectValues": [ ], "objectValuesAll": [ ], "parseHex": 3735928559, diff --git a/testdata/stdlib_smoke_test.jsonnet b/testdata/stdlib_smoke_test.jsonnet index 8272a5f..53a6d95 100644 --- a/testdata/stdlib_smoke_test.jsonnet +++ b/testdata/stdlib_smoke_test.jsonnet @@ -16,9 +16,11 @@ objectHas: std.objectHas(o={}, f="fieldname"), objectFields: std.objectFields(o={}), objectValues: std.objectValues(o={}), + objectKeysValues: std.objectKeysValues(o={}), objectHasAll: std.objectHasAll(o={}, f="fieldname"), objectFieldsAll: std.objectFieldsAll(o={}), objectValuesAll: std.objectValuesAll(o={}), + objectKeysValuesAll: std.objectKeysValuesAll(o={}), prune: std.prune(a={x: null, y: [null, "42"]}), mapWithKey: std.mapWithKey(func=function(key, value) 42, obj={a: 17}), get: [