@mui/internal-code-infra 0.0.4-canary.73 → 0.0.4-canary.75

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.
Files changed (52) hide show
  1. package/package.json +7 -5
  2. package/src/brokenLinksChecker/crawlWorker.mjs +23 -0
  3. package/src/cli/cmdPublish.mjs +32 -3
  4. package/src/brokenLinksChecker/__fixtures__/static-site/broken-links.html +0 -20
  5. package/src/brokenLinksChecker/__fixtures__/static-site/broken-targets.html +0 -22
  6. package/src/brokenLinksChecker/__fixtures__/static-site/example.md +0 -20
  7. package/src/brokenLinksChecker/__fixtures__/static-site/external-links.html +0 -21
  8. package/src/brokenLinksChecker/__fixtures__/static-site/ignored-page.html +0 -17
  9. package/src/brokenLinksChecker/__fixtures__/static-site/index.html +0 -29
  10. package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +0 -15
  11. package/src/brokenLinksChecker/__fixtures__/static-site/known-targets.json +0 -5
  12. package/src/brokenLinksChecker/__fixtures__/static-site/nested/page.html +0 -21
  13. package/src/brokenLinksChecker/__fixtures__/static-site/orphaned-page.html +0 -20
  14. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-api-links.html +0 -20
  15. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-custom-targets.html +0 -24
  16. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-ignored-content.html +0 -28
  17. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-known-target-links.html +0 -19
  18. package/src/brokenLinksChecker/__fixtures__/static-site/unclosed-tags.html +0 -1
  19. package/src/brokenLinksChecker/__fixtures__/static-site/valid.html +0 -20
  20. package/src/brokenLinksChecker/__fixtures__/static-site/with-anchors.html +0 -31
  21. package/src/brokenLinksChecker/index.test.ts +0 -301
  22. package/src/changelog/categorizeCommits.test.ts +0 -319
  23. package/src/changelog/filterCommits.test.ts +0 -363
  24. package/src/changelog/parseCommitLabels.test.ts +0 -509
  25. package/src/changelog/renderChangelog.test.ts +0 -378
  26. package/src/changelog/sortSections.test.ts +0 -199
  27. package/src/cli/cmdVale.test.mjs +0 -644
  28. package/src/eslint/mui/rules/add-undef-to-optional.test.mjs +0 -361
  29. package/src/eslint/mui/rules/consistent-production-guard.test.mjs +0 -162
  30. package/src/eslint/mui/rules/disallow-active-elements-as-key-event-target.test.mjs +0 -66
  31. package/src/eslint/mui/rules/disallow-react-api-in-server-components.test.mjs +0 -305
  32. package/src/eslint/mui/rules/docgen-ignore-before-comment.test.mjs +0 -52
  33. package/src/eslint/mui/rules/flatten-parentheses.test.mjs +0 -245
  34. package/src/eslint/mui/rules/mui-name-matches-component-name.test.mjs +0 -247
  35. package/src/eslint/mui/rules/no-empty-box.test.mjs +0 -40
  36. package/src/eslint/mui/rules/no-floating-cleanup.test.mjs +0 -141
  37. package/src/eslint/mui/rules/no-guarded-throw.test.mjs +0 -206
  38. package/src/eslint/mui/rules/no-presentation-role.test.mjs +0 -33
  39. package/src/eslint/mui/rules/no-styled-box.test.mjs +0 -73
  40. package/src/eslint/mui/rules/require-dev-wrapper.test.mjs +0 -265
  41. package/src/eslint/mui/rules/rules-of-use-theme-variants.test.mjs +0 -149
  42. package/src/eslint/mui/rules/straight-quotes.test.mjs +0 -67
  43. package/src/remark/firstBlockHeading.test.mjs +0 -107
  44. package/src/remark/gitDiff.test.mjs +0 -45
  45. package/src/remark/noSpaceInLinks.test.mjs +0 -22
  46. package/src/remark/straightQuotes.test.mjs +0 -25
  47. package/src/remark/tableAlignment.test.mjs +0 -28
  48. package/src/remark/terminalLanguage.test.mjs +0 -17
  49. package/src/utils/build.test.mjs +0 -1263
  50. package/src/utils/pnpm.test.mjs +0 -731
  51. package/src/utils/template.test.mjs +0 -133
  52. package/src/utils/typescript.test.mjs +0 -341
