Skip to content

Commit 734426b

Browse files
dreamorosiCopilot
andauthored
style(jmespath): apply stricter linting & improve docstrings (#4568)
Co-authored-by: Copilot <[email protected]>
1 parent 81ff3c4 commit 734426b

File tree

14 files changed

+197
-162
lines changed

14 files changed

+197
-162
lines changed

packages/jmespath/src/Expression.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ class Expression {
1616
/**
1717
* Evaluate the expression against a JSON value.
1818
*
19-
* @param value The JSON value to apply the expression to.
20-
* @param node The node to visit.
21-
* @returns The result of applying the expression to the value.
19+
* @param value - The JSON value to apply the expression to.
20+
* @param node - The node to visit.
2221
*/
2322
public visit(value: JSONObject, node?: Node): JSONObject {
2423
return this.#interpreter.visit(node ?? this.#expression, value);

packages/jmespath/src/Functions.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Functions {
5656
/**
5757
* Get the absolute value of the provided number.
5858
*
59-
* @param args The number to get the absolute value of
59+
* @param args - The number to get the absolute value of
6060
*/
6161
@Functions.signature({ argumentsSpecs: [['number']] })
6262
public funcAbs(args: number): number {
@@ -66,7 +66,7 @@ class Functions {
6666
/**
6767
* Calculate the average of the numbers in the provided array.
6868
*
69-
* @param args The numbers to average
69+
* @param args - The numbers to average
7070
*/
7171
@Functions.signature({
7272
argumentsSpecs: [['array-number']],
@@ -78,7 +78,7 @@ class Functions {
7878
/**
7979
* Get the ceiling of the provided number.
8080
*
81-
* @param args The number to get the ceiling of
81+
* @param args - The number to get the ceiling of
8282
*/
8383
@Functions.signature({ argumentsSpecs: [['number']] })
8484
public funcCeil(args: number): number {
@@ -88,8 +88,8 @@ class Functions {
8888
/**
8989
* Determine if the given value is contained in the provided array or string.
9090
*
91-
* @param haystack The array or string to check
92-
* @param needle The value to check for
91+
* @param haystack - The array or string to check
92+
* @param needle - The value to check for
9393
*/
9494
@Functions.signature({
9595
argumentsSpecs: [['array', 'string'], ['any']],
@@ -101,8 +101,8 @@ class Functions {
101101
/**
102102
* Determines if the provided string ends with the provided suffix.
103103
*
104-
* @param str The string to check
105-
* @param suffix The suffix to check for
104+
* @param str - The string to check
105+
* @param suffix - The suffix to check for
106106
*/
107107
@Functions.signature({
108108
argumentsSpecs: [['string'], ['string']],
@@ -114,7 +114,7 @@ class Functions {
114114
/**
115115
* Get the floor of the provided number.
116116
*
117-
* @param args The number to get the floor of
117+
* @param args - The number to get the floor of
118118
*/
119119
@Functions.signature({ argumentsSpecs: [['number']] })
120120
public funcFloor(args: number): number {
@@ -124,8 +124,8 @@ class Functions {
124124
/**
125125
* Join the provided array into a single string.
126126
*
127-
* @param separator The separator to use
128-
* @param items The array of itmes to join
127+
* @param separator - The separator to use
128+
* @param items - The array of itmes to join
129129
*/
130130
@Functions.signature({
131131
argumentsSpecs: [['string'], ['array-string']],
@@ -137,7 +137,7 @@ class Functions {
137137
/**
138138
* Get the keys of the provided object.
139139
*
140-
* @param arg The object to get the keys of
140+
* @param arg - The object to get the keys of
141141
*/
142142
@Functions.signature({
143143
argumentsSpecs: [['object']],
@@ -149,7 +149,7 @@ class Functions {
149149
/**
150150
* Get the number of items in the provided item.
151151
*
152-
* @param arg The array to get the length of
152+
* @param arg - The array to get the length of
153153
*/
154154
@Functions.signature({
155155
argumentsSpecs: [['array', 'string', 'object']],
@@ -166,8 +166,8 @@ class Functions {
166166
/**
167167
* Map the provided function over the provided array.
168168
*
169-
* @param expression The expression to map over the array
170-
* @param args The array to map the expression over
169+
* @param expression - The expression to map over the array
170+
* @param args - The array to map the expression over
171171
*/
172172
@Functions.signature({
173173
argumentsSpecs: [['any'], ['array']],
@@ -184,7 +184,7 @@ class Functions {
184184
/**
185185
* Get the maximum value in the provided array.
186186
*
187-
* @param arg The array to get the maximum value of
187+
* @param arg - The array to get the maximum value of
188188
*/
189189
@Functions.signature({
190190
argumentsSpecs: [['array-number', 'array-string']],
@@ -204,8 +204,8 @@ class Functions {
204204
/**
205205
* Get the item in the provided array that has the maximum value when the provided expression is evaluated.
206206
*
207-
* @param args The array of items to get the maximum value of
208-
* @param expression The expression to evaluate for each item in the array
207+
* @param args - The array of items to get the maximum value of
208+
* @param expression - The expression to evaluate for each item in the array
209209
*/
210210
@Functions.signature({
211211
argumentsSpecs: [['array'], ['expression']],
@@ -252,7 +252,7 @@ class Functions {
252252
*
253253
* Note that this is a shallow merge and will not merge nested objects.
254254
*
255-
* @param args The objects to merge
255+
* @param args - The objects to merge
256256
*/
257257
@Functions.signature({
258258
argumentsSpecs: [['object']],
@@ -266,7 +266,7 @@ class Functions {
266266
/**
267267
* Get the minimum value in the provided array.
268268
*
269-
* @param arg The array to get the minimum value of
269+
* @param arg - The array to get the minimum value of
270270
*/
271271
@Functions.signature({
272272
argumentsSpecs: [['array-number', 'array-string']],
@@ -285,8 +285,8 @@ class Functions {
285285
/**
286286
* Get the item in the provided array that has the minimum value when the provided expression is evaluated.
287287
*
288-
* @param args The array of items to get the minimum value of
289-
* @param expression The expression to evaluate for each item in the array
288+
* @param args - The array of items to get the minimum value of
289+
* @param expression - The expression to evaluate for each item in the array
290290
*/
291291
@Functions.signature({
292292
argumentsSpecs: [['array'], ['expression']],
@@ -332,7 +332,7 @@ class Functions {
332332
* Get the first argument that does not evaluate to null.
333333
* If all arguments evaluate to null, then null is returned.
334334
*
335-
* @param args The keys of the items to check
335+
* @param args - The keys of the items to check
336336
*/
337337
@Functions.signature({
338338
argumentsSpecs: [[]],
@@ -345,7 +345,7 @@ class Functions {
345345
/**
346346
* Reverses the provided string or array.
347347
*
348-
* @param arg The string or array to reverse
348+
* @param arg - The string or array to reverse
349349
*/
350350
@Functions.signature({
351351
argumentsSpecs: [['string', 'array']],
@@ -359,7 +359,7 @@ class Functions {
359359
/**
360360
* Sort the provided array.
361361
*
362-
* @param arg The array to sort
362+
* @param arg - The array to sort
363363
*/
364364
@Functions.signature({
365365
argumentsSpecs: [['array-number', 'array-string']],
@@ -382,8 +382,8 @@ class Functions {
382382
/**
383383
* Sort the provided array by the provided expression.
384384
*
385-
* @param args The array to sort
386-
* @param expression The expression to sort by
385+
* @param args - The array to sort
386+
* @param expression - The expression to sort by
387387
*/
388388
@Functions.signature({
389389
argumentsSpecs: [['array'], ['expression']],
@@ -426,8 +426,8 @@ class Functions {
426426
/**
427427
* Determines if the provided string starts with the provided prefix.
428428
*
429-
* @param str The string to check
430-
* @param prefix The prefix to check for
429+
* @param str - The string to check
430+
* @param prefix - The prefix to check for
431431
*/
432432
@Functions.signature({
433433
argumentsSpecs: [['string'], ['string']],
@@ -439,7 +439,7 @@ class Functions {
439439
/**
440440
* Sum the provided numbers.
441441
*
442-
* @param args The numbers to sum
442+
* @param args - The numbers to sum
443443
*/
444444
@Functions.signature({
445445
argumentsSpecs: [['array-number']],
@@ -454,7 +454,7 @@ class Functions {
454454
* If the provided value is an array, then it is returned.
455455
* Otherwise, the value is wrapped in an array and returned.
456456
*
457-
* @param arg The items to convert to an array
457+
* @param arg - The items to convert to an array
458458
*/
459459
@Functions.signature({
460460
argumentsSpecs: [['any']],
@@ -473,7 +473,7 @@ class Functions {
473473
*
474474
* If the value cannot be converted to a number, then null is returned.
475475
*
476-
* @param arg The value to convert to a number
476+
* @param arg - The value to convert to a number
477477
*/
478478
@Functions.signature({
479479
argumentsSpecs: [['any']],
@@ -496,7 +496,7 @@ class Functions {
496496
* If the provided value is a string, then it is returned.
497497
* Otherwise, the value is converted to a string and returned.
498498
*
499-
* @param arg The value to convert to a string
499+
* @param arg - The value to convert to a string
500500
*/
501501
@Functions.signature({
502502
argumentsSpecs: [['any']],
@@ -508,7 +508,7 @@ class Functions {
508508
/**
509509
* Get the type of the provided value.
510510
*
511-
* @param arg The value to check the type of
511+
* @param arg - The value to check the type of
512512
*/
513513
@Functions.signature({
514514
argumentsSpecs: [['any']],
@@ -520,7 +520,7 @@ class Functions {
520520
/**
521521
* Get the values of the provided object.
522522
*
523-
* @param arg The object to get the values of
523+
* @param arg - The object to get the values of
524524
*/
525525
@Functions.signature({
526526
argumentsSpecs: [['object']],
@@ -544,7 +544,7 @@ class Functions {
544544
* to the `methods` set. Finally, when the recursion collects back to the current instance,
545545
* it adds the collected methods to the `this.methods` set so that they can be accessed later.
546546
*
547-
* @param scope The scope of the class instance to introspect
547+
* @param scope - The scope of the class instance to introspect
548548
*/
549549
public introspectMethods(scope?: Functions): Set<string> {
550550
const prototype = Object.getPrototypeOf(this);
@@ -598,7 +598,7 @@ class Functions {
598598
* }
599599
* ```
600600
*
601-
* @param options The options for the signature decorator
601+
* @param options - The options for the signature decorator
602602
*/
603603
public static signature(
604604
options: FunctionSignatureOptions

packages/jmespath/src/Lexer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Lexer {
5555
const buff = this.#consumeNumber();
5656
yield {
5757
type: 'number',
58-
value: Number.parseInt(buff),
58+
value: Number.parseInt(buff, 10),
5959
start: start,
6060
end: start + buff.length,
6161
};
@@ -155,7 +155,7 @@ class Lexer {
155155
if (buff.length > 1) {
156156
return {
157157
type: 'number',
158-
value: Number.parseInt(buff),
158+
value: Number.parseInt(buff, 10),
159159
start: start,
160160
end: start + buff.length,
161161
};

packages/jmespath/src/ParsedResult.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class ParsedResult {
1919
/**
2020
* Perform a JMESPath search on a JSON value.
2121
*
22-
* @param value The JSON value to search
23-
* @param options The parsing options to use
22+
* @param value - The JSON value to search
23+
* @param options - The parsing options to use
2424
*/
2525
public search(value: JSONObject, options?: JMESPathParsingOptions): unknown {
2626
const interpreter = new TreeInterpreter(options);

0 commit comments

Comments
 (0)