nanos-lint 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,6 +31,754 @@ function fileUriToPath(uri) {
31
31
  }
32
32
  }
33
33
  //#endregion
34
+ //#region node_modules/jsonc-parser/lib/esm/impl/scanner.js
35
+ /**
36
+ * Creates a JSON scanner on the given text.
37
+ * If ignoreTrivia is set, whitespaces or comments are ignored.
38
+ */
39
+ function createScanner(text, ignoreTrivia = false) {
40
+ const len = text.length;
41
+ let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
42
+ function scanHexDigits(count, exact) {
43
+ let digits = 0;
44
+ let value = 0;
45
+ while (digits < count || !exact) {
46
+ let ch = text.charCodeAt(pos);
47
+ if (ch >= 48 && ch <= 57) value = value * 16 + ch - 48;
48
+ else if (ch >= 65 && ch <= 70) value = value * 16 + ch - 65 + 10;
49
+ else if (ch >= 97 && ch <= 102) value = value * 16 + ch - 97 + 10;
50
+ else break;
51
+ pos++;
52
+ digits++;
53
+ }
54
+ if (digits < count) value = -1;
55
+ return value;
56
+ }
57
+ function setPosition(newPosition) {
58
+ pos = newPosition;
59
+ value = "";
60
+ tokenOffset = 0;
61
+ token = 16;
62
+ scanError = 0;
63
+ }
64
+ function scanNumber() {
65
+ let start = pos;
66
+ if (text.charCodeAt(pos) === 48) pos++;
67
+ else {
68
+ pos++;
69
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
70
+ }
71
+ if (pos < text.length && text.charCodeAt(pos) === 46) {
72
+ pos++;
73
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
74
+ pos++;
75
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
76
+ } else {
77
+ scanError = 3;
78
+ return text.substring(start, pos);
79
+ }
80
+ }
81
+ let end = pos;
82
+ if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
83
+ pos++;
84
+ if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) pos++;
85
+ if (pos < text.length && isDigit(text.charCodeAt(pos))) {
86
+ pos++;
87
+ while (pos < text.length && isDigit(text.charCodeAt(pos))) pos++;
88
+ end = pos;
89
+ } else scanError = 3;
90
+ }
91
+ return text.substring(start, end);
92
+ }
93
+ function scanString() {
94
+ let result = "", start = pos;
95
+ while (true) {
96
+ if (pos >= len) {
97
+ result += text.substring(start, pos);
98
+ scanError = 2;
99
+ break;
100
+ }
101
+ const ch = text.charCodeAt(pos);
102
+ if (ch === 34) {
103
+ result += text.substring(start, pos);
104
+ pos++;
105
+ break;
106
+ }
107
+ if (ch === 92) {
108
+ result += text.substring(start, pos);
109
+ pos++;
110
+ if (pos >= len) {
111
+ scanError = 2;
112
+ break;
113
+ }
114
+ switch (text.charCodeAt(pos++)) {
115
+ case 34:
116
+ result += "\"";
117
+ break;
118
+ case 92:
119
+ result += "\\";
120
+ break;
121
+ case 47:
122
+ result += "/";
123
+ break;
124
+ case 98:
125
+ result += "\b";
126
+ break;
127
+ case 102:
128
+ result += "\f";
129
+ break;
130
+ case 110:
131
+ result += "\n";
132
+ break;
133
+ case 114:
134
+ result += "\r";
135
+ break;
136
+ case 116:
137
+ result += " ";
138
+ break;
139
+ case 117:
140
+ const ch3 = scanHexDigits(4, true);
141
+ if (ch3 >= 0) result += String.fromCharCode(ch3);
142
+ else scanError = 4;
143
+ break;
144
+ default: scanError = 5;
145
+ }
146
+ start = pos;
147
+ continue;
148
+ }
149
+ if (ch >= 0 && ch <= 31) {
150
+ if (isLineBreak(ch)) {
151
+ result += text.substring(start, pos);
152
+ scanError = 2;
153
+ break;
154
+ } else scanError = 6;
155
+ }
156
+ pos++;
157
+ }
158
+ return result;
159
+ }
160
+ function scanNext() {
161
+ value = "";
162
+ scanError = 0;
163
+ tokenOffset = pos;
164
+ lineStartOffset = lineNumber;
165
+ prevTokenLineStartOffset = tokenLineStartOffset;
166
+ if (pos >= len) {
167
+ tokenOffset = len;
168
+ return token = 17;
169
+ }
170
+ let code = text.charCodeAt(pos);
171
+ if (isWhiteSpace(code)) {
172
+ do {
173
+ pos++;
174
+ value += String.fromCharCode(code);
175
+ code = text.charCodeAt(pos);
176
+ } while (isWhiteSpace(code));
177
+ return token = 15;
178
+ }
179
+ if (isLineBreak(code)) {
180
+ pos++;
181
+ value += String.fromCharCode(code);
182
+ if (code === 13 && text.charCodeAt(pos) === 10) {
183
+ pos++;
184
+ value += "\n";
185
+ }
186
+ lineNumber++;
187
+ tokenLineStartOffset = pos;
188
+ return token = 14;
189
+ }
190
+ switch (code) {
191
+ case 123:
192
+ pos++;
193
+ return token = 1;
194
+ case 125:
195
+ pos++;
196
+ return token = 2;
197
+ case 91:
198
+ pos++;
199
+ return token = 3;
200
+ case 93:
201
+ pos++;
202
+ return token = 4;
203
+ case 58:
204
+ pos++;
205
+ return token = 6;
206
+ case 44:
207
+ pos++;
208
+ return token = 5;
209
+ case 34:
210
+ pos++;
211
+ value = scanString();
212
+ return token = 10;
213
+ case 47:
214
+ const start = pos - 1;
215
+ if (text.charCodeAt(pos + 1) === 47) {
216
+ pos += 2;
217
+ while (pos < len) {
218
+ if (isLineBreak(text.charCodeAt(pos))) break;
219
+ pos++;
220
+ }
221
+ value = text.substring(start, pos);
222
+ return token = 12;
223
+ }
224
+ if (text.charCodeAt(pos + 1) === 42) {
225
+ pos += 2;
226
+ const safeLength = len - 1;
227
+ let commentClosed = false;
228
+ while (pos < safeLength) {
229
+ const ch = text.charCodeAt(pos);
230
+ if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
231
+ pos += 2;
232
+ commentClosed = true;
233
+ break;
234
+ }
235
+ pos++;
236
+ if (isLineBreak(ch)) {
237
+ if (ch === 13 && text.charCodeAt(pos) === 10) pos++;
238
+ lineNumber++;
239
+ tokenLineStartOffset = pos;
240
+ }
241
+ }
242
+ if (!commentClosed) {
243
+ pos++;
244
+ scanError = 1;
245
+ }
246
+ value = text.substring(start, pos);
247
+ return token = 13;
248
+ }
249
+ value += String.fromCharCode(code);
250
+ pos++;
251
+ return token = 16;
252
+ case 45:
253
+ value += String.fromCharCode(code);
254
+ pos++;
255
+ if (pos === len || !isDigit(text.charCodeAt(pos))) return token = 16;
256
+ case 48:
257
+ case 49:
258
+ case 50:
259
+ case 51:
260
+ case 52:
261
+ case 53:
262
+ case 54:
263
+ case 55:
264
+ case 56:
265
+ case 57:
266
+ value += scanNumber();
267
+ return token = 11;
268
+ default:
269
+ while (pos < len && isUnknownContentCharacter(code)) {
270
+ pos++;
271
+ code = text.charCodeAt(pos);
272
+ }
273
+ if (tokenOffset !== pos) {
274
+ value = text.substring(tokenOffset, pos);
275
+ switch (value) {
276
+ case "true": return token = 8;
277
+ case "false": return token = 9;
278
+ case "null": return token = 7;
279
+ }
280
+ return token = 16;
281
+ }
282
+ value += String.fromCharCode(code);
283
+ pos++;
284
+ return token = 16;
285
+ }
286
+ }
287
+ function isUnknownContentCharacter(code) {
288
+ if (isWhiteSpace(code) || isLineBreak(code)) return false;
289
+ switch (code) {
290
+ case 125:
291
+ case 93:
292
+ case 123:
293
+ case 91:
294
+ case 34:
295
+ case 58:
296
+ case 44:
297
+ case 47: return false;
298
+ }
299
+ return true;
300
+ }
301
+ function scanNextNonTrivia() {
302
+ let result;
303
+ do
304
+ result = scanNext();
305
+ while (result >= 12 && result <= 15);
306
+ return result;
307
+ }
308
+ return {
309
+ setPosition,
310
+ getPosition: () => pos,
311
+ scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
312
+ getToken: () => token,
313
+ getTokenValue: () => value,
314
+ getTokenOffset: () => tokenOffset,
315
+ getTokenLength: () => pos - tokenOffset,
316
+ getTokenStartLine: () => lineStartOffset,
317
+ getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
318
+ getTokenError: () => scanError
319
+ };
320
+ }
321
+ function isWhiteSpace(ch) {
322
+ return ch === 32 || ch === 9;
323
+ }
324
+ function isLineBreak(ch) {
325
+ return ch === 10 || ch === 13;
326
+ }
327
+ function isDigit(ch) {
328
+ return ch >= 48 && ch <= 57;
329
+ }
330
+ var CharacterCodes;
331
+ (function(CharacterCodes) {
332
+ CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
333
+ CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
334
+ CharacterCodes[CharacterCodes["space"] = 32] = "space";
335
+ CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
336
+ CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
337
+ CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
338
+ CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
339
+ CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
340
+ CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
341
+ CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
342
+ CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
343
+ CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
344
+ CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
345
+ CharacterCodes[CharacterCodes["a"] = 97] = "a";
346
+ CharacterCodes[CharacterCodes["b"] = 98] = "b";
347
+ CharacterCodes[CharacterCodes["c"] = 99] = "c";
348
+ CharacterCodes[CharacterCodes["d"] = 100] = "d";
349
+ CharacterCodes[CharacterCodes["e"] = 101] = "e";
350
+ CharacterCodes[CharacterCodes["f"] = 102] = "f";
351
+ CharacterCodes[CharacterCodes["g"] = 103] = "g";
352
+ CharacterCodes[CharacterCodes["h"] = 104] = "h";
353
+ CharacterCodes[CharacterCodes["i"] = 105] = "i";
354
+ CharacterCodes[CharacterCodes["j"] = 106] = "j";
355
+ CharacterCodes[CharacterCodes["k"] = 107] = "k";
356
+ CharacterCodes[CharacterCodes["l"] = 108] = "l";
357
+ CharacterCodes[CharacterCodes["m"] = 109] = "m";
358
+ CharacterCodes[CharacterCodes["n"] = 110] = "n";
359
+ CharacterCodes[CharacterCodes["o"] = 111] = "o";
360
+ CharacterCodes[CharacterCodes["p"] = 112] = "p";
361
+ CharacterCodes[CharacterCodes["q"] = 113] = "q";
362
+ CharacterCodes[CharacterCodes["r"] = 114] = "r";
363
+ CharacterCodes[CharacterCodes["s"] = 115] = "s";
364
+ CharacterCodes[CharacterCodes["t"] = 116] = "t";
365
+ CharacterCodes[CharacterCodes["u"] = 117] = "u";
366
+ CharacterCodes[CharacterCodes["v"] = 118] = "v";
367
+ CharacterCodes[CharacterCodes["w"] = 119] = "w";
368
+ CharacterCodes[CharacterCodes["x"] = 120] = "x";
369
+ CharacterCodes[CharacterCodes["y"] = 121] = "y";
370
+ CharacterCodes[CharacterCodes["z"] = 122] = "z";
371
+ CharacterCodes[CharacterCodes["A"] = 65] = "A";
372
+ CharacterCodes[CharacterCodes["B"] = 66] = "B";
373
+ CharacterCodes[CharacterCodes["C"] = 67] = "C";
374
+ CharacterCodes[CharacterCodes["D"] = 68] = "D";
375
+ CharacterCodes[CharacterCodes["E"] = 69] = "E";
376
+ CharacterCodes[CharacterCodes["F"] = 70] = "F";
377
+ CharacterCodes[CharacterCodes["G"] = 71] = "G";
378
+ CharacterCodes[CharacterCodes["H"] = 72] = "H";
379
+ CharacterCodes[CharacterCodes["I"] = 73] = "I";
380
+ CharacterCodes[CharacterCodes["J"] = 74] = "J";
381
+ CharacterCodes[CharacterCodes["K"] = 75] = "K";
382
+ CharacterCodes[CharacterCodes["L"] = 76] = "L";
383
+ CharacterCodes[CharacterCodes["M"] = 77] = "M";
384
+ CharacterCodes[CharacterCodes["N"] = 78] = "N";
385
+ CharacterCodes[CharacterCodes["O"] = 79] = "O";
386
+ CharacterCodes[CharacterCodes["P"] = 80] = "P";
387
+ CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
388
+ CharacterCodes[CharacterCodes["R"] = 82] = "R";
389
+ CharacterCodes[CharacterCodes["S"] = 83] = "S";
390
+ CharacterCodes[CharacterCodes["T"] = 84] = "T";
391
+ CharacterCodes[CharacterCodes["U"] = 85] = "U";
392
+ CharacterCodes[CharacterCodes["V"] = 86] = "V";
393
+ CharacterCodes[CharacterCodes["W"] = 87] = "W";
394
+ CharacterCodes[CharacterCodes["X"] = 88] = "X";
395
+ CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
396
+ CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
397
+ CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
398
+ CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
399
+ CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
400
+ CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
401
+ CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
402
+ CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
403
+ CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
404
+ CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
405
+ CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
406
+ CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
407
+ CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
408
+ CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
409
+ CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
410
+ CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
411
+ CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
412
+ })(CharacterCodes || (CharacterCodes = {}));
413
+ new Array(20).fill(0).map((_, index) => {
414
+ return " ".repeat(index);
415
+ });
416
+ const maxCachedValues = 200;
417
+ new Array(maxCachedValues).fill(0).map((_, index) => {
418
+ return "\n" + " ".repeat(index);
419
+ }), new Array(maxCachedValues).fill(0).map((_, index) => {
420
+ return "\r" + " ".repeat(index);
421
+ }), new Array(maxCachedValues).fill(0).map((_, index) => {
422
+ return "\r\n" + " ".repeat(index);
423
+ }), new Array(maxCachedValues).fill(0).map((_, index) => {
424
+ return "\n" + " ".repeat(index);
425
+ }), new Array(maxCachedValues).fill(0).map((_, index) => {
426
+ return "\r" + " ".repeat(index);
427
+ }), new Array(maxCachedValues).fill(0).map((_, index) => {
428
+ return "\r\n" + " ".repeat(index);
429
+ });
430
+ //#endregion
431
+ //#region node_modules/jsonc-parser/lib/esm/impl/parser.js
432
+ var ParseOptions;
433
+ (function(ParseOptions) {
434
+ ParseOptions.DEFAULT = { allowTrailingComma: false };
435
+ })(ParseOptions || (ParseOptions = {}));
436
+ /**
437
+ * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
438
+ * Therefore always check the errors list to find out if the input was valid.
439
+ */
440
+ function parse$1(text, errors = [], options = ParseOptions.DEFAULT) {
441
+ let currentProperty = null;
442
+ let currentParent = [];
443
+ const previousParents = [];
444
+ function onValue(value) {
445
+ if (Array.isArray(currentParent)) currentParent.push(value);
446
+ else if (currentProperty !== null) currentParent[currentProperty] = value;
447
+ }
448
+ visit(text, {
449
+ onObjectBegin: () => {
450
+ const object = {};
451
+ onValue(object);
452
+ previousParents.push(currentParent);
453
+ currentParent = object;
454
+ currentProperty = null;
455
+ },
456
+ onObjectProperty: (name) => {
457
+ currentProperty = name;
458
+ },
459
+ onObjectEnd: () => {
460
+ currentParent = previousParents.pop();
461
+ },
462
+ onArrayBegin: () => {
463
+ const array = [];
464
+ onValue(array);
465
+ previousParents.push(currentParent);
466
+ currentParent = array;
467
+ currentProperty = null;
468
+ },
469
+ onArrayEnd: () => {
470
+ currentParent = previousParents.pop();
471
+ },
472
+ onLiteralValue: onValue,
473
+ onError: (error, offset, length) => {
474
+ errors.push({
475
+ error,
476
+ offset,
477
+ length
478
+ });
479
+ }
480
+ }, options);
481
+ return currentParent[0];
482
+ }
483
+ /**
484
+ * Parses the given text and invokes the visitor functions for each object, array and literal reached.
485
+ */
486
+ function visit(text, visitor, options = ParseOptions.DEFAULT) {
487
+ const _scanner = createScanner(text, false);
488
+ const _jsonPath = [];
489
+ let suppressedCallbacks = 0;
490
+ function toNoArgVisit(visitFunction) {
491
+ return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
492
+ }
493
+ function toOneArgVisit(visitFunction) {
494
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
495
+ }
496
+ function toOneArgVisitWithPath(visitFunction) {
497
+ return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
498
+ }
499
+ function toBeginVisit(visitFunction) {
500
+ return visitFunction ? () => {
501
+ if (suppressedCallbacks > 0) suppressedCallbacks++;
502
+ else if (visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) === false) suppressedCallbacks = 1;
503
+ } : () => true;
504
+ }
505
+ function toEndVisit(visitFunction) {
506
+ return visitFunction ? () => {
507
+ if (suppressedCallbacks > 0) suppressedCallbacks--;
508
+ if (suppressedCallbacks === 0) visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
509
+ } : () => true;
510
+ }
511
+ const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
512
+ const disallowComments = options && options.disallowComments;
513
+ const allowTrailingComma = options && options.allowTrailingComma;
514
+ function scanNext() {
515
+ while (true) {
516
+ const token = _scanner.scan();
517
+ switch (_scanner.getTokenError()) {
518
+ case 4:
519
+ handleError(14);
520
+ break;
521
+ case 5:
522
+ handleError(15);
523
+ break;
524
+ case 3:
525
+ handleError(13);
526
+ break;
527
+ case 1:
528
+ if (!disallowComments) handleError(11);
529
+ break;
530
+ case 2:
531
+ handleError(12);
532
+ break;
533
+ case 6: handleError(16);
534
+ }
535
+ switch (token) {
536
+ case 12:
537
+ case 13:
538
+ if (disallowComments) handleError(10);
539
+ else onComment();
540
+ break;
541
+ case 16:
542
+ handleError(1);
543
+ break;
544
+ case 15:
545
+ case 14: break;
546
+ default: return token;
547
+ }
548
+ }
549
+ }
550
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
551
+ onError(error);
552
+ if (skipUntilAfter.length + skipUntil.length > 0) {
553
+ let token = _scanner.getToken();
554
+ while (token !== 17) {
555
+ if (skipUntilAfter.indexOf(token) !== -1) {
556
+ scanNext();
557
+ break;
558
+ } else if (skipUntil.indexOf(token) !== -1) break;
559
+ token = scanNext();
560
+ }
561
+ }
562
+ }
563
+ function parseString(isValue) {
564
+ const value = _scanner.getTokenValue();
565
+ if (isValue) onLiteralValue(value);
566
+ else {
567
+ onObjectProperty(value);
568
+ _jsonPath.push(value);
569
+ }
570
+ scanNext();
571
+ return true;
572
+ }
573
+ function parseLiteral() {
574
+ switch (_scanner.getToken()) {
575
+ case 11:
576
+ const tokenValue = _scanner.getTokenValue();
577
+ let value = Number(tokenValue);
578
+ if (isNaN(value)) {
579
+ handleError(2);
580
+ value = 0;
581
+ }
582
+ onLiteralValue(value);
583
+ break;
584
+ case 7:
585
+ onLiteralValue(null);
586
+ break;
587
+ case 8:
588
+ onLiteralValue(true);
589
+ break;
590
+ case 9:
591
+ onLiteralValue(false);
592
+ break;
593
+ default: return false;
594
+ }
595
+ scanNext();
596
+ return true;
597
+ }
598
+ function parseProperty() {
599
+ if (_scanner.getToken() !== 10) {
600
+ handleError(3, [], [2, 5]);
601
+ return false;
602
+ }
603
+ parseString(false);
604
+ if (_scanner.getToken() === 6) {
605
+ onSeparator(":");
606
+ scanNext();
607
+ if (!parseValue()) handleError(4, [], [2, 5]);
608
+ } else handleError(5, [], [2, 5]);
609
+ _jsonPath.pop();
610
+ return true;
611
+ }
612
+ function parseObject() {
613
+ onObjectBegin();
614
+ scanNext();
615
+ let needsComma = false;
616
+ while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
617
+ if (_scanner.getToken() === 5) {
618
+ if (!needsComma) handleError(4, [], []);
619
+ onSeparator(",");
620
+ scanNext();
621
+ if (_scanner.getToken() === 2 && allowTrailingComma) break;
622
+ } else if (needsComma) handleError(6, [], []);
623
+ if (!parseProperty()) handleError(4, [], [2, 5]);
624
+ needsComma = true;
625
+ }
626
+ onObjectEnd();
627
+ if (_scanner.getToken() !== 2) handleError(7, [2], []);
628
+ else scanNext();
629
+ return true;
630
+ }
631
+ function parseArray() {
632
+ onArrayBegin();
633
+ scanNext();
634
+ let isFirstElement = true;
635
+ let needsComma = false;
636
+ while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
637
+ if (_scanner.getToken() === 5) {
638
+ if (!needsComma) handleError(4, [], []);
639
+ onSeparator(",");
640
+ scanNext();
641
+ if (_scanner.getToken() === 4 && allowTrailingComma) break;
642
+ } else if (needsComma) handleError(6, [], []);
643
+ if (isFirstElement) {
644
+ _jsonPath.push(0);
645
+ isFirstElement = false;
646
+ } else _jsonPath[_jsonPath.length - 1]++;
647
+ if (!parseValue()) handleError(4, [], [4, 5]);
648
+ needsComma = true;
649
+ }
650
+ onArrayEnd();
651
+ if (!isFirstElement) _jsonPath.pop();
652
+ if (_scanner.getToken() !== 4) handleError(8, [4], []);
653
+ else scanNext();
654
+ return true;
655
+ }
656
+ function parseValue() {
657
+ switch (_scanner.getToken()) {
658
+ case 3: return parseArray();
659
+ case 1: return parseObject();
660
+ case 10: return parseString(true);
661
+ default: return parseLiteral();
662
+ }
663
+ }
664
+ scanNext();
665
+ if (_scanner.getToken() === 17) {
666
+ if (options.allowEmptyContent) return true;
667
+ handleError(4, [], []);
668
+ return false;
669
+ }
670
+ if (!parseValue()) {
671
+ handleError(4, [], []);
672
+ return false;
673
+ }
674
+ if (_scanner.getToken() !== 17) handleError(9, [], []);
675
+ return true;
676
+ }
677
+ /**
678
+ * Takes JSON with JavaScript-style comments and remove
679
+ * them. Optionally replaces every none-newline character
680
+ * of comments with a replaceCharacter
681
+ */
682
+ function stripComments$1(text, replaceCh) {
683
+ let _scanner = createScanner(text), parts = [], kind, offset = 0, pos;
684
+ do {
685
+ pos = _scanner.getPosition();
686
+ kind = _scanner.scan();
687
+ switch (kind) {
688
+ case 12:
689
+ case 13:
690
+ case 17:
691
+ if (offset !== pos) parts.push(text.substring(offset, pos));
692
+ if (replaceCh !== void 0) parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
693
+ offset = _scanner.getPosition();
694
+ }
695
+ } while (kind !== 17);
696
+ return parts.join("");
697
+ }
698
+ //#endregion
699
+ //#region node_modules/jsonc-parser/lib/esm/main.js
700
+ var ScanError;
701
+ (function(ScanError) {
702
+ ScanError[ScanError["None"] = 0] = "None";
703
+ ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
704
+ ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
705
+ ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
706
+ ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
707
+ ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
708
+ ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
709
+ })(ScanError || (ScanError = {}));
710
+ var SyntaxKind;
711
+ (function(SyntaxKind) {
712
+ SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
713
+ SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
714
+ SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
715
+ SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
716
+ SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
717
+ SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
718
+ SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
719
+ SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
720
+ SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
721
+ SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
722
+ SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
723
+ SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
724
+ SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
725
+ SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
726
+ SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
727
+ SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
728
+ SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
729
+ })(SyntaxKind || (SyntaxKind = {}));
730
+ /**
731
+ * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
732
+ * Therefore, always check the errors list to find out if the input was valid.
733
+ */
734
+ const parse = parse$1;
735
+ /**
736
+ * Takes JSON with JavaScript-style comments and remove
737
+ * them. Optionally replaces every none-newline character
738
+ * of comments with a replaceCharacter
739
+ */
740
+ const stripComments = stripComments$1;
741
+ var ParseErrorCode;
742
+ (function(ParseErrorCode) {
743
+ ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
744
+ ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
745
+ ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
746
+ ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
747
+ ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
748
+ ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
749
+ ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
750
+ ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
751
+ ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
752
+ ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
753
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
754
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
755
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
756
+ ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
757
+ ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
758
+ ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
759
+ })(ParseErrorCode || (ParseErrorCode = {}));
760
+ function printParseErrorCode(code) {
761
+ switch (code) {
762
+ case 1: return "InvalidSymbol";
763
+ case 2: return "InvalidNumberFormat";
764
+ case 3: return "PropertyNameExpected";
765
+ case 4: return "ValueExpected";
766
+ case 5: return "ColonExpected";
767
+ case 6: return "CommaExpected";
768
+ case 7: return "CloseBraceExpected";
769
+ case 8: return "CloseBracketExpected";
770
+ case 9: return "EndOfFileExpected";
771
+ case 10: return "InvalidCommentToken";
772
+ case 11: return "UnexpectedEndOfComment";
773
+ case 12: return "UnexpectedEndOfString";
774
+ case 13: return "UnexpectedEndOfNumber";
775
+ case 14: return "InvalidUnicode";
776
+ case 15: return "InvalidEscapeCharacter";
777
+ case 16: return "InvalidCharacter";
778
+ }
779
+ return "<unknown ParseErrorCode>";
780
+ }
781
+ //#endregion
34
782
  //#region src/config.ts
