@mui/internal-code-infra 0.0.4-canary.7 → 0.0.4-canary.70

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 (120) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +19 -8
  3. package/build/babel-config.d.mts +11 -3
  4. package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
  5. package/build/brokenLinksChecker/index.d.mts +45 -2
  6. package/build/changelog/types.d.ts +1 -1
  7. package/build/cli/cmdArgosPush.d.mts +2 -2
  8. package/build/cli/cmdBuild.d.mts +3 -2
  9. package/build/cli/cmdCopyFiles.d.mts +2 -2
  10. package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
  11. package/build/cli/cmdGenerateChangelog.d.mts +2 -2
  12. package/build/cli/cmdGithubAuth.d.mts +2 -2
  13. package/build/cli/cmdListWorkspaces.d.mts +6 -4
  14. package/build/cli/cmdNetlifyIgnore.d.mts +3 -2
  15. package/build/cli/cmdPublish.d.mts +4 -2
  16. package/build/cli/cmdPublishCanary.d.mts +3 -3
  17. package/build/cli/cmdPublishNewPackage.d.mts +4 -2
  18. package/build/cli/cmdSetVersionOverrides.d.mts +2 -2
  19. package/build/cli/cmdVale.d.mts +46 -0
  20. package/build/cli/cmdValidateBuiltTypes.d.mts +2 -2
  21. package/build/eslint/baseConfig.d.mts +3 -1
  22. package/build/eslint/mui/rules/disallow-react-api-in-server-components.d.mts +2 -2
  23. package/build/eslint/mui/rules/docgen-ignore-before-comment.d.mts +2 -2
  24. package/build/eslint/mui/rules/no-floating-cleanup.d.mts +5 -0
  25. package/build/eslint/mui/rules/no-guarded-throw.d.mts +31 -0
  26. package/build/eslint/mui/rules/no-presentation-role.d.mts +5 -0
  27. package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +2 -2
  28. package/build/eslint/mui/rules/nodeEnvUtils.d.mts +18 -0
  29. package/build/remark/config.d.mts +43 -0
  30. package/build/remark/createLintTester.d.mts +10 -0
  31. package/build/remark/firstBlockHeading.d.mts +4 -0
  32. package/build/remark/gitDiff.d.mts +2 -0
  33. package/build/remark/noSpaceInLinks.d.mts +2 -0
  34. package/build/remark/straightQuotes.d.mts +2 -0
  35. package/build/remark/tableAlignment.d.mts +2 -0
  36. package/build/remark/terminalLanguage.d.mts +2 -0
  37. package/build/utils/babel.d.mts +1 -1
  38. package/build/utils/build.d.mts +56 -37
  39. package/build/utils/github.d.mts +1 -1
  40. package/build/utils/pnpm.d.mts +81 -2
  41. package/build/utils/testUtils.d.mts +7 -0
  42. package/build/utils/typescript.d.mts +6 -16
  43. package/package.json +60 -38
  44. package/src/babel-config.mjs +9 -3
  45. package/src/brokenLinksChecker/__fixtures__/static-site/index.html +1 -0
  46. package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +15 -0
  47. package/src/brokenLinksChecker/crawlWorker.mjs +217 -0
  48. package/src/brokenLinksChecker/index.mjs +263 -188
  49. package/src/brokenLinksChecker/index.test.ts +50 -13
  50. package/src/changelog/categorizeCommits.test.ts +5 -5
  51. package/src/changelog/fetchChangelogs.mjs +6 -2
  52. package/src/changelog/parseCommitLabels.test.ts +5 -5
  53. package/src/changelog/renderChangelog.mjs +1 -1
  54. package/src/changelog/types.ts +1 -1
  55. package/src/cli/cmdBuild.mjs +51 -85
  56. package/src/cli/cmdListWorkspaces.mjs +12 -27
  57. package/src/cli/cmdNetlifyIgnore.mjs +34 -93
  58. package/src/cli/cmdPublish.mjs +55 -15
  59. package/src/cli/cmdPublishCanary.mjs +128 -132
  60. package/src/cli/cmdPublishNewPackage.mjs +27 -6
  61. package/src/cli/cmdSetVersionOverrides.mjs +8 -9
  62. package/src/cli/cmdVale.mjs +513 -0
  63. package/src/cli/cmdVale.test.mjs +644 -0
  64. package/src/cli/index.mjs +2 -0
  65. package/src/cli/packageJson.d.ts +1 -1
  66. package/src/eslint/baseConfig.mjs +51 -19
  67. package/src/eslint/docsConfig.mjs +2 -1
  68. package/src/eslint/mui/config.mjs +22 -3
  69. package/src/eslint/mui/index.mjs +6 -0
  70. package/src/eslint/mui/rules/no-floating-cleanup.mjs +187 -0
  71. package/src/eslint/mui/rules/no-floating-cleanup.test.mjs +141 -0
  72. package/src/eslint/mui/rules/no-guarded-throw.mjs +115 -0
  73. package/src/eslint/mui/rules/no-guarded-throw.test.mjs +206 -0
  74. package/src/eslint/mui/rules/no-presentation-role.mjs +60 -0
  75. package/src/eslint/mui/rules/no-presentation-role.test.mjs +33 -0
  76. package/src/eslint/mui/rules/nodeEnvUtils.mjs +52 -0
  77. package/src/eslint/mui/rules/require-dev-wrapper.mjs +25 -40
  78. package/src/estree-typescript.d.ts +1 -1
  79. package/src/remark/config.mjs +157 -0
  80. package/src/remark/createLintTester.mjs +19 -0
  81. package/src/remark/firstBlockHeading.mjs +87 -0
  82. package/src/remark/firstBlockHeading.test.mjs +107 -0
  83. package/src/remark/gitDiff.mjs +43 -0
  84. package/src/remark/gitDiff.test.mjs +45 -0
  85. package/src/remark/noSpaceInLinks.mjs +42 -0
  86. package/src/remark/noSpaceInLinks.test.mjs +22 -0
  87. package/src/remark/straightQuotes.mjs +31 -0
  88. package/src/remark/straightQuotes.test.mjs +25 -0
  89. package/src/remark/tableAlignment.mjs +23 -0
  90. package/src/remark/tableAlignment.test.mjs +28 -0
  91. package/src/remark/terminalLanguage.mjs +19 -0
  92. package/src/remark/terminalLanguage.test.mjs +17 -0
  93. package/src/untyped-plugins.d.ts +11 -11
  94. package/src/utils/build.mjs +604 -270
  95. package/src/utils/build.test.mjs +1079 -521
  96. package/src/utils/git.mjs +16 -7
  97. package/src/utils/pnpm.mjs +255 -3
  98. package/src/utils/pnpm.test.mjs +731 -0
  99. package/src/utils/testUtils.mjs +18 -0
  100. package/src/utils/typescript.mjs +23 -42
  101. package/src/utils/typescript.test.mjs +234 -273
  102. package/vale/.vale.ini +1 -0
  103. package/vale/styles/MUI/CorrectReferenceAllCases.yml +43 -0
  104. package/vale/styles/MUI/CorrectRererenceCased.yml +14 -0
  105. package/vale/styles/MUI/GoogleLatin.yml +11 -0
  106. package/vale/styles/MUI/MuiBrandName.yml +22 -0
  107. package/vale/styles/MUI/NoBritish.yml +112 -0
  108. package/vale/styles/MUI/NoCompanyName.yml +17 -0
  109. package/build/markdownlint/duplicate-h1.d.mts +0 -56
  110. package/build/markdownlint/git-diff.d.mts +0 -11
  111. package/build/markdownlint/index.d.mts +0 -52
  112. package/build/markdownlint/straight-quotes.d.mts +0 -11
  113. package/build/markdownlint/table-alignment.d.mts +0 -11
  114. package/build/markdownlint/terminal-language.d.mts +0 -11
  115. package/src/markdownlint/duplicate-h1.mjs +0 -69
  116. package/src/markdownlint/git-diff.mjs +0 -31
  117. package/src/markdownlint/index.mjs +0 -62
  118. package/src/markdownlint/straight-quotes.mjs +0 -26
  119. package/src/markdownlint/table-alignment.mjs +0 -42
  120. package/src/markdownlint/terminal-language.mjs +0 -19
