mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-27 19:18:48 +01:00
Deprecate options.resultVersion via typing, continue to support at run-time, provide format converters in markdownlint/helpers for migration.
Some checks failed
Checkers / linkcheck (push) Has been cancelled
Checkers / spellcheck (push) Has been cancelled
CI / build (20, macos-latest) (push) Has been cancelled
CI / build (20, ubuntu-latest) (push) Has been cancelled
CI / build (20, windows-latest) (push) Has been cancelled
CI / build (22, macos-latest) (push) Has been cancelled
CI / build (22, ubuntu-latest) (push) Has been cancelled
CI / build (22, windows-latest) (push) Has been cancelled
CI / build (24, macos-latest) (push) Has been cancelled
CI / build (24, ubuntu-latest) (push) Has been cancelled
CI / build (24, windows-latest) (push) Has been cancelled
CI / pnpm (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
TestRepos / build (latest, ubuntu-latest) (push) Has been cancelled
UpdateTestRepos / update (push) Has been cancelled
Some checks failed
Checkers / linkcheck (push) Has been cancelled
Checkers / spellcheck (push) Has been cancelled
CI / build (20, macos-latest) (push) Has been cancelled
CI / build (20, ubuntu-latest) (push) Has been cancelled
CI / build (20, windows-latest) (push) Has been cancelled
CI / build (22, macos-latest) (push) Has been cancelled
CI / build (22, ubuntu-latest) (push) Has been cancelled
CI / build (22, windows-latest) (push) Has been cancelled
CI / build (24, macos-latest) (push) Has been cancelled
CI / build (24, ubuntu-latest) (push) Has been cancelled
CI / build (24, windows-latest) (push) Has been cancelled
CI / pnpm (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
TestRepos / build (latest, ubuntu-latest) (push) Has been cancelled
UpdateTestRepos / update (push) Has been cancelled
This commit is contained in:
parent
5729b279c2
commit
bfd89b77de
9 changed files with 191 additions and 74 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
import test from "ava";
|
||||
import { lint as lintAsync } from "markdownlint/async";
|
||||
import { lint as lintPromise } from "markdownlint/promise";
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
import { convertToResultVersion0, convertToResultVersion1, convertToResultVersion2 } from "markdownlint/helpers";
|
||||
import { importWithTypeJson } from "./esm-helpers.mjs";
|
||||
const packageJson = await importWithTypeJson(import.meta, "../package.json");
|
||||
const { homepage, version } = packageJson;
|
||||
|
|
@ -623,3 +625,40 @@ test("frontMatterResultVersion3", (t) => new Promise((resolve) => {
|
|||
resolve();
|
||||
});
|
||||
}));
|
||||
|
||||
test("convertToResultVersionN", async(t) => {
|
||||
t.plan(8);
|
||||
const options = {
|
||||
"files": [
|
||||
"./test/break-all-the-rules.md",
|
||||
"./test/inline-disable-enable.md"
|
||||
],
|
||||
"strings": {
|
||||
"first": "# Heading",
|
||||
"second": "## Heading"
|
||||
}
|
||||
};
|
||||
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 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(base);
|
||||
t.deepEqual(v1, version1);
|
||||
t.is(v1.toString(), version1.toString());
|
||||
const v0 = convertToResultVersion0(base);
|
||||
t.deepEqual(v0, version0);
|
||||
t.is(v0.toString(), version0.toString());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -646,7 +648,7 @@ test("readmeHeadings", (t) => new Promise((resolve) => {
|
|||
"##### options.handleRuleFailures",
|
||||
"##### options.markdownItFactory",
|
||||
"##### options.noInlineConfig",
|
||||
"##### options.resultVersion",
|
||||
"##### ~~options.resultVersion~~",
|
||||
"##### options.strings",
|
||||
"#### callback",
|
||||
"#### result",
|
||||
|
|
@ -1229,6 +1231,7 @@ Text with: [^footnote]
|
|||
[reference]: https://example.com
|
||||
`
|
||||
},
|
||||
// @ts-ignore
|
||||
"resultVersion": 0
|
||||
}, (err, actual) => {
|
||||
t.falsy(err);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ Generated by [AVA](https://avajs.dev).
|
|||
'clearHtmlCommentText',
|
||||
'cloneIfArray',
|
||||
'cloneIfUrl',
|
||||
'convertToResultVersion0',
|
||||
'convertToResultVersion1',
|
||||
'convertToResultVersion2',
|
||||
'default',
|
||||
'ellipsify',
|
||||
'endOfLineGemojiCodeRe',
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue