@lwc/sfdc-lwc-compiler 13.3.25-alpha.4 → 13.3.25
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.
- package/dist/__tests__/compile-apex-logging.spec.js.map +1 -1
- package/dist/__tests__/compile.spec.js +1 -1
- package/dist/__tests__/compile.spec.js.map +1 -1
- package/dist/compile.d.ts +1 -1
- package/dist/compile.js +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/compiler/__tests__/dynamic-imports.spec.js +1 -1
- package/dist/compiler/__tests__/dynamic-imports.spec.js.map +1 -1
- package/dist/compiler/__tests__/output.spec.js +1 -1
- package/dist/compiler/__tests__/output.spec.js.map +1 -1
- package/dist/compiler/compile.js +2 -2
- package/dist/compiler/compile.js.map +1 -1
- package/dist/utils/__tests__/sarif.spec.js +237 -94
- package/dist/utils/__tests__/sarif.spec.js.map +1 -1
- package/package.json +25 -22
|
@@ -12,130 +12,158 @@ const sarif_1 = require("../sarif");
|
|
|
12
12
|
(0, vitest_1.describe)('sarif utilities', () => {
|
|
13
13
|
(0, vitest_1.describe)('toSarifLevel (internal function - tested via convertDiagnosticsToSarif)', () => {
|
|
14
14
|
(0, vitest_1.it)('converts Fatal (0) to error', () => {
|
|
15
|
-
const diagnostics = [
|
|
15
|
+
const diagnostics = [
|
|
16
|
+
{
|
|
16
17
|
code: 1001,
|
|
17
18
|
message: 'Fatal error',
|
|
18
19
|
level: errors_1.DiagnosticLevel.Fatal,
|
|
19
|
-
}
|
|
20
|
+
},
|
|
21
|
+
];
|
|
20
22
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
21
23
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.level).toBe('error');
|
|
22
24
|
});
|
|
23
25
|
(0, vitest_1.it)('converts Error (1) to error', () => {
|
|
24
|
-
const diagnostics = [
|
|
26
|
+
const diagnostics = [
|
|
27
|
+
{
|
|
25
28
|
code: 1002,
|
|
26
29
|
message: 'Error message',
|
|
27
30
|
level: errors_1.DiagnosticLevel.Error,
|
|
28
|
-
}
|
|
31
|
+
},
|
|
32
|
+
];
|
|
29
33
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
30
34
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.level).toBe('error');
|
|
31
35
|
});
|
|
32
36
|
(0, vitest_1.it)('converts Warning (2) to warning', () => {
|
|
33
|
-
const diagnostics = [
|
|
37
|
+
const diagnostics = [
|
|
38
|
+
{
|
|
34
39
|
code: 1003,
|
|
35
40
|
message: 'Warning message',
|
|
36
41
|
level: errors_1.DiagnosticLevel.Warning,
|
|
37
|
-
}
|
|
42
|
+
},
|
|
43
|
+
];
|
|
38
44
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
39
45
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.level).toBe('warning');
|
|
40
46
|
});
|
|
41
47
|
(0, vitest_1.it)('converts Log (3) to note', () => {
|
|
42
|
-
const diagnostics = [
|
|
48
|
+
const diagnostics = [
|
|
49
|
+
{
|
|
43
50
|
code: 1004,
|
|
44
51
|
message: 'Log message',
|
|
45
52
|
level: errors_1.DiagnosticLevel.Log,
|
|
46
|
-
}
|
|
53
|
+
},
|
|
54
|
+
];
|
|
47
55
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
48
56
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.level).toBe('note');
|
|
49
57
|
});
|
|
50
58
|
(0, vitest_1.it)('converts undefined level to note', () => {
|
|
51
|
-
const diagnostics = [
|
|
59
|
+
const diagnostics = [
|
|
60
|
+
{
|
|
52
61
|
code: 1005,
|
|
53
62
|
message: 'Unknown level',
|
|
54
63
|
level: undefined,
|
|
55
|
-
}
|
|
64
|
+
},
|
|
65
|
+
];
|
|
56
66
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
57
67
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.level).toBe('note');
|
|
58
68
|
});
|
|
59
69
|
(0, vitest_1.it)('converts out of range level to note', () => {
|
|
60
|
-
const diagnostics = [
|
|
70
|
+
const diagnostics = [
|
|
71
|
+
{
|
|
61
72
|
code: 1006,
|
|
62
73
|
message: 'Invalid level',
|
|
63
74
|
level: 999,
|
|
64
|
-
}
|
|
75
|
+
},
|
|
76
|
+
];
|
|
65
77
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
66
78
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.level).toBe('note');
|
|
67
79
|
});
|
|
68
80
|
});
|
|
69
81
|
(0, vitest_1.describe)('ruleIdFromDiagnostic (internal function - tested via convertDiagnosticsToSarif)', () => {
|
|
70
82
|
(0, vitest_1.it)('converts numeric code to LWC prefix format', () => {
|
|
71
|
-
const diagnostics = [
|
|
83
|
+
const diagnostics = [
|
|
84
|
+
{
|
|
72
85
|
code: 1234,
|
|
73
86
|
message: 'Test error',
|
|
74
87
|
level: errors_1.DiagnosticLevel.Error,
|
|
75
|
-
}
|
|
88
|
+
},
|
|
89
|
+
];
|
|
76
90
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
77
91
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWC1234');
|
|
78
92
|
});
|
|
79
93
|
(0, vitest_1.it)('converts string code with LWC prefix', () => {
|
|
80
|
-
const diagnostics = [
|
|
94
|
+
const diagnostics = [
|
|
95
|
+
{
|
|
81
96
|
code: 'CUSTOM_ERROR',
|
|
82
97
|
message: 'Custom error',
|
|
83
98
|
level: errors_1.DiagnosticLevel.Error,
|
|
84
|
-
}
|
|
99
|
+
},
|
|
100
|
+
];
|
|
85
101
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
86
102
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWCCUSTOM_ERROR');
|
|
87
103
|
});
|
|
88
104
|
(0, vitest_1.it)('handles undefined code', () => {
|
|
89
|
-
const diagnostics = [
|
|
105
|
+
const diagnostics = [
|
|
106
|
+
{
|
|
90
107
|
code: undefined,
|
|
91
108
|
message: 'No code',
|
|
92
109
|
level: errors_1.DiagnosticLevel.Error,
|
|
93
|
-
}
|
|
110
|
+
},
|
|
111
|
+
];
|
|
94
112
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
95
113
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWCundefined');
|
|
96
114
|
});
|
|
97
115
|
(0, vitest_1.it)('handles null code', () => {
|
|
98
|
-
const diagnostics = [
|
|
116
|
+
const diagnostics = [
|
|
117
|
+
{
|
|
99
118
|
code: null,
|
|
100
119
|
message: 'Null code',
|
|
101
120
|
level: errors_1.DiagnosticLevel.Error,
|
|
102
|
-
}
|
|
121
|
+
},
|
|
122
|
+
];
|
|
103
123
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
104
124
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWCnull');
|
|
105
125
|
});
|
|
106
126
|
(0, vitest_1.it)('handles zero code', () => {
|
|
107
|
-
const diagnostics = [
|
|
127
|
+
const diagnostics = [
|
|
128
|
+
{
|
|
108
129
|
code: 0,
|
|
109
130
|
message: 'Zero code',
|
|
110
131
|
level: errors_1.DiagnosticLevel.Error,
|
|
111
|
-
}
|
|
132
|
+
},
|
|
133
|
+
];
|
|
112
134
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
113
135
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWC0');
|
|
114
136
|
});
|
|
115
137
|
(0, vitest_1.it)('handles negative code', () => {
|
|
116
|
-
const diagnostics = [
|
|
138
|
+
const diagnostics = [
|
|
139
|
+
{
|
|
117
140
|
code: -5,
|
|
118
141
|
message: 'Negative code',
|
|
119
142
|
level: errors_1.DiagnosticLevel.Error,
|
|
120
|
-
}
|
|
143
|
+
},
|
|
144
|
+
];
|
|
121
145
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
122
146
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWC-5');
|
|
123
147
|
});
|
|
124
148
|
(0, vitest_1.it)('handles empty string code', () => {
|
|
125
|
-
const diagnostics = [
|
|
149
|
+
const diagnostics = [
|
|
150
|
+
{
|
|
126
151
|
code: '',
|
|
127
152
|
message: 'Empty string code',
|
|
128
153
|
level: errors_1.DiagnosticLevel.Error,
|
|
129
|
-
}
|
|
154
|
+
},
|
|
155
|
+
];
|
|
130
156
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
131
157
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWC');
|
|
132
158
|
});
|
|
133
159
|
(0, vitest_1.it)('handles numeric string code', () => {
|
|
134
|
-
const diagnostics = [
|
|
160
|
+
const diagnostics = [
|
|
161
|
+
{
|
|
135
162
|
code: '1234',
|
|
136
163
|
message: 'Numeric string',
|
|
137
164
|
level: errors_1.DiagnosticLevel.Error,
|
|
138
|
-
}
|
|
165
|
+
},
|
|
166
|
+
];
|
|
139
167
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
140
168
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.ruleId).toBe('LWC1234');
|
|
141
169
|
});
|
|
@@ -167,7 +195,11 @@ const sarif_1 = require("../sarif");
|
|
|
167
195
|
outputConfig: {},
|
|
168
196
|
diagnostics: [
|
|
169
197
|
{ code: 2001, message: 'Bundle error 1', level: errors_1.DiagnosticLevel.Error },
|
|
170
|
-
{
|
|
198
|
+
{
|
|
199
|
+
code: 2002,
|
|
200
|
+
message: 'Bundle error 2',
|
|
201
|
+
level: errors_1.DiagnosticLevel.Warning,
|
|
202
|
+
},
|
|
171
203
|
],
|
|
172
204
|
timings: {},
|
|
173
205
|
},
|
|
@@ -181,9 +213,7 @@ const sarif_1 = require("../sarif");
|
|
|
181
213
|
const output = {
|
|
182
214
|
success: false,
|
|
183
215
|
version: '1.0.0',
|
|
184
|
-
diagnostics: [
|
|
185
|
-
{ code: 1001, message: 'Top error', level: errors_1.DiagnosticLevel.Error },
|
|
186
|
-
],
|
|
216
|
+
diagnostics: [{ code: 1001, message: 'Top error', level: errors_1.DiagnosticLevel.Error }],
|
|
187
217
|
results: [
|
|
188
218
|
{
|
|
189
219
|
code: 'bundle code',
|
|
@@ -233,8 +263,20 @@ const sarif_1 = require("../sarif");
|
|
|
233
263
|
success: false,
|
|
234
264
|
version: '1.0.0',
|
|
235
265
|
diagnostics: [
|
|
236
|
-
{
|
|
237
|
-
|
|
266
|
+
{
|
|
267
|
+
code: 1001,
|
|
268
|
+
message: 'Same message',
|
|
269
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
270
|
+
filename: 'test.js',
|
|
271
|
+
location: { line: 1, column: 5 },
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
code: 1002,
|
|
275
|
+
message: 'Same message',
|
|
276
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
277
|
+
filename: 'test.js',
|
|
278
|
+
location: { line: 1, column: 5 },
|
|
279
|
+
},
|
|
238
280
|
],
|
|
239
281
|
timings: {},
|
|
240
282
|
};
|
|
@@ -246,8 +288,20 @@ const sarif_1 = require("../sarif");
|
|
|
246
288
|
success: false,
|
|
247
289
|
version: '1.0.0',
|
|
248
290
|
diagnostics: [
|
|
249
|
-
{
|
|
250
|
-
|
|
291
|
+
{
|
|
292
|
+
code: 1001,
|
|
293
|
+
message: 'Message 1',
|
|
294
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
295
|
+
filename: 'test.js',
|
|
296
|
+
location: { line: 1, column: 5 },
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
code: 1001,
|
|
300
|
+
message: 'Message 2',
|
|
301
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
302
|
+
filename: 'test.js',
|
|
303
|
+
location: { line: 1, column: 5 },
|
|
304
|
+
},
|
|
251
305
|
],
|
|
252
306
|
timings: {},
|
|
253
307
|
};
|
|
@@ -259,8 +313,20 @@ const sarif_1 = require("../sarif");
|
|
|
259
313
|
success: false,
|
|
260
314
|
version: '1.0.0',
|
|
261
315
|
diagnostics: [
|
|
262
|
-
{
|
|
263
|
-
|
|
316
|
+
{
|
|
317
|
+
code: 1001,
|
|
318
|
+
message: 'Same error',
|
|
319
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
320
|
+
filename: 'test1.js',
|
|
321
|
+
location: { line: 1, column: 5 },
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
code: 1001,
|
|
325
|
+
message: 'Same error',
|
|
326
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
327
|
+
filename: 'test2.js',
|
|
328
|
+
location: { line: 1, column: 5 },
|
|
329
|
+
},
|
|
264
330
|
],
|
|
265
331
|
timings: {},
|
|
266
332
|
};
|
|
@@ -272,8 +338,20 @@ const sarif_1 = require("../sarif");
|
|
|
272
338
|
success: false,
|
|
273
339
|
version: '1.0.0',
|
|
274
340
|
diagnostics: [
|
|
275
|
-
{
|
|
276
|
-
|
|
341
|
+
{
|
|
342
|
+
code: 1001,
|
|
343
|
+
message: 'Same error',
|
|
344
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
345
|
+
filename: 'test.js',
|
|
346
|
+
location: { line: 1, column: 5 },
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
code: 1001,
|
|
350
|
+
message: 'Same error',
|
|
351
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
352
|
+
filename: 'test.js',
|
|
353
|
+
location: { line: 2, column: 10 },
|
|
354
|
+
},
|
|
277
355
|
],
|
|
278
356
|
timings: {},
|
|
279
357
|
};
|
|
@@ -284,9 +362,7 @@ const sarif_1 = require("../sarif");
|
|
|
284
362
|
const output = {
|
|
285
363
|
success: true,
|
|
286
364
|
version: '1.0.0',
|
|
287
|
-
diagnostics: [
|
|
288
|
-
{ code: 1001, message: 'Top error', level: errors_1.DiagnosticLevel.Error },
|
|
289
|
-
],
|
|
365
|
+
diagnostics: [{ code: 1001, message: 'Top error', level: errors_1.DiagnosticLevel.Error }],
|
|
290
366
|
results: undefined,
|
|
291
367
|
timings: {},
|
|
292
368
|
};
|
|
@@ -330,7 +406,12 @@ const sarif_1 = require("../sarif");
|
|
|
330
406
|
success: false,
|
|
331
407
|
version: '1.0.0',
|
|
332
408
|
diagnostics: [
|
|
333
|
-
{
|
|
409
|
+
{
|
|
410
|
+
code: 1001,
|
|
411
|
+
message: 'Error',
|
|
412
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
413
|
+
filename: undefined,
|
|
414
|
+
},
|
|
334
415
|
],
|
|
335
416
|
timings: {},
|
|
336
417
|
};
|
|
@@ -342,7 +423,12 @@ const sarif_1 = require("../sarif");
|
|
|
342
423
|
success: false,
|
|
343
424
|
version: '1.0.0',
|
|
344
425
|
diagnostics: [
|
|
345
|
-
{
|
|
426
|
+
{
|
|
427
|
+
code: 1001,
|
|
428
|
+
message: 'Error',
|
|
429
|
+
level: errors_1.DiagnosticLevel.Error,
|
|
430
|
+
location: undefined,
|
|
431
|
+
},
|
|
346
432
|
],
|
|
347
433
|
timings: {},
|
|
348
434
|
};
|
|
@@ -384,11 +470,13 @@ const sarif_1 = require("../sarif");
|
|
|
384
470
|
});
|
|
385
471
|
(0, vitest_1.describe)('convertDiagnosticsToSarif', () => {
|
|
386
472
|
(0, vitest_1.it)('creates valid SARIF structure', () => {
|
|
387
|
-
const diagnostics = [
|
|
473
|
+
const diagnostics = [
|
|
474
|
+
{
|
|
388
475
|
code: 1001,
|
|
389
476
|
message: 'Test error',
|
|
390
477
|
level: errors_1.DiagnosticLevel.Error,
|
|
391
|
-
}
|
|
478
|
+
},
|
|
479
|
+
];
|
|
392
480
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
393
481
|
(0, vitest_1.expect)(sarif.version).toBe('2.1.0');
|
|
394
482
|
(0, vitest_1.expect)(sarif.$schema).toBe('https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json');
|
|
@@ -397,49 +485,59 @@ const sarif_1 = require("../sarif");
|
|
|
397
485
|
(0, vitest_1.expect)(sarif.runs[0].results).toHaveLength(1);
|
|
398
486
|
});
|
|
399
487
|
(0, vitest_1.it)('uses default tool name when options not provided', () => {
|
|
400
|
-
const diagnostics = [
|
|
488
|
+
const diagnostics = [
|
|
489
|
+
{
|
|
401
490
|
code: 1001,
|
|
402
491
|
message: 'Test error',
|
|
403
492
|
level: errors_1.DiagnosticLevel.Error,
|
|
404
|
-
}
|
|
493
|
+
},
|
|
494
|
+
];
|
|
405
495
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
406
496
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.name).toBe('@lwc/sfdc-lwc-compiler');
|
|
407
497
|
});
|
|
408
498
|
(0, vitest_1.it)('uses default tool name when options is empty object', () => {
|
|
409
|
-
const diagnostics = [
|
|
499
|
+
const diagnostics = [
|
|
500
|
+
{
|
|
410
501
|
code: 1001,
|
|
411
502
|
message: 'Test error',
|
|
412
503
|
level: errors_1.DiagnosticLevel.Error,
|
|
413
|
-
}
|
|
504
|
+
},
|
|
505
|
+
];
|
|
414
506
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics, {});
|
|
415
507
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.name).toBe('@lwc/sfdc-lwc-compiler');
|
|
416
508
|
});
|
|
417
509
|
(0, vitest_1.it)('uses custom tool name when provided', () => {
|
|
418
|
-
const diagnostics = [
|
|
510
|
+
const diagnostics = [
|
|
511
|
+
{
|
|
419
512
|
code: 1001,
|
|
420
513
|
message: 'Test error',
|
|
421
514
|
level: errors_1.DiagnosticLevel.Error,
|
|
422
|
-
}
|
|
515
|
+
},
|
|
516
|
+
];
|
|
423
517
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics, { toolName: 'custom-tool' });
|
|
424
518
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.name).toBe('custom-tool');
|
|
425
519
|
});
|
|
426
520
|
(0, vitest_1.it)('creates rule for diagnostic with code', () => {
|
|
427
|
-
const diagnostics = [
|
|
521
|
+
const diagnostics = [
|
|
522
|
+
{
|
|
428
523
|
code: 1001,
|
|
429
524
|
message: 'Test error',
|
|
430
525
|
level: errors_1.DiagnosticLevel.Error,
|
|
431
|
-
}
|
|
526
|
+
},
|
|
527
|
+
];
|
|
432
528
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
433
529
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules).toHaveLength(1);
|
|
434
530
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].id).toBe('LWC1001');
|
|
435
531
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].name).toBe('LWC1001');
|
|
436
532
|
});
|
|
437
533
|
(0, vitest_1.it)('creates rule for diagnostic with undefined code', () => {
|
|
438
|
-
const diagnostics = [
|
|
534
|
+
const diagnostics = [
|
|
535
|
+
{
|
|
439
536
|
code: undefined,
|
|
440
537
|
message: 'Test error',
|
|
441
538
|
level: errors_1.DiagnosticLevel.Error,
|
|
442
|
-
}
|
|
539
|
+
},
|
|
540
|
+
];
|
|
443
541
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
444
542
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules).toHaveLength(1);
|
|
445
543
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].id).toBe('LWCundefined');
|
|
@@ -464,57 +562,69 @@ const sarif_1 = require("../sarif");
|
|
|
464
562
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules).toHaveLength(3);
|
|
465
563
|
});
|
|
466
564
|
(0, vitest_1.it)('extracts short description from message with colon', () => {
|
|
467
|
-
const diagnostics = [
|
|
565
|
+
const diagnostics = [
|
|
566
|
+
{
|
|
468
567
|
code: 1001,
|
|
469
568
|
message: 'ShortDesc: Full description here',
|
|
470
569
|
level: errors_1.DiagnosticLevel.Error,
|
|
471
|
-
}
|
|
570
|
+
},
|
|
571
|
+
];
|
|
472
572
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
473
573
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].shortDescription?.text).toBe('ShortDesc');
|
|
474
574
|
});
|
|
475
575
|
(0, vitest_1.it)('uses full message as short description when no colon', () => {
|
|
476
|
-
const diagnostics = [
|
|
576
|
+
const diagnostics = [
|
|
577
|
+
{
|
|
477
578
|
code: 1001,
|
|
478
579
|
message: 'Full message without colon',
|
|
479
580
|
level: errors_1.DiagnosticLevel.Error,
|
|
480
|
-
}
|
|
581
|
+
},
|
|
582
|
+
];
|
|
481
583
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
482
584
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].shortDescription?.text).toBe('Full message without colon');
|
|
483
585
|
});
|
|
484
586
|
(0, vitest_1.it)('handles empty short description', () => {
|
|
485
|
-
const diagnostics = [
|
|
587
|
+
const diagnostics = [
|
|
588
|
+
{
|
|
486
589
|
code: 1001,
|
|
487
590
|
message: '',
|
|
488
591
|
level: errors_1.DiagnosticLevel.Error,
|
|
489
|
-
}
|
|
592
|
+
},
|
|
593
|
+
];
|
|
490
594
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
491
595
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].shortDescription).toBeUndefined();
|
|
492
596
|
});
|
|
493
597
|
(0, vitest_1.it)('includes helpUri when url is provided', () => {
|
|
494
|
-
const diagnostics = [
|
|
598
|
+
const diagnostics = [
|
|
599
|
+
{
|
|
495
600
|
code: 1001,
|
|
496
601
|
message: 'Test error',
|
|
497
602
|
level: errors_1.DiagnosticLevel.Error,
|
|
498
603
|
url: 'https://example.com/error/1001',
|
|
499
|
-
}
|
|
604
|
+
},
|
|
605
|
+
];
|
|
500
606
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
501
607
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].helpUri).toBe('https://example.com/error/1001');
|
|
502
608
|
});
|
|
503
609
|
(0, vitest_1.it)('sets helpUri to undefined when url is not provided', () => {
|
|
504
|
-
const diagnostics = [
|
|
610
|
+
const diagnostics = [
|
|
611
|
+
{
|
|
505
612
|
code: 1001,
|
|
506
613
|
message: 'Test error',
|
|
507
614
|
level: errors_1.DiagnosticLevel.Error,
|
|
508
|
-
}
|
|
615
|
+
},
|
|
616
|
+
];
|
|
509
617
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
510
618
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules[0].helpUri).toBeUndefined();
|
|
511
619
|
});
|
|
512
620
|
(0, vitest_1.it)('sets rank to 100 for Fatal level', () => {
|
|
513
|
-
const diagnostics = [
|
|
621
|
+
const diagnostics = [
|
|
622
|
+
{
|
|
514
623
|
code: 1001,
|
|
515
624
|
message: 'Fatal error',
|
|
516
625
|
level: errors_1.DiagnosticLevel.Fatal,
|
|
517
|
-
}
|
|
626
|
+
},
|
|
627
|
+
];
|
|
518
628
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
519
629
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.rank).toBe(100);
|
|
520
630
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.properties?.isFatal).toBe(true);
|
|
@@ -532,22 +642,26 @@ const sarif_1 = require("../sarif");
|
|
|
532
642
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.properties?.isFatal).toBe(false);
|
|
533
643
|
});
|
|
534
644
|
(0, vitest_1.it)('includes message text', () => {
|
|
535
|
-
const diagnostics = [
|
|
645
|
+
const diagnostics = [
|
|
646
|
+
{
|
|
536
647
|
code: 1001,
|
|
537
648
|
message: 'Test error message',
|
|
538
649
|
level: errors_1.DiagnosticLevel.Error,
|
|
539
|
-
}
|
|
650
|
+
},
|
|
651
|
+
];
|
|
540
652
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
541
653
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.message.text).toBe('Test error message');
|
|
542
654
|
});
|
|
543
655
|
(0, vitest_1.it)('includes both filename and location', () => {
|
|
544
|
-
const diagnostics = [
|
|
656
|
+
const diagnostics = [
|
|
657
|
+
{
|
|
545
658
|
code: 1001,
|
|
546
659
|
message: 'Test error',
|
|
547
660
|
level: errors_1.DiagnosticLevel.Error,
|
|
548
661
|
filename: 'test.js',
|
|
549
662
|
location: { line: 10, column: 5 },
|
|
550
|
-
}
|
|
663
|
+
},
|
|
664
|
+
];
|
|
551
665
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
552
666
|
const result = sarif.runs[0]?.results?.[0];
|
|
553
667
|
(0, vitest_1.expect)(result?.locations).toHaveLength(1);
|
|
@@ -556,12 +670,14 @@ const sarif_1 = require("../sarif");
|
|
|
556
670
|
(0, vitest_1.expect)(result?.locations?.[0]?.physicalLocation?.region?.startColumn).toBe(5);
|
|
557
671
|
});
|
|
558
672
|
(0, vitest_1.it)('includes only filename when location is not provided', () => {
|
|
559
|
-
const diagnostics = [
|
|
673
|
+
const diagnostics = [
|
|
674
|
+
{
|
|
560
675
|
code: 1001,
|
|
561
676
|
message: 'Test error',
|
|
562
677
|
level: errors_1.DiagnosticLevel.Error,
|
|
563
678
|
filename: 'test.js',
|
|
564
|
-
}
|
|
679
|
+
},
|
|
680
|
+
];
|
|
565
681
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
566
682
|
const result = sarif.runs[0]?.results?.[0];
|
|
567
683
|
(0, vitest_1.expect)(result?.locations).toHaveLength(1);
|
|
@@ -569,12 +685,14 @@ const sarif_1 = require("../sarif");
|
|
|
569
685
|
(0, vitest_1.expect)(result?.locations?.[0]?.physicalLocation?.region).toBeUndefined();
|
|
570
686
|
});
|
|
571
687
|
(0, vitest_1.it)('includes only location when filename is not provided', () => {
|
|
572
|
-
const diagnostics = [
|
|
688
|
+
const diagnostics = [
|
|
689
|
+
{
|
|
573
690
|
code: 1001,
|
|
574
691
|
message: 'Test error',
|
|
575
692
|
level: errors_1.DiagnosticLevel.Error,
|
|
576
693
|
location: { line: 10, column: 5 },
|
|
577
|
-
}
|
|
694
|
+
},
|
|
695
|
+
];
|
|
578
696
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
579
697
|
const result = sarif.runs[0]?.results?.[0];
|
|
580
698
|
(0, vitest_1.expect)(result?.locations).toHaveLength(1);
|
|
@@ -583,20 +701,24 @@ const sarif_1 = require("../sarif");
|
|
|
583
701
|
(0, vitest_1.expect)(result?.locations?.[0]?.physicalLocation?.region?.startColumn).toBe(5);
|
|
584
702
|
});
|
|
585
703
|
(0, vitest_1.it)('sets locations to undefined when neither filename nor location provided', () => {
|
|
586
|
-
const diagnostics = [
|
|
704
|
+
const diagnostics = [
|
|
705
|
+
{
|
|
587
706
|
code: 1001,
|
|
588
707
|
message: 'Test error',
|
|
589
708
|
level: errors_1.DiagnosticLevel.Error,
|
|
590
|
-
}
|
|
709
|
+
},
|
|
710
|
+
];
|
|
591
711
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
592
712
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.locations).toBeUndefined();
|
|
593
713
|
});
|
|
594
714
|
(0, vitest_1.it)('includes code in properties', () => {
|
|
595
|
-
const diagnostics = [
|
|
715
|
+
const diagnostics = [
|
|
716
|
+
{
|
|
596
717
|
code: 1234,
|
|
597
718
|
message: 'Test error',
|
|
598
719
|
level: errors_1.DiagnosticLevel.Error,
|
|
599
|
-
}
|
|
720
|
+
},
|
|
721
|
+
];
|
|
600
722
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
601
723
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.properties?.code).toBe(1234);
|
|
602
724
|
});
|
|
@@ -607,14 +729,16 @@ const sarif_1 = require("../sarif");
|
|
|
607
729
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules).toBeUndefined();
|
|
608
730
|
});
|
|
609
731
|
(0, vitest_1.it)('handles diagnostics with all fields populated', () => {
|
|
610
|
-
const diagnostics = [
|
|
732
|
+
const diagnostics = [
|
|
733
|
+
{
|
|
611
734
|
code: 1001,
|
|
612
735
|
message: 'Complete error',
|
|
613
736
|
level: errors_1.DiagnosticLevel.Fatal,
|
|
614
737
|
filename: 'component.js',
|
|
615
738
|
location: { line: 42, column: 13, start: 500, length: 10 },
|
|
616
739
|
url: 'https://docs.example.com/errors/1001',
|
|
617
|
-
}
|
|
740
|
+
},
|
|
741
|
+
];
|
|
618
742
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
619
743
|
const result = sarif.runs[0]?.results?.[0];
|
|
620
744
|
(0, vitest_1.expect)(result?.ruleId).toBe('LWC1001');
|
|
@@ -627,9 +751,19 @@ const sarif_1 = require("../sarif");
|
|
|
627
751
|
});
|
|
628
752
|
(0, vitest_1.it)('handles multiple diagnostics with mixed configurations', () => {
|
|
629
753
|
const diagnostics = [
|
|
630
|
-
{
|
|
754
|
+
{
|
|
755
|
+
code: 1001,
|
|
756
|
+
message: 'Fatal error',
|
|
757
|
+
level: errors_1.DiagnosticLevel.Fatal,
|
|
758
|
+
filename: 'a.js',
|
|
759
|
+
},
|
|
631
760
|
{ code: 1002, message: 'Error', level: errors_1.DiagnosticLevel.Error },
|
|
632
|
-
{
|
|
761
|
+
{
|
|
762
|
+
code: 1003,
|
|
763
|
+
message: 'Warning',
|
|
764
|
+
level: errors_1.DiagnosticLevel.Warning,
|
|
765
|
+
location: { line: 5, column: 10 },
|
|
766
|
+
},
|
|
633
767
|
{ code: undefined, message: 'No code', level: errors_1.DiagnosticLevel.Log },
|
|
634
768
|
];
|
|
635
769
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
@@ -721,31 +855,38 @@ const sarif_1 = require("../sarif");
|
|
|
721
855
|
});
|
|
722
856
|
(0, vitest_1.describe)('edge cases and integration', () => {
|
|
723
857
|
(0, vitest_1.it)('handles Unicode characters in messages', () => {
|
|
724
|
-
const diagnostics = [
|
|
858
|
+
const diagnostics = [
|
|
859
|
+
{
|
|
725
860
|
code: 1001,
|
|
726
861
|
message: 'Error with émojis 🎉 and ünïcödé',
|
|
727
862
|
level: errors_1.DiagnosticLevel.Error,
|
|
728
|
-
}
|
|
863
|
+
},
|
|
864
|
+
];
|
|
729
865
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
730
866
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.message.text).toBe('Error with émojis 🎉 and ünïcödé');
|
|
731
867
|
});
|
|
732
868
|
(0, vitest_1.it)('handles special characters in filenames', () => {
|
|
733
|
-
const diagnostics = [
|
|
869
|
+
const diagnostics = [
|
|
870
|
+
{
|
|
734
871
|
code: 1001,
|
|
735
872
|
message: 'Error',
|
|
736
873
|
level: errors_1.DiagnosticLevel.Error,
|
|
737
874
|
filename: 'path/to/file with spaces.js',
|
|
738
|
-
}
|
|
875
|
+
},
|
|
876
|
+
];
|
|
739
877
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
740
|
-
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.locations?.[0]?.physicalLocation?.artifactLocation
|
|
878
|
+
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.locations?.[0]?.physicalLocation?.artifactLocation
|
|
879
|
+
?.uri).toBe('path/to/file with spaces.js');
|
|
741
880
|
});
|
|
742
881
|
(0, vitest_1.it)('handles very large line numbers', () => {
|
|
743
|
-
const diagnostics = [
|
|
882
|
+
const diagnostics = [
|
|
883
|
+
{
|
|
744
884
|
code: 1001,
|
|
745
885
|
message: 'Error',
|
|
746
886
|
level: errors_1.DiagnosticLevel.Error,
|
|
747
887
|
location: { line: 999999, column: 999999 },
|
|
748
|
-
}
|
|
888
|
+
},
|
|
889
|
+
];
|
|
749
890
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
750
891
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.locations?.[0]?.physicalLocation?.region?.startLine).toBe(999999);
|
|
751
892
|
(0, vitest_1.expect)(sarif.runs[0]?.results?.[0]?.locations?.[0]?.physicalLocation?.region?.startColumn).toBe(999999);
|
|
@@ -761,14 +902,16 @@ const sarif_1 = require("../sarif");
|
|
|
761
902
|
(0, vitest_1.expect)(sarif.runs[0].tool.driver.rules).toHaveLength(100);
|
|
762
903
|
});
|
|
763
904
|
(0, vitest_1.it)('produces SARIF that matches schema structure', () => {
|
|
764
|
-
const diagnostics = [
|
|
905
|
+
const diagnostics = [
|
|
906
|
+
{
|
|
765
907
|
code: 1001,
|
|
766
908
|
message: 'Test: Full error message',
|
|
767
909
|
level: errors_1.DiagnosticLevel.Error,
|
|
768
910
|
filename: 'component.js',
|
|
769
911
|
location: { line: 10, column: 5 },
|
|
770
912
|
url: 'https://docs.example.com/1001',
|
|
771
|
-
}
|
|
913
|
+
},
|
|
914
|
+
];
|
|
772
915
|
const sarif = (0, sarif_1.convertDiagnosticsToSarif)(diagnostics);
|
|
773
916
|
// Validate SARIF structure
|
|
774
917
|
(0, vitest_1.expect)(sarif).toHaveProperty('version');
|