@@ -0,0 +1,18 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as os from 'node:os';
3
+ import * as path from 'node:path';
4
+ import { onTestFinished } from 'vitest';
5
+
6
+ /**
7
+ * Creates a temporary directory and registers an `onTestFinished` hook to
8
+ * remove it automatically when the current test ends — even if the test throws.
9
+ *
10
+ * @returns {Promise<string>} The path of the created temporary directory.
11
+ */
12
+ export async function makeTempDir() {
13
+ const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'code-infra-test-'));
14
+ onTestFinished(async () => {
15
+ await fs.rm(tmpDir, { recursive: true, force: true });
16
+ });
17
+ return tmpDir;
18
+ }
@@ -111,30 +111,21 @@ export async function copyDeclarations(sourceDirectory, destinationDirectory, op
111
111
  * @param {Object} param0
112
112
  * @param {string} param0.inputDir
113
113
  * @param {string} param0.buildDir
114
- * @param {{type: import('../utils/build.mjs').BundleType, dir: string}[]} param0.bundles
115
- * @param {boolean} [param0.isFlat]
114
+ * @param {import('../utils/build.mjs').BundleType[]} param0.bundles
116
115
  * @param {'module' | 'commonjs'} [param0.packageType]
117
116
  * @returns
118
117
  */
119
- export async function moveAndTransformDeclarations({
120
- inputDir,
121
- buildDir,
122
- bundles,
123
- isFlat,
124
- packageType,
125
- }) {
126
- // Directly copy to the bundle directory if there's only one bundle, mainly for esm, since
127
- // the js files are inside 'esm' folder. resolve-imports plugin needs d.ts to be alongside js files to
128
- // resolve paths correctly.
129
- const toCopyDir = bundles.length === 1 ? path.join(buildDir, bundles[0].dir) : buildDir;
130
- await fs.cp(inputDir, toCopyDir, {
118
+ export async function moveAndTransformDeclarations({ inputDir, buildDir, bundles, packageType }) {
119
+ // d.ts files sit alongside the js files in the build root so the resolve-imports
120
+ // plugin can resolve paths correctly.
121
+ await fs.cp(inputDir, buildDir, {
131
122
  recursive: true,
132
123
  force: false,
133
124
  });
134
125
 
135
- const dtsFiles = await globby('**/*.d.ts', { absolute: true, cwd: toCopyDir });
126
+ const dtsFiles = await globby('**/*.d.ts', { absolute: true, cwd: buildDir });
136
127
  if (dtsFiles.length === 0) {
137
- console.log(`No d.ts files found in ${toCopyDir}. Skipping transformation.`);
128
+ console.log(`No d.ts files found in ${buildDir}. Skipping transformation.`);
138
129
  return;
139
130
  }
140
131
 
@@ -144,37 +135,30 @@ export async function moveAndTransformDeclarations({
144
135
  // Normalize to native separators to make path comparisons reliable on Windows
145
136
  const nativeDtsFile = path.normalize(dtsFile);
146
137
  const content = await fs.readFile(nativeDtsFile, 'utf8');
147
- const relativePath = path.relative(toCopyDir, nativeDtsFile);
138
+ const relativePath = path.relative(buildDir, nativeDtsFile);
148
139
 
149
- const writesToOriginalPath =
150
- isFlat &&
151
- bundles.some((bundle) => {
152
- const newFileExtension = getOutExtension(bundle.type, {
153
- isFlat,
154
- isType: true,
155
- packageType,
156
- });
157
- const outFileRelative = relativePath.replace(/\.d\.ts$/, newFileExtension);
158
- const outFilePath = path.join(buildDir, bundle.dir, outFileRelative);
159
- // Ensure both paths are normalized before comparison (fixes Windows posix vs win32 separators)
160
- return path.resolve(outFilePath) === path.resolve(nativeDtsFile);
140
+ const writesToOriginalPath = bundles.some((bundle) => {
141
+ const newFileExtension = getOutExtension(bundle, {
142
+ isType: true,
143
+ packageType,
161
144
  });
145
+ const outFileRelative = relativePath.replace(/\.d\.ts$/, newFileExtension);
146
+ const outFilePath = path.join(buildDir, outFileRelative);
147
+ // Ensure both paths are normalized before comparison (fixes Windows posix vs win32 separators)
148
+ return path.resolve(outFilePath) === path.resolve(nativeDtsFile);
149
+ });
162
150
 
163
151
  await Promise.all(
164
152
  bundles.map(async (bundle) => {
165
- const importExtension = getOutExtension(bundle.type, {
166
- isFlat,
153
+ const importExtension = getOutExtension(bundle, {
167
154
  packageType,
168
155
  });
169
- const newFileExtension = getOutExtension(bundle.type, {
170
- isFlat,
156
+ const newFileExtension = getOutExtension(bundle, {
171
157
  isType: true,
172
158
  packageType,
173
159
  });
174
- const outFileRelative = isFlat
175
- ? relativePath.replace(/\.d\.ts$/, newFileExtension)
176
- : relativePath;
177
- const outFilePath = path.join(buildDir, bundle.dir, outFileRelative);
160
+ const outFileRelative = relativePath.replace(/\.d\.ts$/, newFileExtension);
161
+ const outFilePath = path.join(buildDir, outFileRelative);
178
162
 
179
163
  const babelPlugins = [
180
164
  [pluginTypescriptSyntax, { dts: true }],
@@ -194,7 +178,7 @@ export async function moveAndTransformDeclarations({
194
178
  }
195
179
  }),
196
180
  );
197
- if (isFlat && !writesToOriginalPath) {
181
+ if (!writesToOriginalPath) {
198
182
  await fs.unlink(nativeDtsFile);
199
183
  }
200
184
  },
@@ -208,9 +192,8 @@ export async function moveAndTransformDeclarations({
208
192
  * After copying, babel transformations are applied to the copied files because they need to be alongside the actual js files for proper resolution.
209
193
  *
210
194
  * @param {Object} param0
211
- * @param {boolean} [param0.isFlat = false] - Whether to place generated declaration files in a flattened directory.
212
195
  * @param {boolean} [param0.verbose = false] - Whether to log additional information while generating and moving declaration files.
213
- * @param {{type: import('../utils/build.mjs').BundleType, dir: string}[]} param0.bundles - The bundles to create declarations for.
196
+ * @param {import('../utils/build.mjs').BundleType[]} param0.bundles - The bundles to create declarations for.
214
197
  * @param {string} param0.srcDir - The source directory.
215
198
  * @param {string} param0.buildDir - The build directory.
216
199
  * @param {string} param0.cwd - The current working directory.
@@ -225,7 +208,6 @@ export async function createTypes({
225
208
  cwd,
226
209
  skipTsc,
227
210
  useTsgo = false,
228
- isFlat = false,
229
211
  packageType,
230
212
  verbose,
231
213
  }) {
@@ -253,7 +235,6 @@ export async function createTypes({
253
235
  inputDir: tmpDir,
254
236
  buildDir,
255
237
  bundles,
256
- isFlat,
257
238
  packageType,
258
239
  });
259
240
  } finally {