35
783
  const __filename = fileURLToPath(import.meta.url);
36
784
  const __dirname = path.dirname(__filename);
@@ -54,85 +802,40 @@ function getDefaultTemplatePath() {
54
802
  return path.join(root, "templates", ".luarc.json");
55
803
  }
56
804
  /**
57
- * Strips single-line comments (//), multi-line comments (/* ... *\/),
58
- * and trailing commas before '}' or ']' from JSONC text while preserving string literals.
805
+ * Strips single-line and multi-line comments from JSONC text using jsonc-parser.
59
806
  */
60
807
  function stripJsonComments(text) {
61
808
  const cleanText = text.replace(/^\uFEFF/, "");
62
- let result = "";
63
- let i = 0;
64
- const len = cleanText.length;
65
- while (i < len) {
66
- const ch = cleanText[i];
67
- if (ch === "\"") {
68
- result += ch;
69
- i++;
70
- while (i < len) {
71
- const c = cleanText[i];
72
- result += c;
73
- if (c === "\\") {
74
- i++;
75
- if (i < len) result += cleanText[i];
76
- } else if (c === "\"") break;
77
- i++;
78
- }
79
- i++;
80
- continue;
81
- }
82
- if (ch === "/" && i + 1 < len && cleanText[i + 1] === "/") {
83
- i += 2;
84
- while (i < len && cleanText[i] !== "\n" && cleanText[i] !== "\r") i++;
85
- continue;
86
- }
87
- if (ch === "/" && i + 1 < len && cleanText[i + 1] === "*") {
88
- i += 2;
89
- while (i + 1 < len && !(cleanText[i] === "*" && cleanText[i + 1] === "/")) i++;
90
- i += 2;
91
- continue;
92
- }
93
- if (ch === ",") {
94
- let j = i + 1;
95
- let isTrailing = false;
96
- while (j < len) {
97
- const nextChar = cleanText[j];
98
- if (nextChar === " " || nextChar === " " || nextChar === "\n" || nextChar === "\r") {
99
- j++;
100
- continue;
101
- }
102
- if (nextChar === "/" && j + 1 < len && cleanText[j + 1] === "/") {
103
- j += 2;
104
- while (j < len && cleanText[j] !== "\n" && cleanText[j] !== "\r") j++;
105
- continue;
106
- }
107
- if (nextChar === "/" && j + 1 < len && cleanText[j + 1] === "*") {
108
- j += 2;
109
- while (j + 1 < len && !(cleanText[j] === "*" && cleanText[j + 1] === "/")) j++;
110
- j += 2;
111
- continue;
112
- }
113
- if (nextChar === "}" || nextChar === "]") isTrailing = true;
114
- break;
115
- }
116
- if (isTrailing) {
117
- result += " ";
118
- i++;
119
- continue;
120
- }
121
- }
122
- result += ch;
123
- i++;
124
- }
125
- return result;
809
+ return stripComments(cleanText);
126
810
  }
