Skip to content

Commit

Permalink
Adds std.any and std.all to jsonnet-lint (#695)
Browse files Browse the repository at this point in the history
Co-authored-by: Dave Cunningham <sparkprime@gmail.com>
  • Loading branch information
jregehr and sparkprime committed May 25, 2023
1 parent 7edd5d3 commit 44538a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions linter/internal/types/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions linter/internal/types/placeholder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
nullType
anyArrayType
numberArrayType
boolArrayType
anyObjectType
anyFunctionType
stdlibType
Expand Down
3 changes: 3 additions & 0 deletions linter/internal/types/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),

Expand Down

0 comments on commit 44538a3

Please sign in to comment.