From e4bcef6685ffbdf6fdfe50a5bb3bab2d9b0c982e Mon Sep 17 00:00:00 2001 From: David Anson Date: Wed, 27 Aug 2025 21:55:30 -0700 Subject: [PATCH] wip --- README.md | 2 +- lib/markdownlint.d.mts | 4 ---- lib/markdownlint.mjs | 6 ++---- test/markdownlint-test-custom-rules.mjs | 5 +++++ test/markdownlint-test-result-object.mjs | 18 +++++++++++++----- test/markdownlint-test.mjs | 3 +++ 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ad428589..2e2c7916 100644 --- a/README.md +++ b/README.md @@ -622,7 +622,7 @@ comments. ##### ~~options.resultVersion~~ -This property is *deprecated* and can be removed. The default format of the +This property is *deprecated* and should be removed. The default format of the `result` object remains the same as setting `resultVersion` to `3`. For continued access to other (previously *deprecated*) formats: diff --git a/lib/markdownlint.d.mts b/lib/markdownlint.d.mts index b0bd3dc9..331262e9 100644 --- a/lib/markdownlint.d.mts +++ b/lib/markdownlint.d.mts @@ -431,10 +431,6 @@ export type Options = { * True to ignore HTML directives. */ noInlineConfig?: boolean; - /** - * Results object version. - */ - resultVersion?: number; /** * Strings to lint. */ diff --git a/lib/markdownlint.mjs b/lib/markdownlint.mjs index 8c88707d..b3d8f25f 100644 --- a/lib/markdownlint.mjs +++ b/lib/markdownlint.mjs @@ -823,9 +823,8 @@ function lintInput(options, synchronous, callback) { options.frontMatter; const handleRuleFailures = !!options.handleRuleFailures; const noInlineConfig = !!options.noInlineConfig; - const resultVersion = (options.resultVersion === undefined) ? - 3 : - options.resultVersion; + // eslint-disable-next-line dot-notation + const resultVersion = (options["resultVersion"] === undefined) ? 3 : options["resultVersion"]; const markdownItFactory = options.markdownItFactory || (() => { throw new Error("The option 'markdownItFactory' was required (due to the option 'customRules' including a rule requiring the 'markdown-it' parser), but 'markdownItFactory' was not set."); }); @@ -1484,7 +1483,6 @@ export function getVersion() { * @property {boolean} [handleRuleFailures] True to catch exceptions. * @property {MarkdownItFactory} [markdownItFactory] Function to create a markdown-it parser. * @property {boolean} [noInlineConfig] True to ignore HTML directives. - * @property {number} [resultVersion] Results object version. * @property {Object.} [strings] Strings to lint. */ diff --git a/test/markdownlint-test-custom-rules.mjs b/test/markdownlint-test-custom-rules.mjs index 1a78c117..0cb331d6 100644 --- a/test/markdownlint-test-custom-rules.mjs +++ b/test/markdownlint-test-custom-rules.mjs @@ -24,6 +24,7 @@ test("customRulesV0", (t) => new Promise((resolve) => { "customRules": customRules.all, "files": [ customRulesMd ], markdownItFactory, + // @ts-ignore "resultVersion": 0 }; lintAsync(options, function callback(err, actualResult) { @@ -97,6 +98,7 @@ test("customRulesV1", (t) => new Promise((resolve) => { "customRules": customRules.all, "files": [ customRulesMd ], markdownItFactory, + // @ts-ignore "resultVersion": 1 }; lintAsync(options, function callback(err, actualResult) { @@ -229,6 +231,7 @@ test("customRulesV2", (t) => new Promise((resolve) => { "customRules": customRules.all, "files": [ customRulesMd ], markdownItFactory, + // @ts-ignore "resultVersion": 2 }; lintAsync(options, function callback(err, actualResult) { @@ -358,6 +361,7 @@ test("customRulesConfig", (t) => new Promise((resolve) => { "letters-e-x": false }, markdownItFactory, + // @ts-ignore "resultVersion": 0 }; lintAsync(options, function callback(err, actualResult) { @@ -387,6 +391,7 @@ test("customRulesNpmPackage", (t) => new Promise((resolve) => { "strings": { "string": "# Text\n\n---\n\nText ✅\n" }, + // @ts-ignore "resultVersion": 0 }; lintAsync(options, function callback(err, actualResult) { diff --git a/test/markdownlint-test-result-object.mjs b/test/markdownlint-test-result-object.mjs index a22e93dc..af1ebb18 100644 --- a/test/markdownlint-test-result-object.mjs +++ b/test/markdownlint-test-result-object.mjs @@ -627,7 +627,7 @@ test("frontMatterResultVersion3", (t) => new Promise((resolve) => { })); test("convertToResultVersionN", async(t) => { - t.plan(6); + t.plan(8); const options = { "files": [ "./test/break-all-the-rules.md", @@ -638,19 +638,27 @@ test("convertToResultVersionN", async(t) => { "banana": "## Heading" } }; - const [ version3, version2, version1, version0 ] = await Promise.all([ + const [ base, version3, version2, version1, version0 ] = await Promise.all([ lintPromise(options), + // @ts-ignore + lintPromise({ ...options, "resultVersion": 3 }), + // @ts-ignore lintPromise({ ...options, "resultVersion": 2 }), + // @ts-ignore lintPromise({ ...options, "resultVersion": 1 }), + // @ts-ignore lintPromise({ ...options, "resultVersion": 0 }) ]); - const v2 = convertToResultVersion2(version3); + const v3 = version3; + t.deepEqual(v3, base); + t.is(v3.toString(), base.toString()); + const v2 = convertToResultVersion2(base); t.deepEqual(v2, version2); t.is(v2.toString(), version2.toString()); - const v1 = convertToResultVersion1(version3); + const v1 = convertToResultVersion1(base); t.deepEqual(v1, version1); t.is(v1.toString(), version1.toString()); - const v0 = convertToResultVersion0(version3); + const v0 = convertToResultVersion0(base); t.deepEqual(v0, version0); t.is(v0.toString(), version0.toString()); }); diff --git a/test/markdownlint-test.mjs b/test/markdownlint-test.mjs index 7c973124..06318fce 100644 --- a/test/markdownlint-test.mjs +++ b/test/markdownlint-test.mjs @@ -546,6 +546,7 @@ test("nullFrontMatter", (t) => new Promise((resolve) => { "default": false, "MD010": true }, + // @ts-ignore "resultVersion": 0 }, function callback(err, result) { t.falsy(err); @@ -598,6 +599,7 @@ test("noInlineConfig", (t) => new Promise((resolve) => { ].join("\n") }, "noInlineConfig": true, + // @ts-ignore "resultVersion": 0 }, function callback(err, result) { t.falsy(err); @@ -1229,6 +1231,7 @@ Text with: [^footnote] [reference]: https://example.com ` }, + // @ts-ignore "resultVersion": 0 }, (err, actual) => { t.falsy(err);