127
811
  function parseJsonc(text) {
128
- const stripped = stripJsonComments(text);
129
- return JSON.parse(stripped);
812
+ const cleanText = text.replace(/^\uFEFF/, "");
813
+ const errors = [];
814
+ const result = parse(cleanText, errors, { allowTrailingComma: true });
815
+ if (errors.length > 0) {
816
+ const errorDetails = errors.map((e) => `${printParseErrorCode(e.error)} at offset ${e.offset}`).join(", ");
817
+ throw new SyntaxError(`Invalid JSONC: ${errorDetails}`);
818
+ }
819
+ return result;
130
820
  }
131
821
  function loadConfigFile(filePath) {
132
822
  if (!fs.existsSync(filePath)) throw new Error(`Configuration file not found: ${filePath}`);
133
823
  return parseJsonc(fs.readFileSync(filePath, "utf-8"));
134
824
  }
135
825
  /**
826
+ * Removes trailing `/` characters from a path-like string.
827
+ *
828
+ * Implemented with a scan instead of a `\/+$` regular expression: on inputs made
829
+ * of many slashes that do not end in a slash, a backtracking engine retries the
830
+ * repetition at every offset, which is quadratic in the input length
831
+ * (CodeQL: js/polynomial-redos).
832
+ */
833
+ function stripTrailingSlashes(value) {
834
+ let end = value.length;
835
+ while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
836
+ return end === value.length ? value : value.slice(0, end);
837
+ }
838
+ /**
136
839
  * Merges a base nanos configuration with a workspace override configuration.
137
840
  * Guarantees that the nanos definitions directory is included in workspace.library,
138
841
  * and standardizes paths for LuaLS.
@@ -179,12 +882,12 @@ function mergeConfigs(base, override = {}, definitionsDir = getDefinitionsDir(),
179
882
  for (const pat of normalizedCliIgnore) {
180
883
  excludePatterns.add(pat);
181
884
  if (!pat.includes("*") && !pat.includes("?") && !pat.endsWith(".lua")) {
182
- const dirPat = pat.replace(/\/+$/, "");
885
+ const dirPat = stripTrailingSlashes(pat);
183
886
  excludePatterns.add(`${dirPat}/**`);
184
887
  }
185
888
  }
186
889
  mergedFilesExclude = Array.from(excludePatterns);
187
- const cliDirs = normalizedCliIgnore.filter((p) => !p.includes("*") && !p.includes("?") && !p.endsWith(".lua")).map((p) => p.replace(/\/+$/, ""));
890
+ const cliDirs = normalizedCliIgnore.filter((p) => !p.includes("*") && !p.includes("?") && !p.endsWith(".lua")).map((p) => stripTrailingSlashes(p));
188
891
  mergedIgnoreDir = Array.from(/* @__PURE__ */ new Set([
189
892
  ...defaultIgnore,
190
893
  ...baseIgnore,
@@ -249,7 +952,7 @@ function resolveWorkspaceConfig(workspacePath, customConfigPath, options) {
249
952
  const hasCliIgnore = Boolean(options?.ignore && options.ignore.length > 0);
250
953
  let cliIgnore = options?.ignore;
251
954
  if (hasCliIgnore && cliIgnore) {
252
- const normWs = workspacePath.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
955
+ const normWs = stripTrailingSlashes(workspacePath.replace(/\\/g, "/").replace(/^\.\//, ""));
253
956
  const expanded = [];
254
957
  for (const pat of cliIgnore) {
255
958
  expanded.push(pat);
@@ -312,6 +1015,39 @@ const execFileAsync = promisify(execFile);
312
1015
  const FALLBACK_LUALS_VERSION = "3.19.1";
313
1016
  const DEFAULT_LUALS_VERSION = "latest";
314
1017
  /**
1018
+ * Characters accepted in a LuaLS version/tag. Only ASCII letters, digits, dots,
1019
+ * dashes and underscores are allowed, so a version can never contain a path
1020
+ * separator, a drive letter or a traversal segment.
1021
+ */
1022
+ const SAFE_VERSION_CHARS = new Map([..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-"].map((ch) => [ch, ch]));
1023
+ const MAX_VERSION_LENGTH = 64;
1024
+ /**
1025
+ * Validates a LuaLS version/tag and rebuilds it from the allow-list above.
1026
+ *
1027
+ * Version strings originate from untrusted sources: the GitHub releases API
1028
+ * response and user supplied `--luals-version` arguments. They are interpolated
1029
+ * into cache directory paths, download URLs, and the path of the binary that is
1030
+ * eventually executed, so they must be constrained to a single safe path
1031
+ * segment. Rebuilding the value character by character guarantees the returned
1032
+ * string only ever contains allow-listed characters (CodeQL: js/command-line-injection).
1033
+ *
1034
+ * @returns the normalized version (a single leading `v` is dropped), or `null`
1035
+ * when the input cannot be used as a version tag.
1036
+ */
1037
+ function sanitizeLuaLSVersion(raw) {
1038
+ const trimmed = raw.trim();
1039
+ if (trimmed.length === 0 || trimmed.length > MAX_VERSION_LENGTH) return null;
1040
+ let version = "";
1041
+ for (const ch of trimmed) {
1042
+ const allowed = SAFE_VERSION_CHARS.get(ch);
1043
+ if (allowed === void 0) return null;
1044
+ version += allowed;
1045
+ }
1046
+ if (version.charCodeAt(0) === 118) version = version.slice(1);
1047
+ const first = version.charCodeAt(0);
1048
+ return first >= 48 && first <= 57 || first >= 65 && first <= 90 || first >= 97 && first <= 122 ? version : null;
1049
+ }
1050
+ /**
315
1051
  * Escapes single quotes for safe PowerShell single-quoted string interpolation.
316
1052
  */
317
1053
  function escapePowerShellSingleQuote(str) {
@@ -330,17 +1066,22 @@ async function resolveLatestLuaLSVersion() {
330
1066
  });
331
1067
  if (res.ok) {
332
1068
  const data = await res.json();
333
- if (data.tag_name) return data.tag_name.replace(/^v/, "");
1069
+ const version = typeof data.tag_name === "string" ? sanitizeLuaLSVersion(data.tag_name) : null;
1070
+ if (version) return version;
334
1071
  }
335
1072
  } catch {}
336
1073
  return FALLBACK_LUALS_VERSION;
337
1074
  }
338
1075
  /**
339
1076
  * Resolves a version string ("latest" -> actual tag).
1077
+ *
1078
+ * @throws when an explicitly requested version is not a valid tag.
340
1079
  */
341
1080
  async function resolveLuaLSVersion(version) {
342
1081
  if (!version || version === "latest") return await resolveLatestLuaLSVersion();
343
- return version.replace(/^v/, "");
1082
+ const sanitized = sanitizeLuaLSVersion(version);
1083
+ if (!sanitized) throw new Error(`Invalid LuaLS version: "${version}". Expected a release tag such as "3.19.1", or "latest".`);
1084
+ return sanitized;
344
1085
  }
345
1086
  function getPlatformInfo(version = FALLBACK_LUALS_VERSION) {
346
1087
  const platform = process.platform;
@@ -3930,6 +4671,6 @@ if (isDirectExecution()) runCLI().then((code) => {
3930
4671
  process.exit(1);
3931
4672
  });
3932
4673
  //#endregion
3933
- export { mergeConfigs as A, resolveLuaLSVersion as C, getPackageRoot as D, getDefinitionsDir as E, resolveWorkspaceConfig as M, stripJsonComments as N, initWorkspace as O, fileUriToPath as P, resolveLuaLSBinary as S, getDefaultTemplatePath as T, escapePowerShellSingleQuote as _, formatGitHubAnnotations as a, isBinaryValid as b, formatReport as c, pluralize as d, shouldEnableColor as f, downloadAndExtractLuaLS as g, countCheckedFiles as h, runCLI as i, parseJsonc as j, loadConfigFile as k, formatSeverityBadge as l, FALLBACK_LUALS_VERSION as m, createProgram as n, formatPretty as o, DEFAULT_LUALS_VERSION as p, isDirectExecution as r, formatProblemSummary as s, collectIgnorePatterns as t, getColors as u, getCacheDir as v, runLuaLSCheck as w, resolveLatestLuaLSVersion as x, getPlatformInfo as y };
4674
+ export { loadConfigFile as A, resolveLuaLSVersion as C, getDefinitionsDir as D, getDefaultTemplatePath as E, stripTrailingSlashes as F, fileUriToPath as I, parseJsonc as M, resolveWorkspaceConfig as N, getPackageRoot as O, stripJsonComments as P, resolveLuaLSBinary as S, sanitizeLuaLSVersion as T, escapePowerShellSingleQuote as _, formatGitHubAnnotations as a, isBinaryValid as b, formatReport as c, pluralize as d, shouldEnableColor as f, downloadAndExtractLuaLS as g, countCheckedFiles as h, runCLI as i, mergeConfigs as j, initWorkspace as k, formatSeverityBadge as l, FALLBACK_LUALS_VERSION as m, createProgram as n, formatPretty as o, DEFAULT_LUALS_VERSION as p, isDirectExecution as r, formatProblemSummary as s, collectIgnorePatterns as t, getColors as u, getCacheDir as v, runLuaLSCheck as w, resolveLatestLuaLSVersion as x, getPlatformInfo as y };
3934
4675
 
3935
- //# sourceMappingURL=cli-DnmSA08r.js.map
4676
+ //# sourceMappingURL=cli-BVXk8XmH.js.map