@mui/internal-code-infra 0.0.4-canary.10 → 0.0.4-canary.101
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/LICENSE +1 -1
- package/README.md +21 -7
- package/build/babel-config.d.mts +5 -1
- package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
- package/build/brokenLinksChecker/index.d.mts +192 -2
- package/build/changelog/fetchChangelogs.d.mts +3 -0
- package/build/changelog/types.d.ts +3 -1
- package/build/cli/cmdArgosPush.d.mts +8 -2
- package/build/cli/cmdBuild.d.mts +48 -2
- package/build/cli/cmdCopyFiles.d.mts +14 -2
- package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
- package/build/cli/cmdGenerateChangelog.d.mts +17 -2
- package/build/cli/cmdGithubAuth.d.mts +2 -2
- package/build/cli/cmdListWorkspaces.d.mts +14 -2
- package/build/cli/cmdNetlifyIgnore.d.mts +12 -2
- package/build/cli/cmdPublish.d.mts +23 -4
- package/build/cli/cmdPublishCanary.d.mts +20 -2
- package/build/cli/cmdPublishNewPackage.d.mts +10 -2
- package/build/cli/cmdRenameScope.d.mts +18 -0
- package/build/cli/cmdSetVersionOverrides.d.mts +5 -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-floating-cleanup.d.mts +5 -0
- package/build/eslint/mui/rules/no-guarded-throw.d.mts +31 -0
- package/build/eslint/mui/rules/no-presentation-role.d.mts +5 -0
- package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +8 -2
- package/build/eslint/mui/rules/nodeEnvUtils.d.mts +18 -0
- 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/babel.d.mts +7 -1
- package/build/utils/build.d.mts +59 -37
- package/build/utils/extractErrorCodes.d.mts +9 -0
- package/build/utils/git.d.mts +16 -0
- package/build/utils/github.d.mts +13 -1
- package/build/utils/pnpm.d.mts +226 -20
- package/build/utils/testUtils.d.mts +28 -0
- package/build/utils/typescript.d.mts +6 -16
- package/package.json +79 -53
- package/src/babel-config.mjs +3 -1
- package/src/brokenLinksChecker/crawlWorker.mjs +240 -0
- package/src/brokenLinksChecker/index.mjs +263 -188
- package/src/changelog/fetchChangelogs.mjs +8 -2
- package/src/changelog/renderChangelog.mjs +1 -1
- package/src/changelog/types.ts +3 -1
- package/src/cli/cmdBuild.mjs +53 -88
- package/src/cli/cmdListWorkspaces.mjs +7 -1
- package/src/cli/cmdNetlifyIgnore.mjs +30 -5
- package/src/cli/cmdPublish.mjs +79 -37
- package/src/cli/cmdPublishCanary.mjs +96 -24
- package/src/cli/cmdPublishNewPackage.mjs +31 -8
- package/src/cli/cmdRenameScope.mjs +76 -0
- package/src/cli/cmdSetVersionOverrides.mjs +40 -34
- package/src/cli/cmdVale.mjs +513 -0
- package/src/cli/index.mjs +4 -0
- package/src/cli/packageJson.d.ts +2 -3
- package/src/eslint/baseConfig.mjs +51 -19
- package/src/eslint/docsConfig.mjs +2 -1
- package/src/eslint/mui/config.mjs +24 -4
- package/src/eslint/mui/index.mjs +6 -0
- package/src/eslint/mui/rules/no-floating-cleanup.mjs +187 -0
- package/src/eslint/mui/rules/no-guarded-throw.mjs +115 -0
- package/src/eslint/mui/rules/no-presentation-role.mjs +60 -0
- package/src/eslint/mui/rules/nodeEnvUtils.mjs +52 -0
- package/src/eslint/mui/rules/require-dev-wrapper.mjs +25 -40
- 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/gitDiff.mjs +43 -0
- package/src/remark/noSpaceInLinks.mjs +42 -0
- package/src/remark/straightQuotes.mjs +31 -0
- package/src/remark/tableAlignment.mjs +23 -0
- package/src/remark/terminalLanguage.mjs +19 -0
- package/src/stylelint/index.mjs +2 -2
- package/src/untyped-plugins.d.ts +14 -14
- package/src/utils/build.mjs +604 -270
- package/src/utils/git.mjs +27 -7
- package/src/utils/pnpm.mjs +636 -60
- package/src/utils/testUtils.mjs +53 -0
- package/src/utils/typescript.mjs +23 -42
- package/vale/.vale.ini +1 -0
- package/vale/styles/MUI/CorrectReferenceAllCases.yml +42 -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/markdownlint/duplicate-h1.d.mts +0 -56
- package/build/markdownlint/git-diff.d.mts +0 -11
- package/build/markdownlint/index.d.mts +0 -52
- package/build/markdownlint/straight-quotes.d.mts +0 -11
- package/build/markdownlint/table-alignment.d.mts +0 -11
- package/build/markdownlint/terminal-language.d.mts +0 -11
- package/src/brokenLinksChecker/__fixtures__/static-site/broken-links.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/broken-targets.html +0 -22
- package/src/brokenLinksChecker/__fixtures__/static-site/example.md +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/external-links.html +0 -21
- package/src/brokenLinksChecker/__fixtures__/static-site/ignored-page.html +0 -17
- package/src/brokenLinksChecker/__fixtures__/static-site/index.html +0 -28
- package/src/brokenLinksChecker/__fixtures__/static-site/known-targets.json +0 -5
- package/src/brokenLinksChecker/__fixtures__/static-site/nested/page.html +0 -21
- package/src/brokenLinksChecker/__fixtures__/static-site/orphaned-page.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-api-links.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-custom-targets.html +0 -24
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-ignored-content.html +0 -28
- package/src/brokenLinksChecker/__fixtures__/static-site/page-with-known-target-links.html +0 -19
- package/src/brokenLinksChecker/__fixtures__/static-site/unclosed-tags.html +0 -1
- package/src/brokenLinksChecker/__fixtures__/static-site/valid.html +0 -20
- package/src/brokenLinksChecker/__fixtures__/static-site/with-anchors.html +0 -31
- package/src/brokenLinksChecker/index.test.ts +0 -261
- package/src/changelog/categorizeCommits.test.ts +0 -319
- package/src/changelog/filterCommits.test.ts +0 -363
- package/src/changelog/parseCommitLabels.test.ts +0 -509
- package/src/changelog/renderChangelog.test.ts +0 -378
- package/src/changelog/sortSections.test.ts +0 -199
- package/src/eslint/mui/rules/add-undef-to-optional.test.mjs +0 -361
- package/src/eslint/mui/rules/consistent-production-guard.test.mjs +0 -162
- package/src/eslint/mui/rules/disallow-active-elements-as-key-event-target.test.mjs +0 -66
- package/src/eslint/mui/rules/disallow-react-api-in-server-components.test.mjs +0 -305
- package/src/eslint/mui/rules/docgen-ignore-before-comment.test.mjs +0 -52
- package/src/eslint/mui/rules/flatten-parentheses.test.mjs +0 -245
- package/src/eslint/mui/rules/mui-name-matches-component-name.test.mjs +0 -247
- package/src/eslint/mui/rules/no-empty-box.test.mjs +0 -40
- package/src/eslint/mui/rules/no-styled-box.test.mjs +0 -73
- package/src/eslint/mui/rules/require-dev-wrapper.test.mjs +0 -265
- package/src/eslint/mui/rules/rules-of-use-theme-variants.test.mjs +0 -149
- package/src/eslint/mui/rules/straight-quotes.test.mjs +0 -67
- package/src/markdownlint/duplicate-h1.mjs +0 -69
- package/src/markdownlint/git-diff.mjs +0 -31
- package/src/markdownlint/index.mjs +0 -62
- package/src/markdownlint/straight-quotes.mjs +0 -26
- package/src/markdownlint/table-alignment.mjs +0 -42
- package/src/markdownlint/terminal-language.mjs +0 -19
- package/src/utils/build.test.mjs +0 -705
- package/src/utils/template.test.mjs +0 -133
- package/src/utils/typescript.test.mjs +0 -380
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Test Site Home</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Test Site Home</h1>
|
|
10
|
-
<nav>
|
|
11
|
-
<ul>
|
|
12
|
-
<li><a href="/valid.html">Valid Page</a></li>
|
|
13
|
-
<li><a href="/with-anchors.html">Page with Anchors</a></li>
|
|
14
|
-
<li><a href="/broken-links.html">Page with Broken Links</a></li>
|
|
15
|
-
<li><a href="/broken-targets.html">Page with Broken Targets</a></li>
|
|
16
|
-
<li><a href="/external-links.html">Page with External Links</a></li>
|
|
17
|
-
<li><a href="/nested/page.html">Nested Page</a></li>
|
|
18
|
-
<li><a href="/ignored-page.html">Ignored Page</a></li>
|
|
19
|
-
<li><a href="/page-with-ignored-content.html">Page with Ignored Content</a></li>
|
|
20
|
-
<li><a href="/page-with-custom-targets.html">Page with Custom Targets</a></li>
|
|
21
|
-
<li><a href="/page-with-known-target-links.html">Page with Known Target Links</a></li>
|
|
22
|
-
<li><a href="/page-with-api-links.html">Page with API Links</a></li>
|
|
23
|
-
<li><a href="/example.md">Example Markdown</a></li>
|
|
24
|
-
<li><a href="/unclosed-tags.html">Page with Unclosed Tags</a></li>
|
|
25
|
-
</ul>
|
|
26
|
-
</nav>
|
|
27
|
-
</body>
|
|
28
|
-
</html>
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Nested Page</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Nested Page</h1>
|
|
10
|
-
<p>This is a page in a nested directory.</p>
|
|
11
|
-
<nav>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="/">Home</a></li>
|
|
14
|
-
<li><a href="/valid.html">Valid page</a></li>
|
|
15
|
-
<li><a href="/with-anchors.html#section1">Link to anchor</a></li>
|
|
16
|
-
<li><a href="../valid.html">Relative link to valid page</a></li>
|
|
17
|
-
<li><a href="../broken-relative-html.html">Relative broken link from HTML</a></li>
|
|
18
|
-
</ul>
|
|
19
|
-
</nav>
|
|
20
|
-
</body>
|
|
21
|
-
</html>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Orphaned Page</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Orphaned Page</h1>
|
|
10
|
-
<p>This page is not linked from anywhere and can only be discovered via seedUrls.</p>
|
|
11
|
-
<nav>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="/valid.html">Valid Page</a></li>
|
|
14
|
-
<li><a href="/valid.html/">Valid Page with trailing slash</a></li>
|
|
15
|
-
<li><a href="/orphaned-broken-link.html">Broken link from orphaned page</a></li>
|
|
16
|
-
<li><a href="/example.md">Markdown file with HTML snippet</a></li>
|
|
17
|
-
</ul>
|
|
18
|
-
</nav>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Page with API Links</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Page with API Links</h1>
|
|
10
|
-
<p>This page links to API documentation with known targets.</p>
|
|
11
|
-
<nav>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="/">Home</a></li>
|
|
14
|
-
<li><a href="/api-page.html#method1">API Method 1 (known)</a></li>
|
|
15
|
-
<li><a href="/api-page.html#method2">API Method 2 (known)</a></li>
|
|
16
|
-
<li><a href="/api-page.html#unknown-method">Unknown API method</a></li>
|
|
17
|
-
</ul>
|
|
18
|
-
</nav>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Page with Custom Targets</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Page with Custom Targets</h1>
|
|
10
|
-
<nav>
|
|
11
|
-
<ul>
|
|
12
|
-
<li><a href="/">Home</a></li>
|
|
13
|
-
<li><a href="#custom-id">Link to custom ID</a></li>
|
|
14
|
-
<li><a href="#__should-be-ignored">Link to ignored ID</a></li>
|
|
15
|
-
</ul>
|
|
16
|
-
</nav>
|
|
17
|
-
<section id="custom-id">
|
|
18
|
-
<h2>Custom ID Section</h2>
|
|
19
|
-
</section>
|
|
20
|
-
<section id="__should-be-ignored">
|
|
21
|
-
<h2>This target should be ignored</h2>
|
|
22
|
-
</section>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Page with Ignored Content</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Page with Ignored Content</h1>
|
|
10
|
-
<nav>
|
|
11
|
-
<ul>
|
|
12
|
-
<li><a href="/">Home</a></li>
|
|
13
|
-
</ul>
|
|
14
|
-
</nav>
|
|
15
|
-
<aside class="sidebar">
|
|
16
|
-
<h2>Sidebar (should be ignored)</h2>
|
|
17
|
-
<ul>
|
|
18
|
-
<li><a href="/sidebar-broken-link.html">Broken link in sidebar</a></li>
|
|
19
|
-
</ul>
|
|
20
|
-
</aside>
|
|
21
|
-
<main>
|
|
22
|
-
<p>Main content</p>
|
|
23
|
-
<p>
|
|
24
|
-
<a href="/broken-link-with-sidebar-class.html" class="sidebar">Link with sidebar class directly</a>
|
|
25
|
-
</p>
|
|
26
|
-
</main>
|
|
27
|
-
</body>
|
|
28
|
-
</html>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Page with Known Target Links</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Page with Known Target Links</h1>
|
|
10
|
-
<p>This page links to external pages with known targets.</p>
|
|
11
|
-
<nav>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="/">Home</a></li>
|
|
14
|
-
<li><a href="/external-page.html#valid-target">Valid external target</a></li>
|
|
15
|
-
<li><a href="/external-page.html#invalid-target">Invalid external target</a></li>
|
|
16
|
-
</ul>
|
|
17
|
-
</nav>
|
|
18
|
-
</body>
|
|
19
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Unclosed Tags</title></head><body><div class="wrapper"><main class="content"><a href="/broken-inside-unclosed-main.html">Broken link inside unclosed main</a><a href="/valid.html">Valid link inside unclosed main</a></main></div></body></html>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Valid Page</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Valid Page</h1>
|
|
10
|
-
<p>This page has only valid internal links.</p>
|
|
11
|
-
<nav>
|
|
12
|
-
<ul>
|
|
13
|
-
<li><a href="/">Home</a></li>
|
|
14
|
-
<li><a href="/with-anchors.html#section1">Link to section 1</a></li>
|
|
15
|
-
<li><a href="/with-anchors.html#section2">Link to section 2</a></li>
|
|
16
|
-
<li><a href="/nested/page.html">Nested page</a></li>
|
|
17
|
-
</ul>
|
|
18
|
-
</nav>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Page with Anchors</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<h1>Page with Anchors</h1>
|
|
10
|
-
<nav>
|
|
11
|
-
<ul>
|
|
12
|
-
<li><a href="/">Home</a></li>
|
|
13
|
-
<li><a href="#section1">Jump to section 1</a></li>
|
|
14
|
-
<li><a href="#section2">Jump to section 2</a></li>
|
|
15
|
-
<li><a href="#section3">Jump to section 3</a></li>
|
|
16
|
-
</ul>
|
|
17
|
-
</nav>
|
|
18
|
-
<section id="section1">
|
|
19
|
-
<h2>Section 1</h2>
|
|
20
|
-
<p>Content for section 1</p>
|
|
21
|
-
</section>
|
|
22
|
-
<section id="section2">
|
|
23
|
-
<h2>Section 2</h2>
|
|
24
|
-
<p>Content for section 2</p>
|
|
25
|
-
</section>
|
|
26
|
-
<section id="section3">
|
|
27
|
-
<h2>Section 3</h2>
|
|
28
|
-
<p>Content for section 3</p>
|
|
29
|
-
</section>
|
|
30
|
-
</body>
|
|
31
|
-
</html>
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import getPort from 'get-port';
|
|
3
|
-
import { describe, expect, it } from 'vitest';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line import/extensions
|
|
6
|
-
import { crawl, Issue, Link } from './index.mjs';
|
|
7
|
-
|
|
8
|
-
type ExpectedIssue = Omit<Partial<Issue>, 'link'> & { link?: Partial<Link> };
|
|
9
|
-
|
|
10
|
-
function objectMatchingIssue(expectedIssue: ExpectedIssue) {
|
|
11
|
-
return expect.objectContaining({
|
|
12
|
-
...expectedIssue,
|
|
13
|
-
...(expectedIssue.link ? { link: expect.objectContaining(expectedIssue.link) } : {}),
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Helper to assert that an issue with matching properties exists in the issues array
|
|
19
|
-
*/
|
|
20
|
-
function expectIssue(issues: Issue[], expectedIssue: ExpectedIssue) {
|
|
21
|
-
expect(issues).toEqual(expect.arrayContaining([objectMatchingIssue(expectedIssue)]));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Helper to assert that no issue with matching properties exists in the issues array
|
|
26
|
-
*/
|
|
27
|
-
function expectNotIssue(issues: Issue[], notExpectedIssue: ExpectedIssue) {
|
|
28
|
-
expect(issues).not.toEqual(expect.arrayContaining([objectMatchingIssue(notExpectedIssue)]));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('Broken Links Checker', () => {
|
|
32
|
-
const fixtureDir = path.join(import.meta.dirname, '__fixtures__', 'static-site');
|
|
33
|
-
const servePath = path.join(import.meta.dirname, '..', '..', 'node_modules', '.bin', 'serve');
|
|
34
|
-
|
|
35
|
-
it('should detect all broken links and targets across the entire site', async () => {
|
|
36
|
-
const port = await getPort();
|
|
37
|
-
const host = `http://localhost:${port}`;
|
|
38
|
-
|
|
39
|
-
const result = await crawl({
|
|
40
|
-
startCommand: `${servePath} ${fixtureDir} -p ${port}`,
|
|
41
|
-
host,
|
|
42
|
-
ignoredPaths: [/ignored-page\.html$/],
|
|
43
|
-
ignoredContent: ['.sidebar'],
|
|
44
|
-
ignoredTargets: new Set(['__should-be-ignored']),
|
|
45
|
-
knownTargets: new Map([['/external-page.html', new Set(['#valid-target'])]]),
|
|
46
|
-
knownTargetsDownloadUrl: [`${host}/known-targets.json`],
|
|
47
|
-
seedUrls: ['/', '/orphaned-page.html'],
|
|
48
|
-
// Test ignores with new array syntax and various property combinations
|
|
49
|
-
ignores: [
|
|
50
|
-
// Backward compatible: single values still work
|
|
51
|
-
{ path: '/broken-links.html', href: '/does-not-exist.html' },
|
|
52
|
-
// Test array syntax: multiple hrefs in one rule (OR logic within property)
|
|
53
|
-
{ path: '/broken-links.html', href: [/another-missing/, '../broken-relative-html.html'] },
|
|
54
|
-
// Test contentType: ignore broken links from markdown files
|
|
55
|
-
{ contentType: 'text/markdown', href: '/broken-from-markdown.html' },
|
|
56
|
-
// Test href-only rule (matches from any page) - note: matches the actual href value
|
|
57
|
-
{ href: 'broken-relative.html' },
|
|
58
|
-
],
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(result.links).toHaveLength(66);
|
|
62
|
-
// Issue count: original 11, minus ignored ones (broken-from-markdown via contentType,
|
|
63
|
-
// broken-relative via href-only rule)
|
|
64
|
-
expect(result.issues).toHaveLength(9);
|
|
65
|
-
|
|
66
|
-
// Test ignores: these broken links should be ignored (not in issues)
|
|
67
|
-
expectNotIssue(result.issues, {
|
|
68
|
-
type: 'broken-link',
|
|
69
|
-
link: {
|
|
70
|
-
src: '/broken-links.html',
|
|
71
|
-
href: '/does-not-exist.html',
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
expectNotIssue(result.issues, {
|
|
76
|
-
type: 'broken-link',
|
|
77
|
-
link: {
|
|
78
|
-
src: '/broken-links.html',
|
|
79
|
-
href: '/another-missing-page.html',
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Check broken-target type issues
|
|
84
|
-
expectIssue(result.issues, {
|
|
85
|
-
type: 'broken-target',
|
|
86
|
-
link: {
|
|
87
|
-
src: '/broken-targets.html',
|
|
88
|
-
href: '/with-anchors.html#nonexistent',
|
|
89
|
-
text: 'Non-existent anchor',
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
expectIssue(result.issues, {
|
|
94
|
-
type: 'broken-target',
|
|
95
|
-
link: {
|
|
96
|
-
src: '/broken-targets.html',
|
|
97
|
-
href: '/valid.html#missing-target',
|
|
98
|
-
text: 'Valid page, missing target',
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
expectIssue(result.issues, {
|
|
103
|
-
type: 'broken-target',
|
|
104
|
-
link: {
|
|
105
|
-
src: '/broken-targets.html',
|
|
106
|
-
href: '/with-anchors.html#also-missing',
|
|
107
|
-
text: 'Also missing',
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Verify that valid links are not reported
|
|
112
|
-
expectNotIssue(result.issues, { link: { href: '/' } });
|
|
113
|
-
expectNotIssue(result.issues, { link: { href: '/valid.html' } });
|
|
114
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html' } });
|
|
115
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html#section1' } });
|
|
116
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html#section2' } });
|
|
117
|
-
expectNotIssue(result.issues, { link: { href: '/with-anchors.html#section3' } });
|
|
118
|
-
expectNotIssue(result.issues, { link: { href: '/nested/page.html' } });
|
|
119
|
-
|
|
120
|
-
// Verify that external links are not reported
|
|
121
|
-
expectNotIssue(result.issues, { link: { href: 'https://example.com' } });
|
|
122
|
-
expectNotIssue(result.issues, { link: { href: 'https://github.com/mui' } });
|
|
123
|
-
|
|
124
|
-
// Test ignoredPaths: ignored-page.html should not be crawled
|
|
125
|
-
expectNotIssue(result.issues, { link: { src: '/ignored-page.html' } });
|
|
126
|
-
expectNotIssue(result.issues, { link: { href: '/this-link-should-not-be-checked.html' } });
|
|
127
|
-
|
|
128
|
-
// Test ignoredContent: links in .sidebar should be ignored
|
|
129
|
-
expectNotIssue(result.issues, { link: { href: '/sidebar-broken-link.html' } });
|
|
130
|
-
|
|
131
|
-
// Test ignoredTargets: IDs that shouldn't be tracked as valid link destinations
|
|
132
|
-
// (e.g., framework-specific IDs like '__next'). Links to these should be reported as broken.
|
|
133
|
-
expectIssue(result.issues, {
|
|
134
|
-
type: 'broken-target',
|
|
135
|
-
link: {
|
|
136
|
-
src: '/page-with-custom-targets.html',
|
|
137
|
-
href: '#__should-be-ignored',
|
|
138
|
-
text: 'Link to ignored ID',
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// Test that non-ignored custom target is valid
|
|
143
|
-
expectNotIssue(result.issues, { link: { href: '/page-with-custom-targets.html#custom-id' } });
|
|
144
|
-
|
|
145
|
-
// Test knownTargets: valid-target is known and should not cause issues
|
|
146
|
-
expectNotIssue(result.issues, { link: { href: '/external-page.html#valid-target' } });
|
|
147
|
-
|
|
148
|
-
// Test knownTargets: invalid-target is not in knownTargets and should cause an issue
|
|
149
|
-
expectIssue(result.issues, {
|
|
150
|
-
type: 'broken-target',
|
|
151
|
-
link: {
|
|
152
|
-
src: '/page-with-known-target-links.html',
|
|
153
|
-
href: '/external-page.html#invalid-target',
|
|
154
|
-
text: 'Invalid external target',
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// Test knownTargetsDownloadUrl: method1 and method2 are in downloaded known targets
|
|
159
|
-
expectNotIssue(result.issues, { link: { href: '/api-page.html#method1' } });
|
|
160
|
-
expectNotIssue(result.issues, { link: { href: '/api-page.html#method2' } });
|
|
161
|
-
|
|
162
|
-
// Test knownTargetsDownloadUrl: unknown-method is not in downloaded known targets and should cause an issue
|
|
163
|
-
expectIssue(result.issues, {
|
|
164
|
-
type: 'broken-target',
|
|
165
|
-
link: {
|
|
166
|
-
src: '/page-with-api-links.html',
|
|
167
|
-
href: '/api-page.html#unknown-method',
|
|
168
|
-
text: 'Unknown API method',
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// Test seedUrls: orphaned-page.html should be crawled even though it's not linked from anywhere
|
|
173
|
-
expect(result.pages.has('/orphaned-page.html')).toBe(true);
|
|
174
|
-
|
|
175
|
-
// Test seedUrls: broken link from orphaned page should be detected
|
|
176
|
-
expectIssue(result.issues, {
|
|
177
|
-
type: 'broken-link',
|
|
178
|
-
link: {
|
|
179
|
-
src: '/orphaned-page.html',
|
|
180
|
-
href: '/orphaned-broken-link.html',
|
|
181
|
-
text: 'Broken link from orphaned page',
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// Test trailing slash normalization: /valid.html and /valid.html/ should be treated as the same page
|
|
186
|
-
// The orphaned page has both links, but they should not cause duplicate page crawls
|
|
187
|
-
expectNotIssue(result.issues, { link: { href: '/valid.html/' } });
|
|
188
|
-
|
|
189
|
-
// Test contentType ignores: broken link from markdown should be ignored via contentType rule
|
|
190
|
-
expectNotIssue(result.issues, {
|
|
191
|
-
type: 'broken-link',
|
|
192
|
-
link: {
|
|
193
|
-
src: '/example.md',
|
|
194
|
-
href: '/broken-from-markdown.html',
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Valid links from markdown should not cause issues
|
|
199
|
-
expectNotIssue(result.issues, { link: { href: '/valid.html', src: '/example.md' } });
|
|
200
|
-
expectNotIssue(result.issues, {
|
|
201
|
-
link: { href: '/with-anchors.html#section1', src: '/example.md' },
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// Links inside code blocks should NOT be extracted (they're text, not <a> tags)
|
|
205
|
-
expectNotIssue(result.issues, { link: { href: '/this-should-not-be-checked.html' } });
|
|
206
|
-
|
|
207
|
-
// Markdown file itself should be crawlable without issues
|
|
208
|
-
expectNotIssue(result.issues, { link: { href: '/example.md' } });
|
|
209
|
-
|
|
210
|
-
// Test that markdown heading anchors are discovered (rehype-slug)
|
|
211
|
-
expect(result.pages.get('/example.md')?.targets.has('#example-markdown-file')).toBe(true);
|
|
212
|
-
expect(result.pages.get('/example.md')?.targets.has('#markdown-section')).toBe(true);
|
|
213
|
-
|
|
214
|
-
// Test href-only ignores: broken-relative.html should be ignored from any page via href-only rule
|
|
215
|
-
expectNotIssue(result.issues, {
|
|
216
|
-
type: 'broken-link',
|
|
217
|
-
link: {
|
|
218
|
-
href: 'broken-relative.html',
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// Valid relative links from markdown should not cause issues
|
|
223
|
-
expectNotIssue(result.issues, { link: { href: 'valid.html', src: '/example.md' } });
|
|
224
|
-
expectNotIssue(result.issues, { link: { href: './with-anchors.html', src: '/example.md' } });
|
|
225
|
-
|
|
226
|
-
// Test relative links in HTML
|
|
227
|
-
// Also verifies that the ignore pattern { path: /^\/broken-links\.html$/, href: '../broken-relative-html.html' }
|
|
228
|
-
// does NOT match this link since the path regex doesn't match /nested/page.html
|
|
229
|
-
expectIssue(result.issues, {
|
|
230
|
-
type: 'broken-link',
|
|
231
|
-
link: {
|
|
232
|
-
src: '/nested/page.html',
|
|
233
|
-
href: '../broken-relative-html.html',
|
|
234
|
-
text: 'Relative broken link from HTML',
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
// Valid relative links from HTML should not cause issues
|
|
239
|
-
expectNotIssue(result.issues, { link: { href: '../valid.html', src: '/nested/page.html' } });
|
|
240
|
-
|
|
241
|
-
// Test unclosed tags: links inside unclosed <main> tags should still be detected
|
|
242
|
-
// (regression test for node-html-parser parseNoneClosedTags option)
|
|
243
|
-
expectIssue(result.issues, {
|
|
244
|
-
type: 'broken-link',
|
|
245
|
-
link: {
|
|
246
|
-
src: '/unclosed-tags.html',
|
|
247
|
-
href: '/broken-inside-unclosed-main.html',
|
|
248
|
-
text: 'Broken link inside unclosed main',
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// Valid links inside unclosed tags should not cause issues
|
|
253
|
-
expectNotIssue(result.issues, {
|
|
254
|
-
link: { href: '/valid.html', src: '/unclosed-tags.html' },
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Test contentType is stored on pageData
|
|
258
|
-
expect(result.pages.get('/example.md')?.contentType).toBe('text/markdown');
|
|
259
|
-
expect(result.pages.get('/')?.contentType).toBe('text/html');
|
|
260
|
-
}, 30000);
|
|
261
|
-
});
|