From 4a1f32d8745958acbd9bdd2ed562eb27dfe5e991 Mon Sep 17 00:00:00 2001 From: David Anson Date: Tue, 28 Oct 2025 22:13:27 -0700 Subject: [PATCH] Address new lint issues from previous commit. --- doc-build/build-rules.mjs | 5 ++--- lib/micromark-parse.mjs | 5 ++--- test/markdownlint-test-custom-rules.mjs | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/doc-build/build-rules.mjs b/doc-build/build-rules.mjs index 5f5d234a..274fe5a5 100644 --- a/doc-build/build-rules.mjs +++ b/doc-build/build-rules.mjs @@ -43,11 +43,10 @@ for (const rule of rules) { ``, "" ); - const section = []; - section.push( + const section = [ `## ${decorator}\`${name}\` - ${rule.description}${decorator}`, "" - ); + ]; if (deprecated) { section.push( "> This rule is deprecated and provided for backward-compatibility", diff --git a/lib/micromark-parse.mjs b/lib/micromark-parse.mjs index 14a4d0d6..e960b3c4 100644 --- a/lib/micromark-parse.mjs +++ b/lib/micromark-parse.mjs @@ -142,11 +142,10 @@ export function getEvents( .trim(); if ((text.length > 0) && !text.includes("]")) { /** @type {Event[]} */ - const artificialEvents = []; - artificialEvents.push( + const artificialEvents = [ [ "enter", undefinedReferenceType, tokenizeContext ], [ "enter", undefinedReference, tokenizeContext ] - ); + ]; for (const event of eventsToReplicate) { const [ kind, token ] = event; // Copy token because the current object will get modified by the parser diff --git a/test/markdownlint-test-custom-rules.mjs b/test/markdownlint-test-custom-rules.mjs index fc0723bf..132da729 100644 --- a/test/markdownlint-test-custom-rules.mjs +++ b/test/markdownlint-test-custom-rules.mjs @@ -400,12 +400,12 @@ test("customRulesNpmPackage", (t) => new Promise((resolve) => { }; lintAsync(options, function callback(err, actualResult) { t.falsy(err); - const expectedResult = {}; - expectedResult.string = { - "extended-ascii": [ 5 ], - "sample-rule": [ 3 ] + const expectedResult = { + "string": { + "extended-ascii": [ 5 ], + "sample-rule": [ 3 ] + } }; - // @ts-ignore t.deepEqual(actualResult, expectedResult, "Undetected issues."); resolve(); }); @@ -448,9 +448,10 @@ test("customRulesBadProperty", (t) => { ]) { const { propertyName, propertyValues } = testCase; for (const propertyValue of propertyValues) { - const badRule = { ...customRules.firstLine }; - // @ts-ignore - badRule[propertyName] = propertyValue; + const badRule = { + ...customRules.firstLine, + [propertyName]: propertyValue + }; /** @type {import("markdownlint").Options} */ const options = { "customRules": [ badRule ] @@ -1952,7 +1953,7 @@ test("customRulesValidateJson", (t) => new Promise((resolve) => { ] }; t.true( - actual && (actual["test/validate-json.md"][0].errorDetail.length > 0), + actual && (actual["test/validate-json.md"][0].errorDetail?.length !== 0), "Missing errorDetail" ); // @ts-ignore