From c28305ea81d35b462ad9ed513abc3c20dc6d997b Mon Sep 17 00:00:00 2001 From: Dave Ogle Date: Mon, 18 Nov 2024 13:37:20 +0000 Subject: [PATCH] minor update to lint script --- lintPosts.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lintPosts.js b/lintPosts.js index faeb86597..6f900662e 100644 --- a/lintPosts.js +++ b/lintPosts.js @@ -3,7 +3,8 @@ const matter = require("gray-matter"); const yaml = require("js-yaml"); const fs = require("fs"); const { exit } = require("process"); -const LINTER_MATCH_PATTERN="_posts/**/*.{md,markdown,html}" +const LINTER_MATCH_PATTERN="_posts/**/*.{md,markdown,html}"; +const MAX_CATEGORIES = 3; const flatMap = (arr, mapFunc) => arr.reduce((prev, x) => prev.concat(mapFunc(x)), []); @@ -72,10 +73,10 @@ const lintPosts = () => { category = frontMatter.data.category.toLowerCase(); // if the frontmatter defines a 'categories' field with at least one but no more than 3 values: - } else if (frontMatterCats && frontMatterCats.length && frontMatterCats.length <= 3) { + } else if (frontMatterCats && frontMatterCats.length && frontMatterCats.length <= MAX_CATEGORIES) { category = frontMatter.data.categories[0].toLowerCase(); } else { - console.error("The post " + path + " does not have at least one but no more than 3 categories defined"); + console.error("The post " + path + " does not have at least one and no more than " + MAX_CATEGORIES + " categories defined."); fail = true; return; }