@mui/internal-code-infra 0.0.4-canary.4 → 0.0.4-canary.41
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/README.md +19 -8
- package/build/babel-config.d.mts +11 -3
- package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
- package/build/brokenLinksChecker/index.d.mts +45 -2
- package/build/changelog/types.d.ts +1 -1
- package/build/cli/cmdArgosPush.d.mts +2 -2
- package/build/cli/cmdBuild.d.mts +2 -2
- package/build/cli/cmdCopyFiles.d.mts +2 -2
- package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
- package/build/cli/cmdGenerateChangelog.d.mts +2 -2
- package/build/cli/cmdGithubAuth.d.mts +2 -2
- package/build/cli/cmdListWorkspaces.d.mts +4 -2
- package/build/cli/cmdNetlifyIgnore.d.mts +2 -2
- package/build/cli/cmdPublish.d.mts +4 -2
- package/build/cli/cmdPublishCanary.d.mts +3 -2
- package/build/cli/cmdPublishNewPackage.d.mts +4 -2
- package/build/cli/cmdSetVersionOverrides.d.mts +2 -2
- package/build/cli/cmdVale.d.mts +46 -0
- package/build/cli/cmdValidateBuiltTypes.d.mts +2 -2
- package/build/eslint/baseConfig.d.mts +3 -1
- package/build/eslint/mui/rules/disallow-react-api-in-server-components.d.mts +2 -2
- package/build/eslint/mui/rules/docgen-ignore-before-comment.d.mts +2 -2
- package/build/eslint/mui/rules/no-guarded-throw.d.mts +31 -0
- package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +2 -2
- package/build/eslint/mui/rules/nodeEnvUtils.d.mts +18 -0
- package/build/markdownlint/duplicate-h1.d.mts +1 -1
- package/build/markdownlint/git-diff.d.mts +1 -1
- package/build/markdownlint/index.d.mts +1 -1
- package/build/markdownlint/straight-quotes.d.mts +1 -1
- package/build/markdownlint/table-alignment.d.mts +1 -1
- package/build/markdownlint/terminal-language.d.mts +1 -1
- package/build/remark/config.d.mts +43 -0
- package/build/remark/createLintTester.d.mts +10 -0
- package/build/remark/firstBlockHeading.d.mts +4 -0
- package/build/remark/gitDiff.d.mts +2 -0
- package/build/remark/noSpaceInLinks.d.mts +2 -0
- package/build/remark/straightQuotes.d.mts +2 -0
- package/build/remark/tableAlignment.d.mts +2 -0
- package/build/remark/terminalLanguage.d.mts +2 -0
- package/build/utils/build.d.mts +3 -3
- package/build/utils/github.d.mts +1 -1
- package/build/utils/pnpm.d.mts +68 -2
- package/build/utils/testUtils.d.mts +7 -0
- package/package.json +59 -32
- package/src/babel-config.mjs +9 -3
- package/src/brokenLinksChecker/__fixtures__/static-site/index.html +1 -0
- package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +15 -0
- package/src/brokenLinksChecker/crawlWorker.mjs +212 -0
- package/src/brokenLinksChecker/index.mjs +215 -164
- package/src/brokenLinksChecker/index.test.ts +43 -13
- package/src/changelog/categorizeCommits.test.ts +5 -5
- package/src/changelog/fetchChangelogs.mjs +6 -2
- package/src/changelog/parseCommitLabels.test.ts +5 -5
- package/src/changelog/renderChangelog.mjs +1 -1
- package/src/changelog/types.ts +1 -1
- package/src/cli/cmdListWorkspaces.mjs +9 -2
- package/src/cli/cmdNetlifyIgnore.mjs +4 -88
- package/src/cli/cmdPublish.mjs +51 -14
- package/src/cli/cmdPublishCanary.mjs +139 -107
- package/src/cli/cmdPublishNewPackage.mjs +27 -6
- package/src/cli/cmdVale.mjs +513 -0
- package/src/cli/cmdVale.test.mjs +644 -0
- package/src/cli/index.mjs +2 -0
- package/src/eslint/baseConfig.mjs +45 -20
- package/src/eslint/docsConfig.mjs +2 -1
- package/src/eslint/jsonConfig.mjs +2 -1
- package/src/eslint/mui/config.mjs +20 -1
- package/src/eslint/mui/index.mjs +2 -0
- package/src/eslint/mui/rules/no-guarded-throw.mjs +115 -0
- package/src/eslint/mui/rules/no-guarded-throw.test.mjs +206 -0
- package/src/eslint/mui/rules/nodeEnvUtils.mjs +52 -0
- package/src/eslint/mui/rules/require-dev-wrapper.mjs +25 -40
- package/src/eslint/testConfig.mjs +2 -1
- package/src/estree-typescript.d.ts +1 -1
- package/src/remark/config.mjs +157 -0
- package/src/remark/createLintTester.mjs +19 -0
- package/src/remark/firstBlockHeading.mjs +87 -0
- package/src/remark/firstBlockHeading.test.mjs +107 -0
- package/src/remark/gitDiff.mjs +43 -0
- package/src/remark/gitDiff.test.mjs +45 -0
- package/src/remark/noSpaceInLinks.mjs +42 -0
- package/src/remark/noSpaceInLinks.test.mjs +22 -0
- package/src/remark/straightQuotes.mjs +31 -0
- package/src/remark/straightQuotes.test.mjs +25 -0
- package/src/remark/tableAlignment.mjs +23 -0
- package/src/remark/tableAlignment.test.mjs +28 -0
- package/src/remark/terminalLanguage.mjs +19 -0
- package/src/remark/terminalLanguage.test.mjs +17 -0
- package/src/untyped-plugins.d.ts +11 -11
- package/src/utils/build.test.mjs +546 -575
- package/src/utils/pnpm.mjs +192 -3
- package/src/utils/pnpm.test.mjs +580 -0
- package/src/utils/testUtils.mjs +18 -0
- package/src/utils/typescript.test.mjs +249 -272
- package/vale/.vale.ini +1 -0
- package/vale/styles/MUI/CorrectReferenceAllCases.yml +43 -0
- package/vale/styles/MUI/CorrectRererenceCased.yml +14 -0
- package/vale/styles/MUI/GoogleLatin.yml +11 -0
- package/vale/styles/MUI/MuiBrandName.yml +22 -0
- package/vale/styles/MUI/NoBritish.yml +112 -0
- package/vale/styles/MUI/NoCompanyName.yml +17 -0
package/build/utils/pnpm.d.mts
CHANGED
|
@@ -31,6 +31,7 @@ export type GetWorkspacePackagesOptions = {
|
|
|
31
31
|
publicOnly?: boolean;
|
|
32
32
|
nonPublishedOnly?: boolean;
|
|
33
33
|
cwd?: string;
|
|
34
|
+
filter?: string[];
|
|
34
35
|
};
|
|
35
36
|
export declare function getWorkspacePackages(options?: {
|
|
36
37
|
publicOnly: true;
|
|
@@ -49,13 +50,78 @@ export declare function getWorkspacePackages(options?: GetWorkspacePackagesOptio
|
|
|
49
50
|
* @returns {Promise<VersionInfo>} Version information
|
|
50
51
|
*/
|
|
51
52
|
export declare function getPackageVersionInfo(packageName: string, baseVersion: string): Promise<VersionInfo>;
|
|
53
|
+
export type PublishSummaryEntry = {
|
|
54
|
+
name: string;
|
|
55
|
+
version: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @typedef {Object} PublishSummaryEntry
|
|
59
|
+
* @property {string} name
|
|
60
|
+
* @property {string} version
|
|
61
|
+
*/
|
|
52
62
|
/**
|
|
53
63
|
* Publish packages with the given options
|
|
54
64
|
* @param {PublicPackage[]} packages - Packages to publish
|
|
55
65
|
* @param {PublishOptions} [options={}] - Publishing options
|
|
56
|
-
* @returns {Promise<
|
|
66
|
+
* @returns {Promise<PublishSummaryEntry[]>}
|
|
67
|
+
*/
|
|
68
|
+
export declare function publishPackages(packages: PublicPackage[], options?: PublishOptions): Promise<PublishSummaryEntry[]>;
|
|
69
|
+
export type GetTransitiveDependenciesOptions = {
|
|
70
|
+
workspacePathByName?: Map<string, string>;
|
|
71
|
+
includeDev?: boolean;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* @typedef {Object} GetTransitiveDependenciesOptions
|
|
75
|
+
* @property {Map<string, string>} [workspacePathByName] - Map of workspace package name to directory path
|
|
76
|
+
* @property {boolean} [includeDev=true] - Whether to include devDependencies in the traversal
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Get all transitive workspace dependencies for a set of packages.
|
|
80
|
+
*
|
|
81
|
+
* Only follows deps whose version spec starts with `workspace:` (e.g. `workspace:*`
|
|
82
|
+
* or `workspace:^`), meaning they are sourced directly from the monorepo. Pinned
|
|
83
|
+
* external versions (e.g. `^1.0.0`) are ignored even when the package name exists
|
|
84
|
+
* in the workspace. Traverses `dependencies` and optionally `devDependencies`.
|
|
85
|
+
* Results are cached per package so each package is read from disk at most once
|
|
86
|
+
* regardless of how many roots depend on it.
|
|
87
|
+
*
|
|
88
|
+
* @param {string[]} packageNames - Package names to start the traversal from
|
|
89
|
+
* @param {GetTransitiveDependenciesOptions} [options]
|
|
90
|
+
* @returns {Promise<Set<string>>} All reachable workspace package names, including the input packages themselves
|
|
91
|
+
*/
|
|
92
|
+
export declare function getTransitiveDependencies(packageNames: string[], options?: GetTransitiveDependenciesOptions): Promise<Set<string>>;
|
|
93
|
+
/**
|
|
94
|
+
* Pure validation logic: given a publish set and workspace maps, checks that all
|
|
95
|
+
* transitive hard workspace dependencies are covered and none are private.
|
|
96
|
+
*
|
|
97
|
+
* A hard dependency is one listed in `dependencies` (not `peerDependencies` or
|
|
98
|
+
* `devDependencies`) using a `workspace:` version specifier (e.g. `workspace:*` or
|
|
99
|
+
* `workspace:^`). Peer dependencies are never bundled and dev dependencies are not installed
|
|
100
|
+
* on consumer devices - both are excluded regardless of version specifier. Pinned-version
|
|
101
|
+
* references in `dependencies` are also excluded - they resolve from the registry and do
|
|
102
|
+
* not need to be co-published.
|
|
103
|
+
*
|
|
104
|
+
* @param {PublicPackage[]} packages - The packages intended for publishing
|
|
105
|
+
* @param {Map<string, PublicPackage | PrivatePackage>} workspacePackageByName - All workspace packages by name
|
|
106
|
+
* @param {Map<string, string>} workspacePathByName - Map of workspace package name to directory path
|
|
107
|
+
* @returns {Promise<{issues: string[]}>}
|
|
108
|
+
* List of human-readable issue strings. Empty when the dependency set is valid.
|
|
109
|
+
* @internal
|
|
110
|
+
*/
|
|
111
|
+
export declare function checkPublishDependencies(packages: PublicPackage[], workspacePackageByName: Map<string, PublicPackage | PrivatePackage>, workspacePathByName: Map<string, string>): Promise<{
|
|
112
|
+
issues: string[];
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Validate that a set of packages covers all of their transitive hard workspace dependencies,
|
|
116
|
+
* and that none of those dependencies are private (which would make them unpublishable).
|
|
117
|
+
*
|
|
118
|
+
* @param {PublicPackage[]} packages - The packages intended for publishing
|
|
119
|
+
* @returns {Promise<{issues: string[]}>}
|
|
120
|
+
* List of human-readable issue strings. Empty when the dependency set is valid.
|
|
57
121
|
*/
|
|
58
|
-
export declare function
|
|
122
|
+
export declare function validatePublishDependencies(packages: PublicPackage[]): Promise<{
|
|
123
|
+
issues: string[];
|
|
124
|
+
}>;
|
|
59
125
|
/**
|
|
60
126
|
* Read package.json from a directory
|
|
61
127
|
* @param {string} packagePath - Path to package directory
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a temporary directory and registers an `onTestFinished` hook to
|
|
3
|
+
* remove it automatically when the current test ends — even if the test throws.
|
|
4
|
+
*
|
|
5
|
+
* @returns {Promise<string>} The path of the created temporary directory.
|
|
6
|
+
*/
|
|
7
|
+
export declare function makeTempDir(): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.4-canary.
|
|
3
|
+
"version": "0.0.4-canary.41",
|
|
4
|
+
"author": "MUI Team",
|
|
4
5
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
5
|
-
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "git+https://github.com/mui/mui-public.git",
|
|
@@ -32,6 +33,10 @@
|
|
|
32
33
|
"types": "./build/markdownlint/index.d.mts",
|
|
33
34
|
"default": "./src/markdownlint/index.mjs"
|
|
34
35
|
},
|
|
36
|
+
"./remark": {
|
|
37
|
+
"types": "./build/remark/config.d.mts",
|
|
38
|
+
"default": "./src/remark/config.mjs"
|
|
39
|
+
},
|
|
35
40
|
"./prettier": {
|
|
36
41
|
"types": "./build/prettier.d.mts",
|
|
37
42
|
"default": "./src/prettier.mjs"
|
|
@@ -52,28 +57,29 @@
|
|
|
52
57
|
"code-infra": "./bin/code-infra.mjs"
|
|
53
58
|
},
|
|
54
59
|
"dependencies": {
|
|
55
|
-
"@argos-ci/core": "^
|
|
60
|
+
"@argos-ci/core": "^5.2.0",
|
|
56
61
|
"@babel/cli": "^7.28.6",
|
|
57
62
|
"@babel/core": "^7.29.0",
|
|
58
63
|
"@babel/plugin-syntax-jsx": "^7.28.6",
|
|
59
64
|
"@babel/plugin-syntax-typescript": "^7.28.6",
|
|
60
65
|
"@babel/plugin-transform-runtime": "^7.29.0",
|
|
61
|
-
"@babel/preset-env": "^7.29.
|
|
66
|
+
"@babel/preset-env": "^7.29.2",
|
|
62
67
|
"@babel/preset-react": "^7.28.5",
|
|
63
68
|
"@babel/preset-typescript": "^7.28.5",
|
|
64
|
-
"@eslint/compat": "^2.0.
|
|
69
|
+
"@eslint/compat": "^2.0.3",
|
|
70
|
+
"@eslint/config-helpers": "^0.5.4",
|
|
65
71
|
"@eslint/js": "^10.0.1",
|
|
66
|
-
"@eslint/json": "^1.0
|
|
67
|
-
"@inquirer/confirm": "^6.0.
|
|
68
|
-
"@inquirer/select": "^5.
|
|
72
|
+
"@eslint/json": "^1.1.0",
|
|
73
|
+
"@inquirer/confirm": "^6.0.11",
|
|
74
|
+
"@inquirer/select": "^5.1.3",
|
|
69
75
|
"@napi-rs/keyring": "^1.2.0",
|
|
70
76
|
"@octokit/auth-action": "^6.0.2",
|
|
71
77
|
"@octokit/oauth-methods": "^6.0.2",
|
|
72
78
|
"@octokit/rest": "^22.0.1",
|
|
73
|
-
"@pnpm/find-workspace-dir": "^1000.1.
|
|
74
|
-
"@typescript-eslint/types": "^8.
|
|
75
|
-
"@typescript-eslint/utils": "^8.
|
|
76
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
79
|
+
"@pnpm/find-workspace-dir": "^1000.1.5",
|
|
80
|
+
"@typescript-eslint/types": "^8.57.1",
|
|
81
|
+
"@typescript-eslint/utils": "^8.57.1",
|
|
82
|
+
"@vitest/eslint-plugin": "^1.6.11",
|
|
77
83
|
"babel-plugin-optimize-clsx": "^2.6.2",
|
|
78
84
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
79
85
|
"babel-plugin-transform-import-meta": "^2.3.3",
|
|
@@ -81,44 +87,61 @@
|
|
|
81
87
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
82
88
|
"babel-plugin-transform-remove-imports": "^1.8.1",
|
|
83
89
|
"chalk": "^5.6.2",
|
|
84
|
-
"clipboardy": "^5.3.
|
|
90
|
+
"clipboardy": "^5.3.1",
|
|
85
91
|
"content-type": "^1.0.5",
|
|
86
92
|
"env-ci": "^11.2.0",
|
|
93
|
+
"es-toolkit": "^1.45.1",
|
|
87
94
|
"eslint-config-prettier": "^10.1.8",
|
|
88
95
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
89
96
|
"eslint-module-utils": "^2.12.1",
|
|
90
|
-
"eslint-plugin-compat": "^
|
|
97
|
+
"eslint-plugin-compat": "^7.0.1",
|
|
91
98
|
"eslint-plugin-import": "^2.32.0",
|
|
92
99
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
100
|
+
"eslint-plugin-mdx": "^3.7.0",
|
|
93
101
|
"eslint-plugin-mocha": "^11.2.0",
|
|
94
102
|
"eslint-plugin-react": "^7.37.5",
|
|
95
103
|
"eslint-plugin-react-compiler": "^19.1.0-rc.2",
|
|
96
104
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
97
105
|
"eslint-plugin-testing-library": "^7.16.0",
|
|
98
|
-
"es-toolkit": "^1.44.0",
|
|
99
106
|
"execa": "^9.6.1",
|
|
100
107
|
"git-url-parse": "^16.1.0",
|
|
101
|
-
"globals": "^
|
|
102
|
-
"globby": "^16.
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
108
|
+
"globals": "^17.5.0",
|
|
109
|
+
"globby": "^16.2.0",
|
|
110
|
+
"html-validate": "^10.13.0",
|
|
111
|
+
"minimatch": "^10.2.5",
|
|
112
|
+
"node-html-parser": "^7.1.0",
|
|
113
|
+
"open": "^11.0.0",
|
|
106
114
|
"postcss-styled-syntax": "^0.7.1",
|
|
107
115
|
"regexp.escape": "^2.0.1",
|
|
108
116
|
"rehype-slug": "^6.0.0",
|
|
109
117
|
"rehype-stringify": "^10.0.1",
|
|
118
|
+
"remark-frontmatter": "^5.0.0",
|
|
110
119
|
"remark-gfm": "^4.0.1",
|
|
120
|
+
"remark-lint": "^10.0.1",
|
|
121
|
+
"remark-lint-code-block-style": "^4.0.1",
|
|
122
|
+
"remark-lint-fenced-code-flag": "^4.2.0",
|
|
123
|
+
"remark-lint-heading-increment": "^4.0.1",
|
|
124
|
+
"remark-lint-heading-style": "^4.0.1",
|
|
125
|
+
"remark-lint-no-duplicate-headings": "^4.0.1",
|
|
126
|
+
"remark-lint-no-empty-url": "^4.0.1",
|
|
127
|
+
"remark-lint-no-heading-punctuation": "^4.0.1",
|
|
128
|
+
"remark-lint-no-multiple-toplevel-headings": "^4.0.1",
|
|
129
|
+
"remark-lint-no-undefined-references": "^5.0.2",
|
|
130
|
+
"remark-lint-no-unused-definitions": "^4.0.2",
|
|
131
|
+
"remark-lint-table-pipes": "^5.0.1",
|
|
111
132
|
"remark-parse": "^11.0.0",
|
|
112
133
|
"remark-rehype": "^11.1.2",
|
|
113
134
|
"resolve-pkg-maps": "^1.0.0",
|
|
114
135
|
"semver": "^7.7.4",
|
|
115
136
|
"stylelint-config-standard": "^40.0.0",
|
|
116
|
-
"typescript-eslint": "^8.
|
|
137
|
+
"typescript-eslint": "^8.57.1",
|
|
117
138
|
"unified": "^11.0.5",
|
|
139
|
+
"unified-lint-rule": "^3.0.1",
|
|
140
|
+
"unist-util-visit": "^5.1.0",
|
|
118
141
|
"yargs": "^18.0.0",
|
|
119
|
-
"@mui/internal-babel-plugin-display-name": "1.0.4-canary.
|
|
120
|
-
"@mui/internal-babel-plugin-
|
|
121
|
-
"@mui/internal-babel-plugin-
|
|
142
|
+
"@mui/internal-babel-plugin-display-name": "1.0.4-canary.19",
|
|
143
|
+
"@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.36",
|
|
144
|
+
"@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.27"
|
|
122
145
|
},
|
|
123
146
|
"peerDependencies": {
|
|
124
147
|
"@next/eslint-plugin-next": "*",
|
|
@@ -144,27 +167,31 @@
|
|
|
144
167
|
"@types/eslint-plugin-jsx-a11y": "6.10.1",
|
|
145
168
|
"@types/estree": "1.0.8",
|
|
146
169
|
"@types/estree-jsx": "1.0.5",
|
|
170
|
+
"@types/mdast": "4.0.4",
|
|
147
171
|
"@types/regexp.escape": "2.0.0",
|
|
148
172
|
"@types/yargs": "17.0.35",
|
|
149
|
-
"@typescript-eslint/parser": "8.
|
|
150
|
-
"@typescript-eslint/rule-tester": "8.
|
|
151
|
-
"eslint": "10.0.
|
|
152
|
-
"get-port": "7.
|
|
153
|
-
"prettier": "3.8.
|
|
154
|
-
"
|
|
155
|
-
"
|
|
173
|
+
"@typescript-eslint/parser": "8.57.1",
|
|
174
|
+
"@typescript-eslint/rule-tester": "8.57.1",
|
|
175
|
+
"eslint": "10.0.3",
|
|
176
|
+
"get-port": "7.2.0",
|
|
177
|
+
"prettier": "3.8.3",
|
|
178
|
+
"remark": "^15.0.1",
|
|
179
|
+
"remark-mdx": "^3.1.1",
|
|
180
|
+
"serve": "14.2.6",
|
|
181
|
+
"typescript-eslint": "8.57.1"
|
|
156
182
|
},
|
|
157
183
|
"files": [
|
|
158
184
|
"bin",
|
|
159
185
|
"build",
|
|
160
186
|
"src",
|
|
187
|
+
"vale",
|
|
161
188
|
"README.md",
|
|
162
189
|
"LICENSE"
|
|
163
190
|
],
|
|
164
191
|
"publishConfig": {
|
|
165
192
|
"access": "public"
|
|
166
193
|
},
|
|
167
|
-
"gitSha": "
|
|
194
|
+
"gitSha": "23110663aef8376c78c86ae4c6ee8f54c9f8c9ea",
|
|
168
195
|
"scripts": {
|
|
169
196
|
"build": "tsgo -p tsconfig.build.json",
|
|
170
197
|
"typescript": "tsgo -noEmit",
|
package/src/babel-config.mjs
CHANGED
|
@@ -10,6 +10,10 @@ import pluginTransformImportMeta from 'babel-plugin-transform-import-meta';
|
|
|
10
10
|
import pluginTransformInlineEnvVars from 'babel-plugin-transform-inline-environment-variables';
|
|
11
11
|
import pluginRemovePropTypes from 'babel-plugin-transform-react-remove-prop-types';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {'annotation' | 'syntax' | 'infer' | 'all'} ReactCompilationMode
|
|
15
|
+
*/
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* @param {Object} param0
|
|
15
19
|
* @param {boolean} [param0.debug]
|
|
@@ -20,7 +24,8 @@ import pluginRemovePropTypes from 'babel-plugin-transform-react-remove-prop-type
|
|
|
20
24
|
* @param {string | null} param0.outExtension - Specify the output file extension.
|
|
21
25
|
* @param {string} param0.runtimeVersion
|
|
22
26
|
* @param {string} [param0.reactCompilerReactVersion]
|
|
23
|
-
* @param {
|
|
27
|
+
* @param {ReactCompilationMode} [param0.reactCompilerMode]
|
|
28
|
+
* @param {{ allowedCallees?: Record<string, string[]> }} [param0.displayName] - Options for the display name plugin.
|
|
24
29
|
* @returns {import('@babel/core').TransformOptions} The base Babel configuration.
|
|
25
30
|
*/
|
|
26
31
|
export function getBaseConfig({
|
|
@@ -33,6 +38,7 @@ export function getBaseConfig({
|
|
|
33
38
|
outExtension,
|
|
34
39
|
reactCompilerReactVersion,
|
|
35
40
|
reactCompilerMode,
|
|
41
|
+
displayName,
|
|
36
42
|
}) {
|
|
37
43
|
/**
|
|
38
44
|
* @type {import('@babel/preset-env').Options}
|
|
@@ -57,7 +63,7 @@ export function getBaseConfig({
|
|
|
57
63
|
},
|
|
58
64
|
'@babel/plugin-transform-runtime',
|
|
59
65
|
],
|
|
60
|
-
[pluginDisplayName, {}, '@mui/internal-babel-plugin-display-name'],
|
|
66
|
+
[pluginDisplayName, { ...displayName }, '@mui/internal-babel-plugin-display-name'],
|
|
61
67
|
[
|
|
62
68
|
pluginTransformInlineEnvVars,
|
|
63
69
|
{
|
|
@@ -183,6 +189,6 @@ export default function getBabelConfig(api) {
|
|
|
183
189
|
removePropTypes: process.env.MUI_REMOVE_PROP_TYPES === 'true',
|
|
184
190
|
noResolveImports,
|
|
185
191
|
reactCompilerReactVersion: process.env.MUI_REACT_COMPILER_REACT_VERSION,
|
|
186
|
-
reactCompilerMode: process.env.MUI_REACT_COMPILER_MODE,
|
|
192
|
+
reactCompilerMode: /** @type {ReactCompilationMode} */ (process.env.MUI_REACT_COMPILER_MODE),
|
|
187
193
|
});
|
|
188
194
|
}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
<li><a href="/page-with-api-links.html">Page with API Links</a></li>
|
|
23
23
|
<li><a href="/example.md">Example Markdown</a></li>
|
|
24
24
|
<li><a href="/unclosed-tags.html">Page with Unclosed Tags</a></li>
|
|
25
|
+
<li><a href="/invalid-html.html">Invalid HTML Page</a></li>
|
|
25
26
|
</ul>
|
|
26
27
|
</nav>
|
|
27
28
|
</body>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>Invalid HTML Page</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h1>Invalid HTML</h1>
|
|
9
|
+
<!-- Duplicate ID (violates no-duplicate-id rule) -->
|
|
10
|
+
<div id="dup">First</div>
|
|
11
|
+
<div id="dup">Second</div>
|
|
12
|
+
<!-- Raw ampersand (violates no-raw-characters rule) -->
|
|
13
|
+
<p>Tom & Jerry</p>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { workerData, parentPort } from 'node:worker_threads';
|
|
2
|
+
import { parse } from 'node-html-parser';
|
|
3
|
+
import contentType from 'content-type';
|
|
4
|
+
import { HtmlValidate, StaticConfigLoader, staticResolver } from 'html-validate';
|
|
5
|
+
import { unified } from 'unified';
|
|
6
|
+
import remarkParse from 'remark-parse';
|
|
7
|
+
import remarkGfm from 'remark-gfm';
|
|
8
|
+
import remarkRehype from 'remark-rehype';
|
|
9
|
+
import rehypeSlug from 'rehype-slug';
|
|
10
|
+
import rehypeStringify from 'rehype-stringify';
|
|
11
|
+
|
|
12
|
+
/** @type {import('./index.mjs').CrawlWorkerInput} */
|
|
13
|
+
const { pageUrl, options } = workerData;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Tests if a value matches any of the patterns in the array.
|
|
17
|
+
* Returns true if patterns is undefined/empty (wildcard behavior).
|
|
18
|
+
* Strings use exact match, RegExp uses .test().
|
|
19
|
+
* @param {string} value
|
|
20
|
+
* @param {(string | RegExp)[] | undefined} patterns
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
function matchesAnyPattern(value, patterns) {
|
|
24
|
+
if (!patterns || patterns.length === 0) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return patterns.some((pattern) =>
|
|
28
|
+
typeof pattern === 'string' ? value === pattern : pattern.test(value),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Posts the crawl result back to the parent thread.
|
|
34
|
+
* @param {import('./index.mjs').CrawlWorkerOutput} output
|
|
35
|
+
*/
|
|
36
|
+
function postResult(output) {
|
|
37
|
+
if (!parentPort) {
|
|
38
|
+
throw new Error('crawlWorker must be run as a worker thread');
|
|
39
|
+
}
|
|
40
|
+
parentPort.postMessage(output);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Computes the accessible name of an element according to ARIA rules.
|
|
45
|
+
* @param {import('node-html-parser').HTMLElement | null} elm
|
|
46
|
+
* @param {import('node-html-parser').HTMLElement} ownerDocument
|
|
47
|
+
* @returns {string}
|
|
48
|
+
*/
|
|
49
|
+
function getAccessibleName(elm, ownerDocument) {
|
|
50
|
+
if (!elm) {
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const ariaLabel = elm.getAttribute('aria-label')?.trim();
|
|
55
|
+
if (ariaLabel) {
|
|
56
|
+
return ariaLabel;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const labelledby = elm.getAttribute('aria-labelledby');
|
|
60
|
+
if (labelledby) {
|
|
61
|
+
const labels = [];
|
|
62
|
+
for (const id of labelledby.split(/\s+/)) {
|
|
63
|
+
const label = getAccessibleName(ownerDocument.getElementById(id), ownerDocument);
|
|
64
|
+
if (label) {
|
|
65
|
+
labels.push(label);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const label = labels.join(' ').trim();
|
|
69
|
+
if (label) {
|
|
70
|
+
return label;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (elm.id) {
|
|
75
|
+
const label = ownerDocument.querySelector(`label[for="${elm.id}"]`);
|
|
76
|
+
if (label) {
|
|
77
|
+
return getAccessibleName(label, ownerDocument);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (elm.tagName === 'IMG') {
|
|
82
|
+
const alt = elm.getAttribute('alt')?.trim();
|
|
83
|
+
if (alt) {
|
|
84
|
+
return alt;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return elm.innerText.trim();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Converts markdown content to HTML using unified pipeline.
|
|
93
|
+
* @param {string} markdown
|
|
94
|
+
* @returns {Promise<string>}
|
|
95
|
+
*/
|
|
96
|
+
async function markdownToHtml(markdown) {
|
|
97
|
+
const result = await unified()
|
|
98
|
+
.use(remarkParse)
|
|
99
|
+
.use(remarkGfm)
|
|
100
|
+
.use(remarkRehype)
|
|
101
|
+
.use(rehypeSlug)
|
|
102
|
+
.use(rehypeStringify)
|
|
103
|
+
.process(markdown);
|
|
104
|
+
return String(result);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const res = await fetch(new URL(pageUrl, options.host));
|
|
108
|
+
|
|
109
|
+
const contentTypeHeader = res.headers.get('content-type');
|
|
110
|
+
let type = 'text/html';
|
|
111
|
+
|
|
112
|
+
if (contentTypeHeader) {
|
|
113
|
+
try {
|
|
114
|
+
const parsed = contentType.parse(contentTypeHeader);
|
|
115
|
+
type = parsed.type;
|
|
116
|
+
} catch {
|
|
117
|
+
// invalid content-type, default to text/html
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** @type {import('./index.mjs').CrawlWorkerPageData} */
|
|
122
|
+
const pageData = {
|
|
123
|
+
url: pageUrl,
|
|
124
|
+
status: res.status,
|
|
125
|
+
targets: [],
|
|
126
|
+
contentType: type,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
if (pageData.status < 200 || pageData.status >= 400) {
|
|
130
|
+
postResult({ pageData, links: [], htmlValidateResults: null });
|
|
131
|
+
} else if (type.startsWith('image/') || (type !== 'text/html' && type !== 'text/markdown')) {
|
|
132
|
+
postResult({ pageData, links: [], htmlValidateResults: null });
|
|
133
|
+
} else {
|
|
134
|
+
const rawContent = await res.text();
|
|
135
|
+
|
|
136
|
+
const content = type === 'text/markdown' ? await markdownToHtml(rawContent) : rawContent;
|
|
137
|
+
|
|
138
|
+
const dom = parse(content, { parseNoneClosedTags: true });
|
|
139
|
+
|
|
140
|
+
// Extract targets
|
|
141
|
+
for (const target of dom.querySelectorAll('*[id]')) {
|
|
142
|
+
if (!options.ignoredTargets.has(target.id)) {
|
|
143
|
+
pageData.targets.push(`#${target.id}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Extract links
|
|
148
|
+
let ignoredSelector = ':not(*)';
|
|
149
|
+
if (options.ignoredContent.length > 0) {
|
|
150
|
+
ignoredSelector = Array.from(options.ignoredContent)
|
|
151
|
+
.flatMap((selector) => [selector, `${selector} *`])
|
|
152
|
+
.join(',');
|
|
153
|
+
}
|
|
154
|
+
const linksSelector = `a[href]:not(${ignoredSelector})`;
|
|
155
|
+
|
|
156
|
+
const links = dom.querySelectorAll(linksSelector).map((a) => ({
|
|
157
|
+
src: pageUrl,
|
|
158
|
+
text: getAccessibleName(a, dom),
|
|
159
|
+
href: a.getAttribute('href') ?? '',
|
|
160
|
+
contentType: type,
|
|
161
|
+
}));
|
|
162
|
+
|
|
163
|
+
// HTML validation. Every entry whose path matches contributes to the
|
|
164
|
+
// page's config: each is registered as a synthetic preset and the page's
|
|
165
|
+
// root config `extends` them in order. html-validate's own resolution then
|
|
166
|
+
// merges them, so callers can layer path-specific overrides on top of a
|
|
167
|
+
// baseline entry without re-stating the baseline rules.
|
|
168
|
+
/** @type {{ pageUrl: string, results: import('html-validate').Result[] } | null} */
|
|
169
|
+
let htmlValidateResults = null;
|
|
170
|
+
if (type === 'text/html' && options.htmlValidate.length > 0) {
|
|
171
|
+
const matchedEntries = options.htmlValidate.filter((entry) =>
|
|
172
|
+
matchesAnyPattern(pageUrl, entry.path),
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
if (matchedEntries.length > 0) {
|
|
176
|
+
const overridePresets = Object.fromEntries(
|
|
177
|
+
matchedEntries.map((entry, index) => [`mui:override-${index}`, entry.config]),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const muiHtmlValidateResolver = staticResolver({
|
|
181
|
+
configs: {
|
|
182
|
+
'mui:recommended': {
|
|
183
|
+
extends: ['html-validate:standard', 'html-validate:document', 'html-validate:browser'],
|
|
184
|
+
rules: {
|
|
185
|
+
// TODO: Enable when subresource integrity is adopted across projects
|
|
186
|
+
'require-sri': 'off',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
...overridePresets,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const htmlValidator = new HtmlValidate(
|
|
194
|
+
new StaticConfigLoader([muiHtmlValidateResolver], {
|
|
195
|
+
extends: Object.keys(overridePresets),
|
|
196
|
+
}),
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
if (options.verbose) {
|
|
200
|
+
const resolved = await htmlValidator.getConfigFor(pageUrl);
|
|
201
|
+
console.warn(
|
|
202
|
+
`[html-validate config] ${pageUrl}\n${JSON.stringify(resolved.getConfigData(), null, 2)}`,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const report = await htmlValidator.validateString(rawContent, pageUrl);
|
|
207
|
+
htmlValidateResults = { pageUrl, results: report.results };
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
postResult({ pageData, links, htmlValidateResults });
|
|
212
|
+
}
|