Adds std.any and std.all to jsonnet-lint (#695)

Co-authored-by: Dave Cunningham <sparkprime@gmail.com>
This commit is contained in:
Jonathan Regehr 2023-05-25 08:09:56 -05:00 committed by GitHub
parent 7edd5d373b
commit 44538a33e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -139,6 +139,13 @@ func newTypeGraph(importFunc ImportFunc) *typeGraph {
},
})
g.newPlaceholder()
g._placeholders[boolArrayType] = concreteTP(TypeDesc{
ArrayDesc: &arrayDesc{
furtherContain: []placeholderID{boolType},
},
})
g.newPlaceholder()
g._placeholders[anyObjectType] = concreteTP(TypeDesc{
ObjectDesc: anyObjectDesc,

View File

@ -14,6 +14,7 @@ const (
nullType
anyArrayType
numberArrayType
boolArrayType
anyObjectType
anyFunctionType
stdlibType

View File

@ -144,6 +144,9 @@ func prepareStdlib(g *typeGraph) {
"minArray": g.newFuncType(anyArrayType, []ast.Parameter{required("arr"), optional("keyF")}),
"maxArray": g.newFuncType(anyArrayType, []ast.Parameter{required("arr"), optional("keyF")}),
"contains": g.newSimpleFuncType(boolType, "arr", "elem"),
// TODO these need test cases written by someone who understands how to make them
"all": g.newSimpleFuncType(boolArrayType, "arr"),
"any": g.newSimpleFuncType(boolArrayType, "arr"),
"remove": g.newSimpleFuncType(anyArrayType, "arr", "elem"),
"removeAt": g.newSimpleFuncType(anyArrayType, "arr", "i"),