@@ -1,509 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- // eslint-disable-next-line import/extensions
3
- import { parseCommitLabels } from './parseCommitLabels.mjs';
4
- import type { FetchedCommitDetails, LabelConfig } from './types';
5
-
6
- function createCommit(overrides: Partial<FetchedCommitDetails> = {}): FetchedCommitDetails {
7
- return {
8
- sha: 'abc123',
9
- message: 'test commit',
10
- labels: [],
11
- prNumber: 1,
12
- html_url: 'https://github.com/test/repo/pull/1',
13
- author: {
14
- login: 'testuser',
15
- association: 'contributor',
16
- },
17
- createdAt: '2025-01-01T00:00:00Z',
18
- mergedAt: '2025-01-01T00:00:00Z',
19
- ...overrides,
20
- };
21
- }
22
-
23
- const baseLabelConfig: LabelConfig = {
24
- plan: {
25
- values: ['pro', 'premium'],
26
- },
27
- };
28
-
29
- describe('parseCommitLabels', () => {
30
- describe('basic parsing', () => {
31
- it('should return empty arrays when commit has no labels', () => {
32
- const commit = createCommit({ labels: [] });
33
-
34
- const result = parseCommitLabels(commit, baseLabelConfig);
35
-
36
- expect(result).toEqual({
37
- scopes: [],
38
- components: [],
39
- flags: [],
40
- });
41
- });
42
-
43
- it('should ignore unrecognized labels', () => {
44
- const commit = createCommit({ labels: ['random-label', 'another-label'] });
45
-
46
- const result = parseCommitLabels(commit, baseLabelConfig);
47
-
48
- expect(result).toEqual({
49
- scopes: [],
50
- components: [],
51
- flags: [],
52
- });
53
- });
54
- });
55
-
56
- describe('scope parsing', () => {
57
- it('should parse scope label with default prefix', () => {
58
- const commit = createCommit({ labels: ['scope: data-grid'] });
59
-
60
- const result = parseCommitLabels(commit, baseLabelConfig);
61
-
62
- expect(result.scopes).toEqual(['data-grid']);
63
- });
64
-
65
- it('should parse multiple scope labels', () => {
66
- const commit = createCommit({ labels: ['scope: data-grid', 'scope: charts'] });
67
-
68
- const result = parseCommitLabels(commit, baseLabelConfig);
69
-
70
- expect(result.scopes).toEqual(['data-grid', 'charts']);
71
- });
72
-
73
- it('should parse scope labels with custom prefix', () => {
74
- const commit = createCommit({ labels: ['package: core', 'package: utils'] });
75
- const config: LabelConfig = {
76
- ...baseLabelConfig,
77
- scope: {
78
- prefix: ['package:'],
79
- },
80
- };
81
-
82
- const result = parseCommitLabels(commit, config);
83
-
84
- expect(result.scopes).toEqual(['core', 'utils']);
85
- });
86
-
87
- it('should support multiple scope prefixes', () => {
88
- const commit = createCommit({ labels: ['scope: data-grid', 'package: utils'] });
89
- const config: LabelConfig = {
90
- ...baseLabelConfig,
91
- scope: {
92
- prefix: ['scope:', 'package:'],
93
- },
94
- };
95
-
96
- const result = parseCommitLabels(commit, config);
97
-
98
- expect(result.scopes).toEqual(['data-grid', 'utils']);
99
- });
100
-
101
- it('should trim whitespace from scope values', () => {
102
- const commit = createCommit({ labels: ['scope: data-grid '] });
103
-
104
- const result = parseCommitLabels(commit, baseLabelConfig);
105
-
106
- expect(result.scopes).toEqual(['data-grid']);
107
- });
108
- });
109
-
110
- describe('component parsing', () => {
111
- it('should parse component label with default prefix', () => {
112
- const commit = createCommit({ labels: ['component: Button'] });
113
-
114
- const result = parseCommitLabels(commit, baseLabelConfig);
115
-
116
- expect(result.components).toEqual(['Button']);
117
- });
118
-
119
- it('should parse multiple component labels', () => {
120
- const commit = createCommit({ labels: ['component: Button', 'component: TextField'] });
121
-
122
- const result = parseCommitLabels(commit, baseLabelConfig);
123
-
124
- expect(result.components).toEqual(['Button', 'TextField']);
125
- });
126
-
127
- it('should parse component labels with custom prefix', () => {
128
- const commit = createCommit({ labels: ['comp: Button', 'comp: Input'] });
129
- const config: LabelConfig = {
130
- ...baseLabelConfig,
131
- component: {
132
- prefix: ['comp:'],
133
- },
134
- };
135
-
136
- const result = parseCommitLabels(commit, config);
137
-
138
- expect(result.components).toEqual(['Button', 'Input']);
139
- });
140
-
141
- it('should support multiple component prefixes', () => {
142
- const commit = createCommit({ labels: ['component: Button', 'widget: Slider'] });
143
- const config: LabelConfig = {
144
- ...baseLabelConfig,
145
- component: {
146
- prefix: ['component:', 'widget:'],
147
- },
148
- };
149
-
150
- const result = parseCommitLabels(commit, config);
151
-
152
- expect(result.components).toEqual(['Button', 'Slider']);
153
- });
154
-
155
- it('should trim whitespace from component values', () => {
156
- const commit = createCommit({ labels: ['component: Button '] });
157
-
158
- const result = parseCommitLabels(commit, baseLabelConfig);
159
-
160
- expect(result.components).toEqual(['Button']);
161
- });
162
- });
163
-
164
- describe('plan parsing', () => {
165
- it('should parse plan label', () => {
166
- const commit = createCommit({ labels: ['plan: pro'] });
167
-
168
- const result = parseCommitLabels(commit, baseLabelConfig);
169
-
170
- expect(result.plan).toBe('pro');
171
- });
172
-
173
- it('should normalize plan value to lowercase', () => {
174
- const commit = createCommit({ labels: ['plan: PRO'] });
175
-
176
- const result = parseCommitLabels(commit, baseLabelConfig);
177
-
178
- expect(result.plan).toBe('pro');
179
- });
180
-
181
- it('should only accept configured plan values', () => {
182
- const commit = createCommit({ labels: ['plan: enterprise'] });
183
-
184
- const result = parseCommitLabels(commit, baseLabelConfig);
185
-
186
- expect(result.plan).toBeUndefined();
187
- });
188
-
189
- it('should accept plan values from config', () => {
190
- const commit = createCommit({ labels: ['plan: enterprise'] });
191
- const config: LabelConfig = {
192
- plan: {
193
- values: ['pro', 'premium', 'enterprise'],
194
- },
195
- };
196
-
197
- const result = parseCommitLabels(commit, config);
198
-
199
- expect(result.plan).toBe('enterprise');
200
- });
201
-
202
- it('should use the last plan label when multiple are present', () => {
203
- const commit = createCommit({ labels: ['plan: pro', 'plan: premium'] });
204
-
205
- const result = parseCommitLabels(commit, baseLabelConfig);
206
-
207
- expect(result.plan).toBe('premium');
208
- });
209
- });
210
-
211
- describe('category overrides', () => {
212
- it('should detect category override labels', () => {
213
- const commit = createCommit({ labels: ['scope: all components'] });
214
- const config: LabelConfig = {
215
- ...baseLabelConfig,
216
- categoryOverrides: {
217
- 'scope: all components': 'General changes',
218
- },
219
- };
220
-
221
- const result = parseCommitLabels(commit, config);
222
-
223
- expect(result.categoryOverride).toBe('General changes');
224
- });
225
-
226
- it('should use the last category override when multiple are present', () => {
227
- const commit = createCommit({ labels: ['scope: all components', 'docs'] });
228
- const config: LabelConfig = {
229
- ...baseLabelConfig,
230
- categoryOverrides: {
231
- 'scope: all components': 'General changes',
232
- docs: 'Documentation',
233
- },
234
- };
235
-
236
- const result = parseCommitLabels(commit, config);
237
-
238
- expect(result.categoryOverride).toBe('Documentation');
239
- });
240
-
241
- it('should not set categoryOverride when no matching labels', () => {
242
- const commit = createCommit({ labels: ['scope: core'] });
243
- const config: LabelConfig = {
244
- ...baseLabelConfig,
245
- categoryOverrides: {
246
- 'scope: all components': 'General changes',
247
- },
248
- };
249
-
250
- const result = parseCommitLabels(commit, config);
251
-
252
- expect(result.categoryOverride).toBeUndefined();
253
- });
254
- });
255
-
256
- describe('flags parsing', () => {
257
- it('should parse configured flag labels', () => {
258
- const commit = createCommit({ labels: ['breaking change', 'enhancement'] });
259
- const config: LabelConfig = {
260
- ...baseLabelConfig,
261
- flags: {
262
- 'breaking change': { name: 'Breaking' },
263
- enhancement: { name: 'Enhancement' },
264
- },
265
- };
266
-
267
- const result = parseCommitLabels(commit, config);
268
-
269
- expect(result.flags).toEqual(['breaking change', 'enhancement']);
270
- });
271
-
272
- it('should only include explicitly configured flags', () => {
273
- const commit = createCommit({ labels: ['breaking change', 'random-label', 'bug'] });
274
- const config: LabelConfig = {
275
- ...baseLabelConfig,
276
- flags: {
277
- 'breaking change': { name: 'Breaking' },
278
- bug: { name: 'Bug fix' },
279
- },
280
- };
281
-
282
- const result = parseCommitLabels(commit, config);
283
-
284
- expect(result.flags).toEqual(['breaking change', 'bug']);
285
- });
286
-
287
- it('should return empty flags array when no flags configured', () => {
288
- const commit = createCommit({ labels: ['breaking change'] });
289
-
290
- const result = parseCommitLabels(commit, baseLabelConfig);
291
-
292
- expect(result.flags).toEqual([]);
293
- });
294
-
295
- it('should return empty flags array when flags config is empty object', () => {
296
- const commit = createCommit({ labels: ['breaking change'] });
297
- const config: LabelConfig = {
298
- ...baseLabelConfig,
299
- flags: {},
300
- };
301
-
302
- const result = parseCommitLabels(commit, config);
303
-
304
- expect(result.flags).toEqual([]);
305
- });
306
- });
307
-
308
- describe('extractLabelsFromTitle', () => {
309
- it('should extract labels from commit title', () => {
310
- const commit = createCommit({ message: '[core] Fix bug in Button', labels: [] });
311
- const config: LabelConfig = {
312
- ...baseLabelConfig,
313
- extractLabelsFromTitle: (title) => {
314
- const match = title.match(/^\[([^\]]+)\]/);
315
- return match ? [`scope: ${match[1]}`] : [];
316
- },
317
- };
318
-
319
- const result = parseCommitLabels(commit, config);
320
-
321
- expect(result.scopes).toEqual(['core']);
322
- expect(commit.labels).toContain('scope: core');
323
- });
324
-
325
- it('should merge extracted labels with existing labels', () => {
326
- const commit = createCommit({
327
- message: '[charts] Add new feature',
328
- labels: ['enhancement'],
329
- });
330
- const config: LabelConfig = {
331
- ...baseLabelConfig,
332
- extractLabelsFromTitle: (title) => {
333
- const match = title.match(/^\[([^\]]+)\]/);
334
- return match ? [`scope: ${match[1]}`] : [];
335
- },
336
- };
337
-
338
- const result = parseCommitLabels(commit, config);
339
-
340
- expect(result.scopes).toEqual(['charts']);
341
- expect(commit.labels).toContain('scope: charts');
342
- expect(commit.labels).toContain('enhancement');
343
- });
344
-
345
- it('should deduplicate labels when extracting from title', () => {
346
- const commit = createCommit({
347
- message: '[core] Fix bug',
348
- labels: ['scope: core'],
349
- });
350
- const config: LabelConfig = {
351
- ...baseLabelConfig,
352
- extractLabelsFromTitle: (title) => {
353
- const match = title.match(/^\[([^\]]+)\]/);
354
- return match ? [`scope: ${match[1]}`] : [];
355
- },
356
- };
357
-
358
- parseCommitLabels(commit, config);
359
-
360
- const scopeLabels = commit.labels.filter((l) => l === 'scope: core');
361
- expect(scopeLabels).toHaveLength(1);
362
- });
363
-
364
- it('should use only first line of commit message for title extraction', () => {
365
- const commit = createCommit({
366
- message: '[core] Fix bug\n\nThis is a longer description with [charts] mentioned',
367
- labels: [],
368
- });
369
- const config: LabelConfig = {
370
- ...baseLabelConfig,
371
- extractLabelsFromTitle: (title) => {
372
- const matches = title.match(/\[([^\]]+)\]/g);
373
- return matches ? matches.map((m) => `scope: ${m.slice(1, -1)}`) : [];
374
- },
375
- };
376
-
377
- const result = parseCommitLabels(commit, config);
378
-
379
- expect(result.scopes).toEqual(['core']);
380
- });
381
-
382
- it('should handle extractLabelsFromTitle returning empty array', () => {
383
- const commit = createCommit({ message: 'Fix bug without scope', labels: ['enhancement'] });
384
- const config: LabelConfig = {
385
- ...baseLabelConfig,
386
- extractLabelsFromTitle: () => [],
387
- };
388
-
389
- parseCommitLabels(commit, config);
390
-
391
- expect(commit.labels).toEqual(['enhancement']);
392
- });
393
-
394
- it('should not call extractLabelsFromTitle if not a function', () => {
395
- const commit = createCommit({ message: '[core] Fix bug', labels: [] });
396
- const config: LabelConfig = {
397
- ...baseLabelConfig,
398
- // extractLabelsFromTitle not defined
399
- };
400
-
401
- const result = parseCommitLabels(commit, config);
402
-
403
- expect(result.scopes).toEqual([]);
404
- expect(commit.labels).toEqual([]);
405
- });
406
- });
407
-
408
- describe('combined parsing', () => {
409
- it('should parse all label types together', () => {
410
- const commit = createCommit({
411
- labels: [
412
- 'scope: data-grid',
413
- 'component: DataGrid',
414
- 'plan: pro',
415
- 'breaking change',
416
- 'enhancement',
417
- ],
418
- });
419
- const config: LabelConfig = {
420
- ...baseLabelConfig,
421
- flags: {
422
- 'breaking change': { name: 'Breaking' },
423
- enhancement: { name: 'Enhancement' },
424
- },
425
- };
426
-
427
- const result = parseCommitLabels(commit, config);
428
-
429
- expect(result.scopes).toEqual(['data-grid']);
430
- expect(result.components).toEqual(['DataGrid']);
431
- expect(result.plan).toBe('pro');
432
- expect(result.flags).toEqual(['breaking change', 'enhancement']);
433
- });
434
-
435
- it('should handle complex real-world label combinations', () => {
436
- const commit = createCommit({
437
- message: '[data-grid] Fix row selection bug',
438
- labels: [
439
- 'scope: data-grid',
440
- 'component: DataGrid',
441
- 'plan: premium',
442
- 'bug',
443
- 'breaking change',
444
- ],
445
- });
446
- const config: LabelConfig = {
447
- plan: {
448
- values: ['pro', 'premium'],
449
- },
450
- flags: {
451
- bug: { name: 'Bug fix' },
452
- 'breaking change': { name: 'Breaking', prefix: '💥 ' },
453
- },
454
- extractLabelsFromTitle: (title) => {
455
- const match = title.match(/^\[([^\]]+)\]/);
456
- return match ? [`scope: ${match[1]}`] : [];
457
- },
458
- };
459
-
460
- const result = parseCommitLabels(commit, config);
461
-
462
- expect(result.scopes).toEqual(['data-grid']);
463
- expect(result.components).toEqual(['DataGrid']);
464
- expect(result.plan).toBe('premium');
465
- expect(result.flags).toEqual(['bug', 'breaking change']);
466
- });
467
- });
468
-
469
- describe('edge cases', () => {
470
- it('should handle labels with colons in the value', () => {
471
- const commit = createCommit({ labels: ['scope: foo:bar'] });
472
-
473
- const result = parseCommitLabels(commit, baseLabelConfig);
474
-
475
- expect(result.scopes).toEqual(['foo:bar']);
476
- });
477
-
478
- it('should handle empty string labels', () => {
479
- const commit = createCommit({ labels: ['', 'scope: core'] });
480
-
481
- const result = parseCommitLabels(commit, baseLabelConfig);
482
-
483
- expect(result.scopes).toEqual(['core']);
484
- });
485
-
486
- it('should handle scope prefix without value', () => {
487
- const commit = createCommit({ labels: ['scope:'] });
488
-
489
- const result = parseCommitLabels(commit, baseLabelConfig);
490
-
491
- expect(result.scopes).toEqual(['']);
492
- });
493
-
494
- it('should mutate the original commit labels array when extracting from title', () => {
495
- const commit = createCommit({ message: '[core] Fix bug', labels: [] });
496
- const config: LabelConfig = {
497
- ...baseLabelConfig,
498
- extractLabelsFromTitle: (title) => {
499
- const match = title.match(/^\[([^\]]+)\]/);
500
- return match ? [`scope: ${match[1]}`] : [];
501
- },
502
- };
503
-
504
- parseCommitLabels(commit, config);
505
-
506
- expect(commit.labels).toEqual(['scope: core']);
507
- });
508
- });
509
- });