chore: clean up lint file

pull/273/head
Parkreiner 11 months ago
parent cd010baac8
commit 66472b0105

@ -5,14 +5,15 @@ import grayMatter from "gray-matter";
const files = await readdir(".", { withFileTypes: true }); const files = await readdir(".", { withFileTypes: true });
const dirs = files.filter( const dirs = files.filter(
(f) => f.isDirectory() && !f.name.startsWith(".") && f.name !== "node_modules" (f) =>
f.isDirectory() && !f.name.startsWith(".") && f.name !== "node_modules",
); );
let badExit = false; let badExit = false;
// error reports an error to the console and sets badExit to true // error reports an error to the console and sets badExit to true
// so that the process will exit with a non-zero exit code. // so that the process will exit with a non-zero exit code.
const error = (...data: any[]) => { const error = (...data: unknown[]) => {
console.error(...data); console.error(...data);
badExit = true; badExit = true;
}; };
@ -22,7 +23,7 @@ const verifyCodeBlocks = (
res = { res = {
codeIsTF: false, codeIsTF: false,
codeIsHCL: false, codeIsHCL: false,
} },
) => { ) => {
for (const token of tokens) { for (const token of tokens) {
// Check in-depth. // Check in-depth.
@ -30,7 +31,12 @@ const verifyCodeBlocks = (
verifyCodeBlocks(token.items, res); verifyCodeBlocks(token.items, res);
continue; continue;
} }
if (token.type === "list_item") { if (token.type === "list_item") {
if (token.tokens === undefined) {
throw new Error("Tokens are missing for type list_item");
}
verifyCodeBlocks(token.tokens, res); verifyCodeBlocks(token.tokens, res);
continue; continue;
} }
@ -80,8 +86,9 @@ for (const dir of dirs) {
if (!data.maintainer_github) { if (!data.maintainer_github) {
error(dir.name, "missing maintainer_github"); error(dir.name, "missing maintainer_github");
} }
try { try {
await stat(path.join(".", dir.name, data.icon)); await stat(path.join(".", dir.name, data.icon ?? ""));
} catch (ex) { } catch (ex) {
error(dir.name, "icon does not exist", data.icon); error(dir.name, "icon does not exist", data.icon);
} }

Loading…
Cancel
Save