mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
wip
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
802e3fbdd4
commit
e4bcef6685
6 changed files with 24 additions and 14 deletions
|
@ -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:
|
||||
|
||||
|
|
|
@ -431,10 +431,6 @@ export type Options = {
|
|||
* True to ignore HTML directives.
|
||||
*/
|
||||
noInlineConfig?: boolean;
|
||||
/**
|
||||
* Results object version.
|
||||
*/
|
||||
resultVersion?: number;
|
||||
/**
|
||||
* Strings to lint.
|
||||
*/
|
||||
|
|
|
@ -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.<string, string>} [strings] Strings to lint.
|
||||
*/
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue