Skip to content

Commit 4b6e2b1

Browse files
committed
Fix lint
1 parent 9f63040 commit 4b6e2b1

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

docs/other/build-llms-txt.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import rehypeRemark from "rehype-remark";
55
import remarkStringify from "remark-stringify";
66
import remarkGfm from "remark-gfm";
77
import { visitParents } from "unist-util-visit-parents";
8+
import type { Node } from "unist";
89
import { basename, dirname, join, relative } from "node:path";
910
import { fileURLToPath } from "node:url";
1011
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
@@ -49,19 +50,19 @@ async function collectFiles(currentDir: string, baseDir: string): Promise<FileMa
4950
* Custom remark plugin to clean up code blocks by removing excessive blank lines.
5051
*/
5152
function remarkCleanCodeBlocks() {
52-
return (tree: any) => {
53-
function visit(node: any) {
54-
if (node.type === 'code' && node.value) {
53+
return (tree: Node) => {
54+
function visit(node: Node) {
55+
if (node.type === 'code' && 'value' in node && typeof node.value === 'string') {
5556
// Remove lines that only contain whitespace
5657
node.value = node.value
5758
.split('\n')
5859
.filter((line: string) => line.trim().length > 0)
5960
.join('\n').trim();
6061
}
6162

62-
if (node.children) {
63+
if ('children' in node && Array.isArray(node.children)) {
6364
for (const child of node.children) {
64-
visit(child);
65+
visit(child as Node);
6566
}
6667
}
6768
}
@@ -75,12 +76,12 @@ function remarkCleanCodeBlocks() {
7576
* This is a special case, and the easiest way to handle it is to just manually decode it.
7677
*/
7778
function remarkDecodeTableEntities() {
78-
return (tree: any) => {
79-
visitParents(tree, 'text', (node: any, ancestors: any[]) => {
79+
return (tree: Node) => {
80+
visitParents(tree, 'text', (node: Node, ancestors: Node[]) => {
8081
// Check if any ancestor is a tableCell
8182
const isInTableCell = ancestors.some((ancestor) => ancestor.type === 'tableCell');
8283

83-
if (isInTableCell) {
84+
if (isInTableCell && 'value' in node && typeof node.value === 'string') {
8485
node.value = node.value
8586
.replace(/\\&#123;/g, "{")
8687
.replace(/\\&#125;/g, "}")

docs/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@types/jsdom": "^21.1.7",
3030
"@types/mdast": "^4.0.4",
3131
"@types/node": "catalog:",
32+
"@types/unist": "^3.0.3",
3233
"bits-ui": "workspace:*",
3334
"clsx": "^2.1.1",
3435
"consola": "^3.4.2",
@@ -41,6 +42,7 @@
4142
"rehype-parse": "^9.0.1",
4243
"rehype-pretty-code": "^0.13.2",
4344
"rehype-remark": "^10.0.1",
45+
"rehype-remove-comments": "^6.1.1",
4446
"rehype-slug": "^6.0.0",
4547
"remark-gfm": "^4.0.1",
4648
"remark-stringify": "^11.0.0",
@@ -59,11 +61,10 @@
5961
"unified": "^11.0.5",
6062
"unist-builder": "^4.0.0",
6163
"unist-util-visit": "^5.0.0",
64+
"unist-util-visit-parents": "^6.0.2",
6265
"velite": "^0.2.4",
6366
"vite": "catalog:",
64-
"vite-plugin-devtools-json": "^1.0.0",
65-
"rehype-remove-comments": "^6.1.1",
66-
"unist-util-visit-parents": "^6.0.2"
67+
"vite-plugin-devtools-json": "^1.0.0"
6768
},
6869
"type": "module"
6970
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)