Skip to content

Commit 31d71aa

Browse files
committed
Add missing linter metadata for stdlib.
Fixes google#483.
1 parent 6140a2f commit 31d71aa

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

linter/internal/types/stdlib.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,21 @@ func prepareStdlib(g *typeGraph) {
3131
"length": g.newSimpleFuncType(numberType, "x"),
3232
"objectHas": g.newSimpleFuncType(boolType, "o", "f"),
3333
"objectFields": g.newSimpleFuncType(arrayOfString, "o"),
34+
"objectValues": g.newSimpleFuncType(anyArrayType, "o"),
3435
"objectHasAll": g.newSimpleFuncType(boolType, "o", "f"),
3536
"objectFieldsAll": g.newSimpleFuncType(arrayOfString, "o"),
37+
"objectValuesAll": g.newSimpleFuncType(anyArrayType, "o"),
3638
"prune": g.newSimpleFuncType(anyObjectType, "a"),
3739
"mapWithKey": g.newSimpleFuncType(anyObjectType, "func", "obj"),
3840

41+
// isSomething
42+
"isArray": g.newSimpleFuncType(boolType, "v"),
43+
"isBoolean": g.newSimpleFuncType(boolType, "v"),
44+
"isFunction": g.newSimpleFuncType(boolType, "v"),
45+
"isNumber": g.newSimpleFuncType(boolType, "v"),
46+
"isObject": g.newSimpleFuncType(boolType, "v"),
47+
"isString": g.newSimpleFuncType(boolType, "v"),
48+
3949
// Mathematical utilities
4050
"abs": g.newSimpleFuncType(numberType, "n"),
4151
"sign": g.newSimpleFuncType(numberType, "n"),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!std.setMember([1, 2, 3], 1)

linter/testdata/stdlib_return_type_test.linter.golden

Whitespace-only changes.

testdata/stdlib_smoke_test.golden

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@
7878
4
7979
],
8080
"format": "test blah 42",
81+
"isArray": true,
82+
"isBoolean": true,
83+
"isFunction": true,
84+
"isNumber": true,
85+
"isObject": true,
86+
"isString": true,
8187
"join": "a,b,c",
8288
"length": 0,
8389
"lines": "a\nb\nc\n",
@@ -115,8 +121,11 @@
115121
"mergePatch": { },
116122
"min": 2,
117123
"objectFields": [ ],
124+
"objectFieldsAll": [ ],
118125
"objectHas": false,
119126
"objectHasAll": false,
127+
"objectValues": [ ],
128+
"objectValuesAll": [ ],
120129
"parseHex": 3735928559,
121130
"parseInt": 42,
122131
"parseJson": {

testdata/stdlib_smoke_test.jsonnet

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@
1515
length: std.length(x=[]),
1616
objectHas: std.objectHas(o={}, f="fieldname"),
1717
objectFields: std.objectFields(o={}),
18+
objectValues: std.objectValues(o={}),
1819
objectHasAll: std.objectHasAll(o={}, f="fieldname"),
20+
objectFieldsAll: std.objectFieldsAll(o={}),
21+
objectValuesAll: std.objectValuesAll(o={}),
1922
prune: std.prune(a={x: null, y: [null, "42"]}),
2023
mapWithKey: std.mapWithKey(func=function(key, value) 42, obj={a: 17}),
2124

25+
// isSomething
26+
isArray: std.isArray(v=[]),
27+
isBoolean: std.isBoolean(v=true),
28+
isFunction: std.isFunction(v=function() 42),
29+
isNumber: std.isNumber(v=42),
30+
isObject: std.isObject(v={}),
31+
isString: std.isString(v=""),
32+
2233
// Mathematical utilities
2334
abs: std.abs(n=-42),
2435
sign: std.sign(n=17),

0 commit comments

Comments
 (0)