@mui/internal-code-infra 0.0.4-canary.49 → 0.0.4-canary.50
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.4-canary.
|
|
3
|
+
"version": "0.0.4-canary.50",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"publishConfig": {
|
|
192
192
|
"access": "public"
|
|
193
193
|
},
|
|
194
|
-
"gitSha": "
|
|
194
|
+
"gitSha": "4c409b3d174cfefb32e4a3fe633f9aa46f53bce3",
|
|
195
195
|
"scripts": {
|
|
196
196
|
"build": "tsgo -p tsconfig.build.json",
|
|
197
197
|
"typescript": "tsgo -noEmit",
|
|
@@ -162,9 +162,14 @@ if (pageData.status < 200 || pageData.status >= 400) {
|
|
|
162
162
|
|
|
163
163
|
// HTML validation. Every entry whose path matches contributes to the
|
|
164
164
|
// page's config: each is registered as a synthetic preset and the page's
|
|
165
|
-
// root config `extends`
|
|
166
|
-
//
|
|
167
|
-
//
|
|
165
|
+
// root config `extends` `mui:recommended` first, then the matched presets
|
|
166
|
+
// in order. When override configs do not specify their own `extends`,
|
|
167
|
+
// they behave as pure rule patches layered on top of `mui:recommended`,
|
|
168
|
+
// so a later entry can only change the rules it names directly. Override
|
|
169
|
+
// configs are passed through as-is, though, so an entry that declares its
|
|
170
|
+
// own `extends` can still pull in additional presets (including
|
|
171
|
+
// `mui:recommended`) and affect earlier downgrades. html-validate merges
|
|
172
|
+
// `extends` left to right.
|
|
168
173
|
/** @type {{ pageUrl: string, results: import('html-validate').Result[] } | null} */
|
|
169
174
|
let htmlValidateResults = null;
|
|
170
175
|
if (type === 'text/html' && options.htmlValidate.length > 0) {
|
|
@@ -192,7 +197,7 @@ if (pageData.status < 200 || pageData.status >= 400) {
|
|
|
192
197
|
|
|
193
198
|
const htmlValidator = new HtmlValidate(
|
|
194
199
|
new StaticConfigLoader([muiHtmlValidateResolver], {
|
|
195
|
-
extends: Object.keys(overridePresets),
|
|
200
|
+
extends: ['mui:recommended', ...Object.keys(overridePresets)],
|
|
196
201
|
}),
|
|
197
202
|
);
|
|
198
203
|
|
|
@@ -351,7 +351,7 @@ function shouldIgnoreLink(link, ignores) {
|
|
|
351
351
|
* @property {number} [concurrency] - Number of concurrent page fetches (defaults to 4)
|
|
352
352
|
* @property {string[]} [seedUrls] - Starting URLs for the crawl (defaults to ['/'])
|
|
353
353
|
* @property {IgnoreRule[]} [ignores] - Rules to ignore broken links. Each rule can have path, href, contentType, and/or has properties. All specified properties must match (AND logic). Within a property, multiple values use OR logic.
|
|
354
|
-
* @property {HtmlValidateOption} [htmlValidate] - Enable HTML validation on crawled pages. `false` (default): disabled. `true`: validate with recommended rules. Object: use as html-validate config — `
|
|
354
|
+
* @property {HtmlValidateOption} [htmlValidate] - Enable HTML validation on crawled pages. `false` (default): disabled. `true`: validate with recommended rules. Object: use as html-validate config — `mui:recommended` is always applied as the baseline, so most callers only need to set `rules`. Array: per-path config overrides — `mui:recommended` is applied once as the baseline and every entry whose `path` matches the page URL is layered on top; later matching entries win on conflicting rule keys. If an entry omits `extends`, it behaves like a rule patch and typically only changes the rules it names. If an entry includes `extends` (for example, re-extending `mui:recommended`), it can re-introduce or reset baseline presets rather than acting as a pure patch. An entry without `path` matches every page. If no entry matches, the page is not validated.
|
|
355
355
|
* @property {boolean} [verbose] - Log extra diagnostics during crawling (e.g. resolved html-validate config per page). Defaults to `false`.
|
|
356
356
|
*/
|
|
357
357
|
|
|
@@ -392,17 +392,19 @@ function validateIgnoreRule(rule) {
|
|
|
392
392
|
|
|
393
393
|
/**
|
|
394
394
|
* Normalizes a single config value to a non-null html-validate config object.
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
395
|
+
* Each config is registered as a pure rule patch; `mui:recommended` is pulled
|
|
396
|
+
* in once by the page's root config (ahead of every patch), so callers only
|
|
397
|
+
* need to specify the `rules` they want to change and never restate the
|
|
398
|
+
* recommended ruleset. `true` means "recommended only" (an empty patch). An
|
|
399
|
+
* explicit `extends` is still honored if a caller wants extra presets.
|
|
398
400
|
* @param {true | import('html-validate').ConfigData} config
|
|
399
401
|
* @returns {import('html-validate').ConfigData}
|
|
400
402
|
*/
|
|
401
403
|
function normalizeHtmlValidateConfig(config) {
|
|
402
404
|
if (config === true) {
|
|
403
|
-
return {
|
|
405
|
+
return {};
|
|
404
406
|
}
|
|
405
|
-
return
|
|
407
|
+
return config;
|
|
406
408
|
}
|
|
407
409
|
|
|
408
410
|
/**
|
|
@@ -64,12 +64,18 @@ describe('Broken Links Checker', () => {
|
|
|
64
64
|
],
|
|
65
65
|
// Exercise the array form with union semantics: every matching entry
|
|
66
66
|
// contributes to the page's config. The baseline entry (no `path`)
|
|
67
|
-
// turns off `no-
|
|
68
|
-
//
|
|
67
|
+
// turns off `no-dup-id` everywhere; the path-specific entry turns off
|
|
68
|
+
// `no-raw-characters` only on /invalid-html.html. Both rules are
|
|
69
69
|
// silenced on that page because the configs are merged, not replaced.
|
|
70
|
+
//
|
|
71
|
+
// This also guards against the path-specific entry clobbering the
|
|
72
|
+
// baseline: the path entry only names `no-raw-characters`, so it must
|
|
73
|
+
// not re-introduce the recommended ruleset and re-enable the
|
|
74
|
+
// `no-dup-id` that the baseline silenced (which /invalid-html.html
|
|
75
|
+
// violates). If it did, that page would report `no-dup-id` below.
|
|
70
76
|
htmlValidate: [
|
|
71
|
-
{ config: { rules: { 'no-
|
|
72
|
-
{ path: '/invalid-html.html', config: { rules: { 'no-
|
|
77
|
+
{ config: { rules: { 'no-dup-id': 'off' } } },
|
|
78
|
+
{ path: '/invalid-html.html', config: { rules: { 'no-raw-characters': 'off' } } },
|
|
73
79
|
],
|
|
74
80
|
});
|
|
75
81
|
|
|
@@ -277,9 +283,10 @@ describe('Broken Links Checker', () => {
|
|
|
277
283
|
expect(result.pages.get('/')?.contentType).toBe('text/html');
|
|
278
284
|
|
|
279
285
|
// Test htmlValidate union semantics: invalid-html.html has both a duplicate
|
|
280
|
-
// ID (no-dup-id) and a raw `&` (no-raw-characters). The
|
|
281
|
-
//
|
|
282
|
-
// Under union semantics both apply, so the page reports zero issues
|
|
286
|
+
// ID (no-dup-id) and a raw `&` (no-raw-characters). The baseline entry
|
|
287
|
+
// silences no-dup-id; the path-specific entry silences no-raw-characters.
|
|
288
|
+
// Under union semantics both apply, so the page reports zero issues — and
|
|
289
|
+
// the path-specific entry must not clobber the baseline's no-dup-id.
|
|
283
290
|
const htmlValidateIssues = result.issues.filter(
|
|
284
291
|
(issue): issue is HtmlValidateIssue => issue.type === 'html-validate',
|
|
285
292
|
);
|