wip: add linters and formatters

This commit is contained in:
2026-01-11 01:42:18 +00:00
parent 230e76b2d5
commit e86b0de9fa
30 changed files with 1342 additions and 933 deletions

View File

@@ -73,13 +73,13 @@ function extractText(node: MdastNode): string {
function findHeadingIndex(
nodes: RootContent[],
text: string,
depth: number = 2
depth: number = 2,
): number {
return nodes.findIndex(
(node) =>
node.type === "heading" &&
(node as Heading).depth === depth &&
extractText(node).toLowerCase().includes(text.toLowerCase())
extractText(node).toLowerCase().includes(text.toLowerCase()),
);
}
@@ -89,7 +89,7 @@ function findHeadingIndex(
function extractSectionNodes(
nodes: RootContent[],
startText: string,
depth: number = 2
depth: number = 2,
): RootContent[] {
const startIdx = findHeadingIndex(nodes, startText, depth);
if (startIdx === -1) return [];
@@ -114,7 +114,7 @@ function extractSectionNodes(
function getHeadingText(
nodes: RootContent[],
text: string,
depth: number = 2
depth: number = 2,
): string {
const idx = findHeadingIndex(nodes, text, depth);
if (idx === -1) return text;
@@ -135,7 +135,7 @@ async function nodesToHtml(nodes: RootContent[]): Promise<string> {
.use(rehypeStringify, { allowDangerousHtml: true })
.run(root);
const html = await unified()
const html = unified()
.use(rehypeStringify, { allowDangerousHtml: true })
.stringify(result as HastRoot);
@@ -299,7 +299,7 @@ function buildTocItems(parsed: Partial<ParsedSpec>): TocItem[] {
*/
export async function parseSpecContent(
markdown: string,
version: string
version: string,
): Promise<ParsedSpec> {
const svgPath = `/spec/${version}.svg`;
@@ -320,7 +320,7 @@ export async function parseSpecContent(
const terminologyTitle = getHeadingText(nodes, "Terminology");
const specificationTitle = getHeadingText(
nodes,
"Git Common-Flow Specification"
"Git Common-Flow Specification",
);
// Extract section nodes
@@ -376,7 +376,7 @@ export async function parseSpecContent(
// Convert FAQ answers to HTML
const faqAnswers = await Promise.all(
faqAnswerNodes.map((nodes) => nodesToHtml(nodes))
faqAnswerNodes.map((nodes) => nodesToHtml(nodes)),
);
// Assign FAQ answers