From c93b7d219b3e39fb35d428cb649b3c1ab3e8b7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 11 Dec 2024 02:03:43 +0100 Subject: [PATCH] add a separate page --- lint/_data.ts | 33 +++++++++++++++++++++++++++++++++ lint/index.md | 12 ++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 lint/_data.ts create mode 100644 lint/index.md diff --git a/lint/_data.ts b/lint/_data.ts new file mode 100644 index 000000000..ebe149601 --- /dev/null +++ b/lint/_data.ts @@ -0,0 +1,33 @@ +import { walk } from "jsr:@std/fs"; +import { basename } from "jsr:@std/path"; + +export const sidebar = []; +export const sectionTitle = "Lint rules"; +export const sectionHref = "/lint/"; + +interface LintRuleDescription { + name: string; + mdContent: string; +} +export async function generateLintRuleList() { + const lintRules: LintRuleDescription[] = []; + + for await ( + const dirEntry of walk( + new URL(import.meta.resolve("../lint_rules/")), + { exts: ["md"] }, + ) + ) { + const snakeCaselintRuleName = basename(dirEntry.path).split(".")[0]; + const lintRuleName = snakeCaselintRuleName.replaceAll("_", "-"); + const mdContent = await Deno.readTextFile(dirEntry.path); + lintRules.push({ + name: lintRuleName, + mdContent, + }); + } + + lintRules.sort((a, b) => a.name.localeCompare(b.name)); + + return lintRules; +} diff --git a/lint/index.md b/lint/index.md new file mode 100644 index 000000000..954803ffa --- /dev/null +++ b/lint/index.md @@ -0,0 +1,12 @@ +--- +title: Deno linter rules +templateEngine: [vto, md] +--- + +{{ for lintRule of await generateLintRuleList() }} + +## {{ lintRule.name }} + +{{ lintRule.mdContent }} + +{{ /for }}