@mintlify/cli 4.0.1800 → 4.0.1801
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/__test__/validateCommand.test.ts +1 -1
- package/__test__/validateEngine.test.ts +2 -0
- package/__test__/validateRules.test.ts +56 -1
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/bin/validate/files.js +9 -2
- package/bin/validate/rules/content/missingSnippet.js +34 -0
- package/bin/validate/rules/content/undefinedVariable.js +13 -0
- package/bin/validate/rules/content/unknownComponent.js +1 -1
- package/bin/validate/rules/index.js +4 -0
- package/package.json +2 -2
- package/src/validate/files.ts +10 -3
- package/src/validate/rules/content/missingSnippet.ts +36 -0
- package/src/validate/rules/content/undefinedVariable.ts +20 -0
- package/src/validate/rules/content/unknownComponent.ts +1 -1
- package/src/validate/rules/index.ts +4 -0
- package/src/validate/types.ts +1 -0
|
@@ -478,7 +478,7 @@ describe('mint validate', () => {
|
|
|
478
478
|
},
|
|
479
479
|
]);
|
|
480
480
|
expect(rules(result)).toEqual(['unknown-component']);
|
|
481
|
-
expect(processExitMock).toHaveBeenCalledWith(
|
|
481
|
+
expect(processExitMock).toHaveBeenCalledWith(1);
|
|
482
482
|
});
|
|
483
483
|
|
|
484
484
|
it('turns rules and groups on and off', async () => {
|
|
@@ -492,7 +492,7 @@ describe('validate rules', () => {
|
|
|
492
492
|
expect(severities).toEqual({
|
|
493
493
|
'void-tags': 'error',
|
|
494
494
|
'duplicate-h1': 'warning',
|
|
495
|
-
'unknown-component': '
|
|
495
|
+
'unknown-component': 'error',
|
|
496
496
|
katex: 'warning',
|
|
497
497
|
});
|
|
498
498
|
expect(hasErrors(issues)).toBe(true);
|
|
@@ -549,6 +549,61 @@ describe('validate rules', () => {
|
|
|
549
549
|
expect(issues.map(({ message }) => message)).toEqual([expect.stringContaining('<Color.Nope>')]);
|
|
550
550
|
});
|
|
551
551
|
|
|
552
|
+
it('reports {{variables}} docs.json does not define, outside code', async () => {
|
|
553
|
+
write(dir, {
|
|
554
|
+
'index.mdx':
|
|
555
|
+
"---\ntitle: Home\n---\n\nVersion {{version}} of {{product}}.\n\n`{{inline}}`\n\n```jinja\n{{ fenced }}\n```\n\nexport const color = 'red';\n\n<div style={{color}} data-x = {{ color }}>Hi</div>\n",
|
|
556
|
+
'snippets/note.mdx': 'Hi {{ missing }}\n',
|
|
557
|
+
});
|
|
558
|
+
fs.writeJSONSync(path.join(dir, 'docs.json'), {
|
|
559
|
+
name: 'Test',
|
|
560
|
+
navigation: { pages: ['index'] },
|
|
561
|
+
variables: { product: 'Acme' },
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
const { issues } = await check(dir, { rules: ['undefined-variable'] });
|
|
565
|
+
|
|
566
|
+
expect(
|
|
567
|
+
issues.map(({ file, line, column, severity, message }) => [
|
|
568
|
+
file,
|
|
569
|
+
line,
|
|
570
|
+
column,
|
|
571
|
+
severity,
|
|
572
|
+
message,
|
|
573
|
+
])
|
|
574
|
+
).toEqual([
|
|
575
|
+
['index.mdx', 5, 9, 'error', '{{version}} is not defined in the variables of docs.json'],
|
|
576
|
+
[
|
|
577
|
+
'snippets/note.mdx',
|
|
578
|
+
1,
|
|
579
|
+
4,
|
|
580
|
+
'error',
|
|
581
|
+
'{{missing}} is not defined in the variables of docs.json',
|
|
582
|
+
],
|
|
583
|
+
]);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
it('reports legacy <Snippet file> tags the build cannot resolve', async () => {
|
|
587
|
+
write(dir, {
|
|
588
|
+
'_snippets/a.mdx': 'A\n',
|
|
589
|
+
'snippets/b.mdx': 'B\n',
|
|
590
|
+
'index.mdx':
|
|
591
|
+
'---\ntitle: Home\n---\n\n<Snippet file="a.mdx" />\n\n<Snippet file="{{part}}" />\n\n<Snippet file="snippets/b.mdx" />\n\n<Snippet file="b.mdx" />\n\n<Snippet file="/a.mdx" />\n',
|
|
592
|
+
});
|
|
593
|
+
fs.writeJSONSync(path.join(dir, 'docs.json'), {
|
|
594
|
+
name: 'Test',
|
|
595
|
+
navigation: { pages: ['index'] },
|
|
596
|
+
variables: { part: 'a.mdx' },
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
const { issues } = await check(dir, { rules: ['missing-snippet'] });
|
|
600
|
+
|
|
601
|
+
expect(issues.map(({ line, severity, message }) => [line, severity, message])).toEqual([
|
|
602
|
+
[11, 'error', '<Snippet file="b.mdx"> renders nothing: no snippet matches "b.mdx"'],
|
|
603
|
+
[13, 'error', '<Snippet file="/a.mdx"> renders nothing: no snippet matches "/a.mdx"'],
|
|
604
|
+
]);
|
|
605
|
+
});
|
|
606
|
+
|
|
552
607
|
it('leaves escaped void tags alone', async () => {
|
|
553
608
|
write(dir, { 'index.mdx': '---\ntitle: Home\n---\n\nText \\<br> and \\<img src="/a.png">\n' });
|
|
554
609
|
|