Skip to content

Commit 594f3d6

Browse files
committed
Fix lint
1 parent 9f63040 commit 594f3d6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
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, "}")

0 commit comments

Comments
 (0)