mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update to use named exports via / /async /promise /sync, simplify references via self-referencing, refine examples.
This commit is contained in:
parent
e41f034bef
commit
8da43dd246
96 changed files with 635 additions and 548 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import { readFile } from "node:fs/promises";
|
||||
import { lint } from "markdownlint/promise";
|
||||
import { parse } from "../lib/micromark-parse.mjs";
|
||||
import library from "../lib/markdownlint.mjs";
|
||||
const markdownlint = library.promises.markdownlint;
|
||||
|
||||
/* eslint-disable no-await-in-loop, no-console */
|
||||
|
||||
|
|
@ -43,7 +42,7 @@ for (const file of files) {
|
|||
let results = null;
|
||||
performance.mark("profile-start");
|
||||
for (let i = 0; i < count; i++) {
|
||||
results = await markdownlint({
|
||||
results = await lint({
|
||||
"files": [ file ]
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,16 @@ const require = createRequire(import.meta.url);
|
|||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "ava";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
import { readConfig as readConfigAsync } from "markdownlint/async";
|
||||
import { extendConfig, readConfig as readConfigPromise } from "markdownlint/promise";
|
||||
import { readConfig as readConfigSync } from "markdownlint/sync";
|
||||
import { __dirname } from "./esm-helpers.mjs";
|
||||
|
||||
const sameFileSystem = (path.relative(os.homedir(), __dirname(import.meta)) !== __dirname(import.meta));
|
||||
|
||||
test("configSingle", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig("./test/config/config-child.json",
|
||||
readConfigAsync("./test/config/config-child.json",
|
||||
function callback(err, actual) {
|
||||
t.falsy(err);
|
||||
const expected = require("./config/config-child.json");
|
||||
|
|
@ -24,7 +26,7 @@ test("configSingle", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configAbsolute", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig(path.join(__dirname(import.meta), "config", "config-child.json"),
|
||||
readConfigAsync(path.join(__dirname(import.meta), "config", "config-child.json"),
|
||||
function callback(err, actual) {
|
||||
t.falsy(err);
|
||||
const expected = require("./config/config-child.json");
|
||||
|
|
@ -36,7 +38,7 @@ test("configAbsolute", (t) => new Promise((resolve) => {
|
|||
if (sameFileSystem) {
|
||||
test("configTilde", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig(
|
||||
readConfigAsync(
|
||||
`~/${path.relative(os.homedir(), "./test/config/config-child.json")}`,
|
||||
function callback(err, actual) {
|
||||
t.falsy(err);
|
||||
|
|
@ -49,7 +51,7 @@ if (sameFileSystem) {
|
|||
|
||||
test("configMultiple", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig("./test/config/config-grandparent.json",
|
||||
readConfigAsync("./test/config/config-grandparent.json",
|
||||
function callback(err, actual) {
|
||||
t.falsy(err);
|
||||
const expected = {
|
||||
|
|
@ -66,7 +68,7 @@ test("configMultiple", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configMultipleWithRequireResolve", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig("./test/config/config-packageparent.json",
|
||||
readConfigAsync("./test/config/config-packageparent.json",
|
||||
function callback(err, actual) {
|
||||
t.falsy(err);
|
||||
const expected = {
|
||||
|
|
@ -108,7 +110,7 @@ test("configCustomFileSystem", (t) => new Promise((resolve) => {
|
|||
return t.fail(p);
|
||||
}
|
||||
};
|
||||
markdownlint.readConfig(
|
||||
readConfigAsync(
|
||||
file,
|
||||
// @ts-ignore
|
||||
null,
|
||||
|
|
@ -128,7 +130,7 @@ test("configCustomFileSystem", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configBadFile", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint.readConfig("./test/config/config-badfile.json",
|
||||
readConfigAsync("./test/config/config-badfile.json",
|
||||
function callback(err, result) {
|
||||
t.truthy(err, "Did not get an error for bad file.");
|
||||
t.true(err instanceof Error, "Error not instance of Error.");
|
||||
|
|
@ -141,7 +143,7 @@ test("configBadFile", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configBadChildFile", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint.readConfig("./test/config/config-badchildfile.json",
|
||||
readConfigAsync("./test/config/config-badchildfile.json",
|
||||
function callback(err, result) {
|
||||
t.truthy(err, "Did not get an error for bad child file.");
|
||||
t.true(err instanceof Error, "Error not instance of Error.");
|
||||
|
|
@ -155,7 +157,7 @@ test("configBadChildFile", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configBadChildPackage", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint.readConfig("./test/config/config-badchildpackage.json",
|
||||
readConfigAsync("./test/config/config-badchildpackage.json",
|
||||
function callback(err, result) {
|
||||
t.truthy(err, "Did not get an error for bad child package.");
|
||||
t.true(err instanceof Error, "Error not instance of Error.");
|
||||
|
|
@ -169,7 +171,7 @@ test("configBadChildPackage", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configBadJson", (t) => new Promise((resolve) => {
|
||||
t.plan(3);
|
||||
markdownlint.readConfig("./test/config/config-badjson.json",
|
||||
readConfigAsync("./test/config/config-badjson.json",
|
||||
function callback(err, result) {
|
||||
t.truthy(err, "Did not get an error for bad JSON.");
|
||||
t.true(err instanceof Error, "Error not instance of Error.");
|
||||
|
|
@ -180,7 +182,7 @@ test("configBadJson", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configBadChildJson", (t) => new Promise((resolve) => {
|
||||
t.plan(3);
|
||||
markdownlint.readConfig("./test/config/config-badchildjson.json",
|
||||
readConfigAsync("./test/config/config-badchildjson.json",
|
||||
function callback(err, result) {
|
||||
t.truthy(err, "Did not get an error for bad child JSON.");
|
||||
t.true(err instanceof Error, "Error not instance of Error.");
|
||||
|
|
@ -191,7 +193,7 @@ test("configBadChildJson", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configSingleYaml", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig(
|
||||
readConfigAsync(
|
||||
"./test/config/config-child.yaml",
|
||||
// @ts-ignore
|
||||
[ require("js-yaml").load ],
|
||||
|
|
@ -205,7 +207,7 @@ test("configSingleYaml", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configMultipleYaml", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig(
|
||||
readConfigAsync(
|
||||
"./test/config/config-grandparent.yaml",
|
||||
// @ts-ignore
|
||||
[ require("js-yaml").load ],
|
||||
|
|
@ -225,7 +227,7 @@ test("configMultipleYaml", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configMultipleHybrid", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.readConfig(
|
||||
readConfigAsync(
|
||||
"./test/config/config-grandparent-hybrid.yaml",
|
||||
// @ts-ignore
|
||||
[ JSON.parse, require("toml").parse, require("js-yaml").load ],
|
||||
|
|
@ -245,7 +247,7 @@ test("configMultipleHybrid", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configBadHybrid", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint.readConfig(
|
||||
readConfigAsync(
|
||||
"./test/config/config-badcontent.txt",
|
||||
// @ts-ignore
|
||||
[ JSON.parse, require("toml").parse, require("js-yaml").load ],
|
||||
|
|
@ -262,14 +264,14 @@ test("configBadHybrid", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configSingleSync", (t) => {
|
||||
t.plan(1);
|
||||
const actual = markdownlint.readConfigSync("./test/config/config-child.json");
|
||||
const actual = readConfigSync("./test/config/config-child.json");
|
||||
const expected = require("./config/config-child.json");
|
||||
t.deepEqual(actual, expected, "Config object not correct.");
|
||||
});
|
||||
|
||||
test("configAbsoluteSync", (t) => {
|
||||
t.plan(1);
|
||||
const actual = markdownlint.readConfigSync(
|
||||
const actual = readConfigSync(
|
||||
path.join(__dirname(import.meta), "config", "config-child.json"));
|
||||
const expected = require("./config/config-child.json");
|
||||
t.deepEqual(actual, expected, "Config object not correct.");
|
||||
|
|
@ -278,7 +280,7 @@ test("configAbsoluteSync", (t) => {
|
|||
if (sameFileSystem) {
|
||||
test("configTildeSync", (t) => {
|
||||
t.plan(1);
|
||||
const actual = markdownlint.readConfigSync(
|
||||
const actual = readConfigSync(
|
||||
`~/${path.relative(os.homedir(), "./test/config/config-child.json")}`);
|
||||
const expected = require("./config/config-child.json");
|
||||
t.deepEqual(actual, expected, "Config object not correct.");
|
||||
|
|
@ -288,7 +290,7 @@ if (sameFileSystem) {
|
|||
test("configMultipleSync", (t) => {
|
||||
t.plan(1);
|
||||
const actual =
|
||||
markdownlint.readConfigSync("./test/config/config-grandparent.json");
|
||||
readConfigSync("./test/config/config-grandparent.json");
|
||||
const expected = {
|
||||
...require("./config/config-child.json"),
|
||||
...require("./config/config-parent.json"),
|
||||
|
|
@ -303,7 +305,7 @@ test("configBadFileSync", (t) => {
|
|||
t.plan(1);
|
||||
t.throws(
|
||||
function badFileCall() {
|
||||
markdownlint.readConfigSync("./test/config/config-badfile.json");
|
||||
readConfigSync("./test/config/config-badfile.json");
|
||||
},
|
||||
{
|
||||
"message": /ENOENT/
|
||||
|
|
@ -316,7 +318,7 @@ test("configBadChildFileSync", (t) => {
|
|||
t.plan(1);
|
||||
t.throws(
|
||||
function badChildFileCall() {
|
||||
markdownlint.readConfigSync("./test/config/config-badchildfile.json");
|
||||
readConfigSync("./test/config/config-badchildfile.json");
|
||||
},
|
||||
{
|
||||
"message": /ENOENT/
|
||||
|
|
@ -329,7 +331,7 @@ test("configBadJsonSync", (t) => {
|
|||
t.plan(1);
|
||||
t.throws(
|
||||
function badJsonCall() {
|
||||
markdownlint.readConfigSync("./test/config/config-badjson.json");
|
||||
readConfigSync("./test/config/config-badjson.json");
|
||||
},
|
||||
{
|
||||
"message":
|
||||
|
|
@ -343,7 +345,7 @@ test("configBadChildJsonSync", (t) => {
|
|||
t.plan(1);
|
||||
t.throws(
|
||||
function badChildJsonCall() {
|
||||
markdownlint.readConfigSync("./test/config/config-badchildjson.json");
|
||||
readConfigSync("./test/config/config-badchildjson.json");
|
||||
},
|
||||
{
|
||||
"message":
|
||||
|
|
@ -355,7 +357,7 @@ test("configBadChildJsonSync", (t) => {
|
|||
|
||||
test("configSingleYamlSync", (t) => {
|
||||
t.plan(1);
|
||||
const actual = markdownlint.readConfigSync(
|
||||
const actual = readConfigSync(
|
||||
// @ts-ignore
|
||||
"./test/config/config-child.yaml", [ require("js-yaml").load ]);
|
||||
const expected = require("./config/config-child.json");
|
||||
|
|
@ -364,7 +366,7 @@ test("configSingleYamlSync", (t) => {
|
|||
|
||||
test("configMultipleYamlSync", (t) => {
|
||||
t.plan(1);
|
||||
const actual = markdownlint.readConfigSync(
|
||||
const actual = readConfigSync(
|
||||
// @ts-ignore
|
||||
"./test/config/config-grandparent.yaml", [ require("js-yaml").load ]);
|
||||
const expected = {
|
||||
|
|
@ -379,7 +381,7 @@ test("configMultipleYamlSync", (t) => {
|
|||
|
||||
test("configMultipleHybridSync", (t) => {
|
||||
t.plan(1);
|
||||
const actual = markdownlint.readConfigSync(
|
||||
const actual = readConfigSync(
|
||||
"./test/config/config-grandparent-hybrid.yaml",
|
||||
// @ts-ignore
|
||||
[ JSON.parse, require("toml").parse, require("js-yaml").load ]);
|
||||
|
|
@ -420,7 +422,7 @@ test("configCustomFileSystemSync", (t) => {
|
|||
return t.fail(p);
|
||||
}
|
||||
};
|
||||
const actual = markdownlint.readConfigSync(file, undefined, fsApi);
|
||||
const actual = readConfigSync(file, undefined, fsApi);
|
||||
const expected = {
|
||||
...extendedContent,
|
||||
...fileContent
|
||||
|
|
@ -434,7 +436,7 @@ test("configBadHybridSync", (t) => {
|
|||
t.plan(1);
|
||||
t.throws(
|
||||
function badHybridCall() {
|
||||
markdownlint.readConfigSync(
|
||||
readConfigSync(
|
||||
"./test/config/config-badcontent.txt",
|
||||
// @ts-ignore
|
||||
[ JSON.parse, require("toml").parse, require("js-yaml").load ]);
|
||||
|
|
@ -448,7 +450,7 @@ test("configBadHybridSync", (t) => {
|
|||
|
||||
test("configSinglePromise", (t) => new Promise((resolve) => {
|
||||
t.plan(1);
|
||||
markdownlint.promises.readConfig("./test/config/config-child.json")
|
||||
readConfigPromise("./test/config/config-child.json")
|
||||
.then((actual) => {
|
||||
const expected = require("./config/config-child.json");
|
||||
t.deepEqual(actual, expected, "Config object not correct.");
|
||||
|
|
@ -487,7 +489,7 @@ test("configCustomFileSystemPromise", (t) => new Promise((resolve) => {
|
|||
}
|
||||
}
|
||||
};
|
||||
markdownlint.promises.readConfig(file, undefined, fsApi)
|
||||
readConfigPromise(file, undefined, fsApi)
|
||||
.then((actual) => {
|
||||
const expected = {
|
||||
...extendedContent,
|
||||
|
|
@ -502,7 +504,7 @@ test("configCustomFileSystemPromise", (t) => new Promise((resolve) => {
|
|||
|
||||
test("configBadFilePromise", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.promises.readConfig("./test/config/config-badfile.json")
|
||||
readConfigPromise("./test/config/config-badfile.json")
|
||||
.then(
|
||||
null,
|
||||
(error) => {
|
||||
|
|
@ -516,7 +518,7 @@ test("configBadFilePromise", (t) => new Promise((resolve) => {
|
|||
test("extendSinglePromise", (t) => new Promise((resolve) => {
|
||||
t.plan(1);
|
||||
const expected = require("./config/config-child.json");
|
||||
markdownlint.promises.extendConfig(
|
||||
extendConfig(
|
||||
expected,
|
||||
"./test/config/config-child.json",
|
||||
undefined,
|
||||
|
|
@ -530,7 +532,7 @@ test("extendSinglePromise", (t) => new Promise((resolve) => {
|
|||
|
||||
test("extendBadPromise", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint.promises.extendConfig(
|
||||
extendConfig(
|
||||
{
|
||||
"extends": "missing.json"
|
||||
},
|
||||
|
|
@ -576,7 +578,7 @@ test("extendCustomFileSystemPromise", (t) => new Promise((resolve) => {
|
|||
}
|
||||
}
|
||||
};
|
||||
markdownlint.promises.extendConfig(fileContent, file, undefined, fsApi)
|
||||
extendConfig(fileContent, file, undefined, fsApi)
|
||||
.then((actual) => {
|
||||
t.truthy(fileContent.extends);
|
||||
const expected = {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import fs from "node:fs/promises";
|
|||
import { createRequire } from "node:module";
|
||||
const require = createRequire(import.meta.url);
|
||||
import test from "ava";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
import { lint as lintAsync } from "markdownlint/async";
|
||||
import { lint as lintPromise } from "markdownlint/promise";
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
import customRules from "./rules/rules.cjs";
|
||||
import { newLineRe } from "../helpers/helpers.cjs";
|
||||
import { __filename, importWithTypeJson } from "./esm-helpers.mjs";
|
||||
|
|
@ -14,13 +16,13 @@ const { homepage, version } = packageJson;
|
|||
test("customRulesV0", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
const customRulesMd = "./test/custom-rules.md";
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": customRules.all,
|
||||
"files": [ customRulesMd ],
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {};
|
||||
expectedResult[customRulesMd] = {
|
||||
|
|
@ -86,13 +88,13 @@ test("customRulesV0", (t) => new Promise((resolve) => {
|
|||
test("customRulesV1", (t) => new Promise((resolve) => {
|
||||
t.plan(3);
|
||||
const customRulesMd = "./test/custom-rules.md";
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": customRules.all,
|
||||
"files": [ customRulesMd ],
|
||||
"resultVersion": 1
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {};
|
||||
expectedResult[customRulesMd] = [
|
||||
|
|
@ -217,13 +219,13 @@ test("customRulesV1", (t) => new Promise((resolve) => {
|
|||
test("customRulesV2", (t) => new Promise((resolve) => {
|
||||
t.plan(3);
|
||||
const customRulesMd = "./test/custom-rules.md";
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": customRules.all,
|
||||
"files": [ customRulesMd ],
|
||||
"resultVersion": 2
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {};
|
||||
expectedResult[customRulesMd] = [
|
||||
|
|
@ -338,7 +340,7 @@ test("customRulesV2", (t) => new Promise((resolve) => {
|
|||
test("customRulesConfig", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
const customRulesMd = "./test/custom-rules.md";
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": customRules.all,
|
||||
"files": [ customRulesMd ],
|
||||
|
|
@ -351,7 +353,7 @@ test("customRulesConfig", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {};
|
||||
expectedResult[customRulesMd] = {
|
||||
|
|
@ -368,7 +370,7 @@ test("customRulesConfig", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesNpmPackage", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
require("./rules/npm"),
|
||||
|
|
@ -379,7 +381,7 @@ test("customRulesNpmPackage", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {};
|
||||
expectedResult.string = {
|
||||
|
|
@ -431,13 +433,13 @@ test("customRulesBadProperty", (t) => {
|
|||
for (const propertyValue of propertyValues) {
|
||||
const badRule = { ...customRules.firstLine };
|
||||
badRule[propertyName] = propertyValue;
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [ badRule ]
|
||||
};
|
||||
t.throws(
|
||||
function badRuleCall() {
|
||||
markdownlint.sync(options);
|
||||
lintSync(options);
|
||||
},
|
||||
{
|
||||
"message":
|
||||
|
|
@ -451,8 +453,8 @@ test("customRulesBadProperty", (t) => {
|
|||
|
||||
test("customRulesUsedNameName", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintAsync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name", "NO-missing-SPACE-atx" ],
|
||||
|
|
@ -477,8 +479,8 @@ test("customRulesUsedNameName", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesUsedNameTag", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintAsync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name", "HtMl" ],
|
||||
|
|
@ -502,8 +504,8 @@ test("customRulesUsedNameTag", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesUsedTagName", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintAsync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "filler" ],
|
||||
|
|
@ -535,7 +537,7 @@ test("customRulesUsedTagName", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesParserUndefined", (t) => {
|
||||
t.plan(5);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
// @ts-ignore
|
||||
|
|
@ -557,12 +559,12 @@ test("customRulesParserUndefined", (t) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesParserNone", (t) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -581,12 +583,12 @@ test("customRulesParserNone", (t) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesParserMarkdownIt", (t) => {
|
||||
t.plan(5);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -608,12 +610,12 @@ test("customRulesParserMarkdownIt", (t) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesParserMicromark", (t) => {
|
||||
t.plan(5);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -635,12 +637,12 @@ test("customRulesParserMicromark", (t) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesMarkdownItParamsTokensSameObject", (t) => {
|
||||
t.plan(1);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
// @ts-ignore
|
||||
|
|
@ -659,12 +661,12 @@ test("customRulesMarkdownItParamsTokensSameObject", (t) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesMarkdownItTokensSnapshot", (t) => {
|
||||
t.plan(1);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -684,13 +686,13 @@ test("customRulesMarkdownItTokensSnapshot", (t) => {
|
|||
.readFile("./test/every-markdown-syntax.md", "utf8")
|
||||
.then((content) => {
|
||||
options.strings = { "content": content.split(newLineRe).join("\n") };
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
});
|
||||
|
||||
test("customRulesMicromarkTokensSnapshot", (t) => {
|
||||
t.plan(1);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -710,13 +712,13 @@ test("customRulesMicromarkTokensSnapshot", (t) => {
|
|||
.readFile("./test/every-markdown-syntax.md", "utf8")
|
||||
.then((content) => {
|
||||
options.strings = { "content": content.split(newLineRe).join("\n") };
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
});
|
||||
|
||||
test("customRulesDefinitionStatic", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -741,7 +743,7 @@ test("customRulesDefinitionStatic", (t) => new Promise((resolve) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
markdownlint(options, (err, actualResult) => {
|
||||
lintAsync(options, (err, actualResult) => {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"string": [
|
||||
|
|
@ -765,8 +767,8 @@ test("customRulesDefinitionStatic", (t) => new Promise((resolve) => {
|
|||
test("customRulesThrowForFile", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
const exceptionMessage = "Test exception message";
|
||||
markdownlint({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintAsync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -795,8 +797,8 @@ test("customRulesThrowForFileSync", (t) => {
|
|||
const exceptionMessage = "Test exception message";
|
||||
t.throws(
|
||||
function customRuleThrowsCall() {
|
||||
markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -821,8 +823,8 @@ test("customRulesThrowForFileSync", (t) => {
|
|||
test("customRulesThrowForString", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
const exceptionMessage = "Test exception message";
|
||||
markdownlint({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintAsync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -853,8 +855,8 @@ test("customRulesThrowForStringSync", (t) => {
|
|||
const exceptionMessage = "Test exception message";
|
||||
t.throws(
|
||||
function customRuleThrowsCall() {
|
||||
markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -880,8 +882,8 @@ test("customRulesThrowForStringSync", (t) => {
|
|||
|
||||
test("customRulesOnErrorNull", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintAsync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -914,7 +916,7 @@ test("customRulesOnErrorNull", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesOnErrorNullSync", (t) => {
|
||||
t.plan(1);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -934,7 +936,7 @@ test("customRulesOnErrorNullSync", (t) => {
|
|||
};
|
||||
t.throws(
|
||||
function nullErrorCall() {
|
||||
markdownlint.sync(options);
|
||||
lintSync(options);
|
||||
},
|
||||
{
|
||||
"message": "Value of 'lineNumber' passed to onError by 'NAME' is incorrect for 'string'."
|
||||
|
|
@ -1005,7 +1007,7 @@ test("customRulesOnErrorBad", (t) => {
|
|||
badObject[propertyName] = propertyValue;
|
||||
propertyNames = propertyName;
|
||||
}
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1024,7 +1026,7 @@ test("customRulesOnErrorBad", (t) => {
|
|||
};
|
||||
t.throws(
|
||||
function badErrorCall() {
|
||||
markdownlint.sync(options);
|
||||
lintSync(options);
|
||||
},
|
||||
{
|
||||
"message":
|
||||
|
|
@ -1077,7 +1079,7 @@ test("customRulesOnErrorInvalid", (t) => {
|
|||
badObject[propertyName] = propertyValue;
|
||||
propertyNames = propertyName;
|
||||
}
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1096,7 +1098,7 @@ test("customRulesOnErrorInvalid", (t) => {
|
|||
};
|
||||
t.throws(
|
||||
function invalidErrorCall() {
|
||||
markdownlint.sync(options);
|
||||
lintSync(options);
|
||||
},
|
||||
{
|
||||
"message":
|
||||
|
|
@ -1152,7 +1154,7 @@ test("customRulesOnErrorValid", (t) => {
|
|||
} else {
|
||||
goodObject[propertyName] = propertyValue;
|
||||
}
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1169,7 +1171,7 @@ test("customRulesOnErrorValid", (t) => {
|
|||
"string": "Text\ntext"
|
||||
}
|
||||
};
|
||||
markdownlint.sync(options);
|
||||
lintSync(options);
|
||||
t.truthy(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1177,7 +1179,7 @@ test("customRulesOnErrorValid", (t) => {
|
|||
|
||||
test("customRulesOnErrorLazy", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1199,7 +1201,7 @@ test("customRulesOnErrorLazy", (t) => new Promise((resolve) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"string": [
|
||||
|
|
@ -1234,7 +1236,7 @@ test("customRulesOnErrorModified", (t) => new Promise((resolve) => {
|
|||
"insertText": "text"
|
||||
}
|
||||
};
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1259,7 +1261,7 @@ test("customRulesOnErrorModified", (t) => new Promise((resolve) => {
|
|||
"string": "# Heading\n"
|
||||
}
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"string": [
|
||||
|
|
@ -1286,8 +1288,8 @@ test("customRulesOnErrorModified", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesOnErrorInvalidHandled", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
lintAsync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1329,8 +1331,8 @@ test("customRulesOnErrorInvalidHandled", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesOnErrorInvalidHandledSync", (t) => {
|
||||
t.plan(1);
|
||||
const actualResult = markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
const actualResult = lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1370,7 +1372,7 @@ test("customRulesOnErrorInvalidHandledSync", (t) => {
|
|||
|
||||
test("customRulesVersion", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1385,7 +1387,7 @@ test("customRulesVersion", (t) => new Promise((resolve) => {
|
|||
],
|
||||
"files": "doc/CustomRules.md"
|
||||
};
|
||||
markdownlint(options, function callback(err) {
|
||||
lintAsync(options, function callback(err) {
|
||||
t.falsy(err);
|
||||
resolve();
|
||||
});
|
||||
|
|
@ -1393,7 +1395,7 @@ test("customRulesVersion", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesFileName", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1408,7 +1410,7 @@ test("customRulesFileName", (t) => new Promise((resolve) => {
|
|||
],
|
||||
"files": "doc/CustomRules.md"
|
||||
};
|
||||
markdownlint(options, function callback(err) {
|
||||
lintAsync(options, function callback(err) {
|
||||
t.falsy(err);
|
||||
resolve();
|
||||
});
|
||||
|
|
@ -1416,7 +1418,7 @@ test("customRulesFileName", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesStringName", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1433,7 +1435,7 @@ test("customRulesStringName", (t) => new Promise((resolve) => {
|
|||
"string": "# Heading"
|
||||
}
|
||||
};
|
||||
markdownlint(options, function callback(err) {
|
||||
lintAsync(options, function callback(err) {
|
||||
t.falsy(err);
|
||||
resolve();
|
||||
});
|
||||
|
|
@ -1441,8 +1443,8 @@ test("customRulesStringName", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesOnErrorInformationNotRuleNotError", (t) => {
|
||||
t.plan(1);
|
||||
const actualResult = markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
const actualResult = lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1465,8 +1467,8 @@ test("customRulesOnErrorInformationNotRuleNotError", (t) => {
|
|||
|
||||
test("customRulesOnErrorInformationRuleNotError", (t) => {
|
||||
t.plan(1);
|
||||
const actualResult = markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
const actualResult = lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1494,8 +1496,8 @@ test("customRulesOnErrorInformationRuleNotError", (t) => {
|
|||
|
||||
test("customRulesOnErrorInformationNotRuleError", (t) => {
|
||||
t.plan(1);
|
||||
const actualResult = markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
const actualResult = lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1523,8 +1525,8 @@ test("customRulesOnErrorInformationNotRuleError", (t) => {
|
|||
|
||||
test("customRulesOnErrorInformationRuleError", (t) => {
|
||||
t.plan(1);
|
||||
const actualResult = markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
const actualResult = lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1553,8 +1555,8 @@ test("customRulesOnErrorInformationRuleError", (t) => {
|
|||
|
||||
test("customRulesOnErrorInformationRuleErrorUndefined", (t) => {
|
||||
t.plan(1);
|
||||
const actualResult = markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
const actualResult = lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1583,8 +1585,8 @@ test("customRulesOnErrorInformationRuleErrorUndefined", (t) => {
|
|||
|
||||
test("customRulesOnErrorInformationRuleErrorMultiple", (t) => {
|
||||
t.plan(6);
|
||||
const actualResult = markdownlint.sync({
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
const actualResult = lintSync({
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
"customRules": [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -1645,7 +1647,7 @@ test("customRulesOnErrorInformationRuleErrorMultiple", (t) => {
|
|||
|
||||
test("customRulesDoc", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"files": "./doc/CustomRules.md",
|
||||
"config": {
|
||||
"MD013": { "line_length": 200 }
|
||||
|
|
@ -1660,12 +1662,12 @@ test("customRulesDoc", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesLintJavaScript", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": customRules.lintJavaScript,
|
||||
"files": "test/lint-javascript.md"
|
||||
};
|
||||
markdownlint(options, (err, actual) => {
|
||||
lintAsync(options, (err, actual) => {
|
||||
t.falsy(err);
|
||||
const expected = {
|
||||
"test/lint-javascript.md": [
|
||||
|
|
@ -1688,12 +1690,12 @@ test("customRulesLintJavaScript", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesValidateJson", (t) => new Promise((resolve) => {
|
||||
t.plan(3);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": customRules.validateJson,
|
||||
"files": "test/validate-json.md"
|
||||
};
|
||||
markdownlint(options, (err, actual) => {
|
||||
lintAsync(options, (err, actual) => {
|
||||
t.falsy(err);
|
||||
const expected = {
|
||||
"test/validate-json.md": [
|
||||
|
|
@ -1721,7 +1723,7 @@ test("customRulesValidateJson", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customRulesAsyncThrowsInSyncContext", (t) => {
|
||||
t.plan(1);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1738,7 +1740,7 @@ test("customRulesAsyncThrowsInSyncContext", (t) => {
|
|||
}
|
||||
};
|
||||
t.throws(
|
||||
() => markdownlint.sync(options),
|
||||
() => lintSync(options),
|
||||
{
|
||||
"message": "Custom rule name1/name2 at index 0 is asynchronous and " +
|
||||
"can not be used in a synchronous context."
|
||||
|
|
@ -1765,7 +1767,7 @@ test("customRulesParamsAreFrozen", (t) => {
|
|||
}
|
||||
}
|
||||
};
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1792,14 +1794,14 @@ test("customRulesParamsAreFrozen", (t) => {
|
|||
],
|
||||
"files": [ "README.md" ]
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesParamsAreStable", (t) => {
|
||||
t.plan(4);
|
||||
const config1 = { "value1": 10 };
|
||||
const config2 = { "value2": 20 };
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"config": {
|
||||
"MD010": true,
|
||||
|
|
@ -1860,12 +1862,12 @@ test("customRulesParamsAreStable", (t) => {
|
|||
"string": "# Heading"
|
||||
}
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options).then(() => null);
|
||||
return lintPromise(options).then(() => null);
|
||||
});
|
||||
|
||||
test("customRulesAsyncReadFiles", (t) => {
|
||||
t.plan(3);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1947,13 +1949,13 @@ test("customRulesAsyncReadFiles", (t) => {
|
|||
}
|
||||
]
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options)
|
||||
return lintPromise(options)
|
||||
.then((actual) => t.deepEqual(actual, expected, "Unexpected issues."));
|
||||
});
|
||||
|
||||
test("customRulesAsyncIgnoresSyncReturn", (t) => {
|
||||
t.plan(1);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -2011,7 +2013,7 @@ test("customRulesAsyncIgnoresSyncReturn", (t) => {
|
|||
}
|
||||
]
|
||||
};
|
||||
return markdownlint.promises.markdownlint(options)
|
||||
return lintPromise(options)
|
||||
.then((actual) => t.deepEqual(actual, expected, "Unexpected issues."));
|
||||
});
|
||||
|
||||
|
|
@ -2044,7 +2046,7 @@ for (const flavor of [
|
|||
]
|
||||
]) {
|
||||
const [ name, func ] = flavor;
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule[]} */
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
const customRule = [
|
||||
{
|
||||
"names": [ "name" ],
|
||||
|
|
@ -2074,7 +2076,7 @@ for (const flavor of [
|
|||
|
||||
test(`${name}${subname}UnhandledAsync`, (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
// @ts-ignore
|
||||
"customRules": customRule,
|
||||
// @ts-ignore
|
||||
|
|
@ -2093,7 +2095,7 @@ for (const flavor of [
|
|||
|
||||
test(`${name}${subname}HandledAsync`, (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
// @ts-ignore
|
||||
"customRules": customRule,
|
||||
// @ts-ignore
|
||||
|
|
@ -2111,7 +2113,7 @@ for (const flavor of [
|
|||
test(`${name}${subname}UnhandledSync`, (t) => {
|
||||
t.plan(1);
|
||||
t.throws(
|
||||
() => markdownlint.sync({
|
||||
() => lintSync({
|
||||
// @ts-ignore
|
||||
"customRules": customRule,
|
||||
// @ts-ignore
|
||||
|
|
@ -2128,7 +2130,7 @@ for (const flavor of [
|
|||
|
||||
test(`${name}${subname}HandledSync`, (t) => {
|
||||
t.plan(1);
|
||||
const actualResult = markdownlint.sync({
|
||||
const actualResult = lintSync({
|
||||
// @ts-ignore
|
||||
"customRules": customRule,
|
||||
// @ts-ignore
|
||||
|
|
@ -2181,7 +2183,7 @@ for (const flavor of [
|
|||
]
|
||||
]) {
|
||||
const [ name, func ] = flavor;
|
||||
/** @type {import("../lib/markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
const customRule = {
|
||||
"names": [ "name" ],
|
||||
"description": "description",
|
||||
|
|
@ -2196,7 +2198,7 @@ for (const flavor of [
|
|||
|
||||
test(`${name}${subname}Unhandled`, (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
// @ts-ignore
|
||||
"customRules": [ customRule ],
|
||||
// @ts-ignore
|
||||
|
|
@ -2215,7 +2217,7 @@ for (const flavor of [
|
|||
|
||||
test(`${name}${subname}Handled`, (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
// @ts-ignore
|
||||
"customRules": [ customRule ],
|
||||
// @ts-ignore
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
import test from "ava";
|
||||
import { globby } from "globby";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
import { lint } from "markdownlint/promise";
|
||||
|
||||
// Parses all Markdown files in all package dependencies
|
||||
test("parseAllFiles", async(t) => {
|
||||
t.plan(1);
|
||||
const files = await globby("**/*.{md,markdown}");
|
||||
await markdownlint.promises.markdownlint({ files });
|
||||
await lint({ files });
|
||||
t.pass();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "ava";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
import { lint } from "markdownlint/sync";
|
||||
|
||||
// Simulates typing each test file to validate handling of partial input
|
||||
const files = fs
|
||||
|
|
@ -18,7 +18,7 @@ for (const file of files) {
|
|||
}
|
||||
test.serial(`type ${file}`, (t) => {
|
||||
t.plan(1);
|
||||
markdownlint.sync({
|
||||
lint({
|
||||
// @ts-ignore
|
||||
strings,
|
||||
"resultVersion": 0
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
import test from "ava";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
import { applyFix, applyFixes } from "markdownlint";
|
||||
|
||||
test("applyFix", (t) => {
|
||||
t.plan(4);
|
||||
|
|
@ -46,7 +46,7 @@ test("applyFix", (t) => {
|
|||
for (const testCase of testCases) {
|
||||
const [ line, fixInfo, lineEnding, expected ] = testCase;
|
||||
// @ts-ignore
|
||||
const actual = markdownlint.applyFix(line, fixInfo, lineEnding);
|
||||
const actual = applyFix(line, fixInfo, lineEnding);
|
||||
t.is(actual, String(expected), "Incorrect fix applied.");
|
||||
}
|
||||
});
|
||||
|
|
@ -524,7 +524,7 @@ test("applyFixes", (t) => {
|
|||
for (const testCase of testCases) {
|
||||
const [ input, errors, expected ] = testCase;
|
||||
// @ts-ignore
|
||||
const actual = markdownlint.applyFixes(input, errors);
|
||||
const actual = applyFixes(input, errors);
|
||||
t.is(actual, String(expected), "Incorrect fix applied.");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ import test from "ava";
|
|||
import { characterEntities } from "character-entities";
|
||||
import { gemoji } from "gemoji";
|
||||
import helpers from "../helpers/helpers.cjs";
|
||||
import libMarkdownlint from "../lib/markdownlint.mjs";
|
||||
const { markdownlint } = libMarkdownlint.promises;
|
||||
import { lint } from "markdownlint/promise";
|
||||
import { forEachInlineCodeSpan } from "../lib/markdownit.cjs";
|
||||
import { getReferenceLinkImageData } from "../lib/cache.mjs";
|
||||
|
||||
|
|
@ -387,7 +386,7 @@ test("expandTildePath", (t) => {
|
|||
|
||||
test("getReferenceLinkImageData().shortcuts", (t) => {
|
||||
t.plan(1);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -415,7 +414,7 @@ Empty bracket pair: [text4[]]
|
|||
`
|
||||
}
|
||||
};
|
||||
return markdownlint(options).then(() => null);
|
||||
return lint(options).then(() => null);
|
||||
});
|
||||
|
||||
test("endOfLineHtmlEntityRe", (t) => {
|
||||
|
|
|
|||
|
|
@ -3,15 +3,14 @@
|
|||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
import { availableParallelism } from "node:os";
|
||||
import { Worker } from "node:worker_threads";
|
||||
import { lint } from "markdownlint/sync";
|
||||
import { __filename } from "./esm-helpers.mjs";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
const markdownlintSync = markdownlint.sync;
|
||||
|
||||
/**
|
||||
* Lint specified Markdown files (using multiple threads).
|
||||
*
|
||||
* @param {import("../lib/markdownlint.mjs").Options} options Configuration options.
|
||||
* @returns {Promise<import("../lib/markdownlint.mjs").LintResults>} Results object.
|
||||
* @param {import("markdownlint").Options} options Configuration options.
|
||||
* @returns {Promise<import("markdownlint").LintResults>} Results object.
|
||||
*/
|
||||
export function markdownlintParallel(options) {
|
||||
const workerCount = availableParallelism();
|
||||
|
|
@ -30,7 +29,7 @@ export function markdownlintParallel(options) {
|
|||
}));
|
||||
}
|
||||
return Promise.all(promises).then((workerResults) => {
|
||||
const combinedResults = markdownlintSync(null);
|
||||
const combinedResults = lint(null);
|
||||
for (const workerResult of workerResults) {
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (const result in workerResult) {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ const { join } = path.posix;
|
|||
import { globby } from "globby";
|
||||
import jsoncParser from "jsonc-parser";
|
||||
import jsYaml from "js-yaml";
|
||||
import library from "../lib/markdownlint.mjs";
|
||||
const { markdownlint, readConfig } = library.promises;
|
||||
import { lint, readConfig } from "markdownlint/promise";
|
||||
import { markdownlintParallel } from "./markdownlint-test-parallel.mjs";
|
||||
|
||||
/**
|
||||
|
|
@ -39,7 +38,7 @@ export function lintTestRepo(t, globPatterns, configPath, parallel) {
|
|||
v
|
||||
])
|
||||
);
|
||||
return (parallel ? markdownlintParallel : markdownlint)({
|
||||
return (parallel ? markdownlintParallel : lint)({
|
||||
files,
|
||||
config
|
||||
}).then((results) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
import test from "ava";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
import { lint as lintAsync } from "markdownlint/async";
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
import { importWithTypeJson } from "./esm-helpers.mjs";
|
||||
const packageJson = await importWithTypeJson(import.meta, "../package.json");
|
||||
const { homepage, version } = packageJson;
|
||||
|
|
@ -13,7 +14,7 @@ test("resultObjectToStringNotEnumerable", (t) => new Promise((resolve) => {
|
|||
"string": "# Heading"
|
||||
}
|
||||
};
|
||||
markdownlint(options, function callback(err, result) {
|
||||
lintAsync(options, function callback(err, result) {
|
||||
t.falsy(err);
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (const property in result) {
|
||||
|
|
@ -36,7 +37,7 @@ test("resultFormattingV0", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -95,7 +96,7 @@ test("resultFormattingSyncV0", (t) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
const actualResult = markdownlint.sync(options);
|
||||
const actualResult = lintSync(options);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
"MD018": [ 1 ],
|
||||
|
|
@ -154,7 +155,7 @@ test("resultFormattingV1", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 1
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"truncate": [
|
||||
|
|
@ -258,7 +259,7 @@ test("resultFormattingV2", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 2
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"truncate": [
|
||||
|
|
@ -352,7 +353,7 @@ test("resultFormattingV3", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 3
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"input": [
|
||||
|
|
@ -467,7 +468,7 @@ test("onePerLineResultVersion0", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"input": {
|
||||
|
|
@ -488,7 +489,7 @@ test("onePerLineResultVersion1", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 1
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"input": [
|
||||
|
|
@ -519,7 +520,7 @@ test("onePerLineResultVersion2", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 2
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"input": [
|
||||
|
|
@ -548,7 +549,7 @@ test("manyPerLineResultVersion3", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 3
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"input": [
|
||||
|
|
@ -597,7 +598,7 @@ test("frontMatterResultVersion3", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 3
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"input": [
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@
|
|||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import test from "ava";
|
||||
import libMarkdownlint from "../lib/markdownlint.mjs";
|
||||
const { applyFixes, promises } = libMarkdownlint;
|
||||
const { markdownlint } = promises;
|
||||
import { lint } from "markdownlint/promise";
|
||||
import { applyFixes } from "markdownlint";
|
||||
import helpers from "../helpers/helpers.cjs";
|
||||
import { fixableRuleNames } from "../lib/constants.mjs";
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ function createTestForFile(file) {
|
|||
// Read and lint Markdown test file
|
||||
Promise.all([
|
||||
fs.readFile(file, "utf8"),
|
||||
markdownlint({
|
||||
lint({
|
||||
"files": [ file ]
|
||||
})
|
||||
])
|
||||
|
|
@ -89,7 +88,7 @@ function createTestForFile(file) {
|
|||
fixed
|
||||
});
|
||||
// Identify missing fixes
|
||||
return markdownlint({
|
||||
return lint({
|
||||
"strings": {
|
||||
"input": fixed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
import { parentPort, workerData } from "node:worker_threads";
|
||||
import library from "../lib/markdownlint.mjs";
|
||||
const { markdownlint } = library.promises;
|
||||
import { lint } from "markdownlint/promise";
|
||||
|
||||
const lintResults = await markdownlint(workerData);
|
||||
const lintResults = await lint(workerData);
|
||||
// @ts-ignore
|
||||
parentPort
|
||||
// eslint-disable-next-line unicorn/require-post-message-target-origin
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ import pluginInline from "markdown-it-for-inline";
|
|||
import pluginSub from "markdown-it-sub";
|
||||
import pluginSup from "markdown-it-sup";
|
||||
import test from "ava";
|
||||
import markdownlint from "../lib/markdownlint.mjs";
|
||||
import { getVersion } from "markdownlint";
|
||||
import { lint as lintAsync } from "markdownlint/async";
|
||||
import { lint as lintPromise } from "markdownlint/promise";
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
import * as constants from "../lib/constants.mjs";
|
||||
import rules from "../lib/rules.mjs";
|
||||
import customRules from "./rules/rules.cjs";
|
||||
|
|
@ -36,7 +39,7 @@ test("simpleAsync", (t) => new Promise((resolve) => {
|
|||
};
|
||||
const expected = "content: 1: MD047/single-trailing-newline " +
|
||||
"Files should end with a single newline character";
|
||||
markdownlint(options, (err, actual) => {
|
||||
lintAsync(options, (err, actual) => {
|
||||
t.falsy(err);
|
||||
// @ts-ignore
|
||||
t.is(actual.toString(), expected, "Unexpected results.");
|
||||
|
|
@ -53,7 +56,7 @@ test("simpleSync", (t) => {
|
|||
};
|
||||
const expected = "content: 1: MD047/single-trailing-newline " +
|
||||
"Files should end with a single newline character";
|
||||
const actual = markdownlint.sync(options).toString();
|
||||
const actual = lintSync(options).toString();
|
||||
t.is(actual, expected, "Unexpected results.");
|
||||
});
|
||||
|
||||
|
|
@ -66,7 +69,7 @@ test("simplePromise", (t) => {
|
|||
};
|
||||
const expected = "content: 1: MD047/single-trailing-newline " +
|
||||
"Files should end with a single newline character";
|
||||
return markdownlint.promises.markdownlint(options).then((actual) => {
|
||||
return lintPromise(options).then((actual) => {
|
||||
t.is(actual.toString(), expected, "Unexpected results.");
|
||||
});
|
||||
});
|
||||
|
|
@ -90,7 +93,7 @@ test("projectFiles", (t) => {
|
|||
"config": require("../.markdownlint.json")
|
||||
};
|
||||
// @ts-ignore
|
||||
return markdownlint.promises.markdownlint(options).then((actual) => {
|
||||
return lintPromise(options).then((actual) => {
|
||||
const expected = {};
|
||||
for (const file of files) {
|
||||
expected[file] = [];
|
||||
|
|
@ -118,7 +121,7 @@ test("projectFilesExtendedAscii", (t) => {
|
|||
"customRules": [ require("markdownlint-rule-extended-ascii") ]
|
||||
};
|
||||
// @ts-ignore
|
||||
return markdownlint.promises.markdownlint(options).then((actual) => {
|
||||
return lintPromise(options).then((actual) => {
|
||||
const expected = {};
|
||||
for (const file of files) {
|
||||
expected[file] = [];
|
||||
|
|
@ -142,7 +145,7 @@ test("stringInputLineEndings", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"cr": { "MD018": [ 3 ] },
|
||||
|
|
@ -168,7 +171,7 @@ test("inputOnlyNewline", (t) => new Promise((resolve) => {
|
|||
"default": false
|
||||
}
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"cr": [],
|
||||
|
|
@ -193,7 +196,7 @@ test("defaultTrue", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -224,7 +227,7 @@ test("defaultFalse", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {},
|
||||
|
|
@ -247,7 +250,7 @@ test("defaultUndefined", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -279,7 +282,7 @@ test("disableRules", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -308,7 +311,7 @@ test("enableRules", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -340,7 +343,7 @@ test("enableRulesMixedCase", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -371,7 +374,7 @@ test("disableTag", (t) => new Promise((resolve) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -401,7 +404,7 @@ test("enableTag", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -430,7 +433,7 @@ test("enableTagMixedCase", (t) => new Promise((resolve) => {
|
|||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
markdownlint(options, function callback(err, actualResult) {
|
||||
lintAsync(options, function callback(err, actualResult) {
|
||||
t.falsy(err);
|
||||
const expectedResult = {
|
||||
"./test/atx_heading_spacing.md": {
|
||||
|
|
@ -464,7 +467,7 @@ test("styleAll", async(t) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
const actualResult = await markdownlint.promises.markdownlint(options);
|
||||
const actualResult = await lintPromise(options);
|
||||
const expectedResult = {
|
||||
"./test/break-all-the-rules.md": {
|
||||
"MD001": [ 3 ],
|
||||
|
|
@ -527,7 +530,7 @@ test("styleRelaxed", async(t) => {
|
|||
"noInlineConfig": true,
|
||||
"resultVersion": 0
|
||||
};
|
||||
const actualResult = await markdownlint.promises.markdownlint(options);
|
||||
const actualResult = await lintPromise(options);
|
||||
const expectedResult = {
|
||||
"./test/break-all-the-rules.md": {
|
||||
"MD001": [ 3 ],
|
||||
|
|
@ -569,7 +572,7 @@ test("styleRelaxed", async(t) => {
|
|||
|
||||
test("nullFrontMatter", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
"content": "---\n\t\n---\n# Heading\n"
|
||||
},
|
||||
|
|
@ -592,7 +595,7 @@ test("nullFrontMatter", (t) => new Promise((resolve) => {
|
|||
|
||||
test("customFrontMatter", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
"content": "<head>\n\t\n</head>\n# Heading\n"
|
||||
},
|
||||
|
|
@ -613,7 +616,7 @@ test("customFrontMatter", (t) => new Promise((resolve) => {
|
|||
|
||||
test("noInlineConfig", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
"content": [
|
||||
"# Heading",
|
||||
|
|
@ -646,7 +649,7 @@ test("noInlineConfig", (t) => new Promise((resolve) => {
|
|||
|
||||
test("readmeHeadings", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"files": "README.md",
|
||||
"noInlineConfig": true,
|
||||
"config": {
|
||||
|
|
@ -713,7 +716,7 @@ test("filesArrayNotModified", (t) => new Promise((resolve) => {
|
|||
"./test/first_heading_bad_atx.md"
|
||||
];
|
||||
const expectedFiles = [ ...files ];
|
||||
markdownlint({ "files": files }, function callback(err) {
|
||||
lintAsync({ "files": files }, function callback(err) {
|
||||
t.falsy(err);
|
||||
t.deepEqual(files, expectedFiles, "Files modified.");
|
||||
resolve();
|
||||
|
|
@ -722,7 +725,7 @@ test("filesArrayNotModified", (t) => new Promise((resolve) => {
|
|||
|
||||
test("filesArrayAsString", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"files": "README.md",
|
||||
"noInlineConfig": true,
|
||||
"config": {
|
||||
|
|
@ -739,7 +742,7 @@ test("filesArrayAsString", (t) => new Promise((resolve) => {
|
|||
|
||||
test("missingOptions", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint(null, function callback(err, result) {
|
||||
lintAsync(null, function callback(err, result) {
|
||||
t.falsy(err);
|
||||
t.deepEqual(
|
||||
result,
|
||||
|
|
@ -752,7 +755,7 @@ test("missingOptions", (t) => new Promise((resolve) => {
|
|||
|
||||
test("missingFilesAndStrings", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({}, function callback(err, result) {
|
||||
lintAsync({}, function callback(err, result) {
|
||||
t.falsy(err);
|
||||
t.truthy(result, "Did not get result for missing files/strings.");
|
||||
resolve();
|
||||
|
|
@ -762,12 +765,12 @@ test("missingFilesAndStrings", (t) => new Promise((resolve) => {
|
|||
test("missingCallback", (t) => {
|
||||
t.plan(0);
|
||||
// @ts-ignore
|
||||
markdownlint();
|
||||
lintAsync();
|
||||
});
|
||||
|
||||
test("badFile", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"files": [ "./badFile" ]
|
||||
}, function callback(err, result) {
|
||||
t.truthy(err, "Did not get an error for bad file.");
|
||||
|
|
@ -783,7 +786,7 @@ test("badFileSync", (t) => {
|
|||
t.plan(1);
|
||||
t.throws(
|
||||
function badFileCall() {
|
||||
markdownlint.sync({
|
||||
lintSync({
|
||||
"files": [ "./badFile" ]
|
||||
});
|
||||
},
|
||||
|
|
@ -796,7 +799,7 @@ test("badFileSync", (t) => {
|
|||
|
||||
test("badFilePromise", (t) => new Promise((resolve) => {
|
||||
t.plan(3);
|
||||
markdownlint.promises.markdownlint({
|
||||
lintPromise({
|
||||
"files": [ "./badFile" ]
|
||||
}).then(
|
||||
null,
|
||||
|
|
@ -811,7 +814,7 @@ test("badFilePromise", (t) => new Promise((resolve) => {
|
|||
|
||||
test("missingStringValue", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
// @ts-ignore
|
||||
"undefined": undefined,
|
||||
|
|
@ -840,7 +843,7 @@ test("customFileSystemSync", (t) => {
|
|||
return "# Heading";
|
||||
}
|
||||
};
|
||||
const result = markdownlint.sync({
|
||||
const result = lintSync({
|
||||
"files": file,
|
||||
"fs": fsApi
|
||||
});
|
||||
|
|
@ -856,7 +859,7 @@ test("customFileSystemAsync", (t) => new Promise((resolve) => {
|
|||
cb(null, "# Heading");
|
||||
}
|
||||
};
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"files": file,
|
||||
"fs": fsApi
|
||||
}, function callback(err, result) {
|
||||
|
|
@ -1101,7 +1104,7 @@ test("someCustomRulesHaveValidUrl", (t) => {
|
|||
|
||||
test("markdownItPluginsSingle", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
"string": "# Heading\n\nText\n"
|
||||
},
|
||||
|
|
@ -1120,7 +1123,7 @@ test("markdownItPluginsSingle", (t) => new Promise((resolve) => {
|
|||
|
||||
test("markdownItPluginsMultiple", (t) => new Promise((resolve) => {
|
||||
t.plan(4);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
"string": "# Heading\n\nText H~2~0 text 29^th^ text\n"
|
||||
},
|
||||
|
|
@ -1142,7 +1145,7 @@ test("markdownItPluginsMultiple", (t) => new Promise((resolve) => {
|
|||
|
||||
test("markdownItPluginsNoMarkdownIt", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
"string": "# Heading\n\nText\n"
|
||||
},
|
||||
|
|
@ -1159,7 +1162,7 @@ test("markdownItPluginsNoMarkdownIt", (t) => new Promise((resolve) => {
|
|||
|
||||
test("markdownItPluginsUnusedUncalled", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"config": {
|
||||
"default": false
|
||||
},
|
||||
|
|
@ -1181,7 +1184,7 @@ test("markdownItPluginsUnusedUncalled", (t) => new Promise((resolve) => {
|
|||
|
||||
test("Pandoc footnote", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
markdownlint({
|
||||
lintAsync({
|
||||
"strings": {
|
||||
"string":
|
||||
`# Heading
|
||||
|
|
@ -1206,7 +1209,7 @@ Text with: [^footnote]
|
|||
|
||||
test("token-map-spans", (t) => {
|
||||
t.plan(38);
|
||||
/** @type {import("../lib/markdownlint.mjs").Options} */
|
||||
/** @type {import("markdownlint").Options} */
|
||||
const options = {
|
||||
"customRules": [
|
||||
{
|
||||
|
|
@ -1239,7 +1242,7 @@ test("token-map-spans", (t) => {
|
|||
],
|
||||
"files": [ "./test/token-map-spans.md" ]
|
||||
};
|
||||
markdownlint.sync(options);
|
||||
lintSync(options);
|
||||
});
|
||||
|
||||
test("configParsersInvalid", async(t) => {
|
||||
|
|
@ -1258,7 +1261,7 @@ test("configParsersInvalid", async(t) => {
|
|||
};
|
||||
const expected = "content: 1: MD041/first-line-heading/first-line-h1 " +
|
||||
"First line in a file should be a top-level heading [Context: \"Text\"]";
|
||||
const actual = await markdownlint.promises.markdownlint(options);
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), expected, "Unexpected results.");
|
||||
});
|
||||
|
||||
|
|
@ -1278,7 +1281,7 @@ test("configParsersJSON", async(t) => {
|
|||
].join("\n")
|
||||
}
|
||||
};
|
||||
const actual = await markdownlint.promises.markdownlint(options);
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
});
|
||||
|
||||
|
|
@ -1300,7 +1303,7 @@ test("configParsersJSONC", async(t) => {
|
|||
},
|
||||
"configParsers": [ jsoncParser.parse ]
|
||||
};
|
||||
const actual = await markdownlint.promises.markdownlint(options);
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
});
|
||||
|
||||
|
|
@ -1321,7 +1324,7 @@ test("configParsersYAML", async(t) => {
|
|||
"configParsers": [ jsYaml.load ]
|
||||
};
|
||||
// @ts-ignore
|
||||
const actual = await markdownlint.promises.markdownlint(options);
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
});
|
||||
|
||||
|
|
@ -1344,13 +1347,13 @@ test("configParsersTOML", async(t) => {
|
|||
require("toml").parse
|
||||
]
|
||||
};
|
||||
const actual = await markdownlint.promises.markdownlint(options);
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
});
|
||||
|
||||
test("getVersion", (t) => {
|
||||
t.plan(1);
|
||||
const actual = markdownlint.getVersion();
|
||||
const actual = getVersion();
|
||||
const expected = packageJson.version;
|
||||
t.is(actual, expected, "Version string not correct.");
|
||||
});
|
||||
|
|
@ -1364,7 +1367,10 @@ test("constants", (t) => {
|
|||
});
|
||||
|
||||
const exportMappings = new Map([
|
||||
[ ".", "../lib/markdownlint.mjs" ],
|
||||
[ ".", "../lib/exports.mjs" ],
|
||||
[ "./async", "../lib/exports-async.mjs" ],
|
||||
[ "./promise", "../lib/exports-promise.mjs" ],
|
||||
[ "./sync", "../lib/exports-sync.mjs" ],
|
||||
[ "./helpers", "../helpers/helpers.cjs" ],
|
||||
[ "./style/all", "../style/all.json" ],
|
||||
[ "./style/cirosantilli", "../style/cirosantilli.json" ],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { readFile } from "node:fs/promises";
|
||||
import library from "../lib/markdownlint.mjs";
|
||||
const markdownlint = library.promises.markdownlint;
|
||||
import { lint } from "markdownlint/promise";
|
||||
|
||||
const strings = {
|
||||
"CHANGELOG": await readFile("CHANGELOG.md", "utf8"),
|
||||
|
|
@ -14,7 +13,7 @@ const strings = {
|
|||
const start = new Date();
|
||||
for (let i = 0; i < 250; i++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await markdownlint({ strings });
|
||||
await lint({ strings });
|
||||
}
|
||||
const end = new Date();
|
||||
// eslint-disable-next-line no-console
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type {import("../../lib/markdownlint.mjs").Rule[]} */
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
module.exports = [
|
||||
|
||||
// micromark parser (preferred)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type {import("../../lib/markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "every-n-lines" ],
|
||||
"description": "Rule that reports an error every N lines",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type {import("../../lib/markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "first-line" ],
|
||||
"description": "Rule that reports an error for the first line",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @type {import("../../lib/markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
||||
"description": "Rule that reports an error for lines with the letters 'EX'",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const eslint = require("eslint");
|
|||
const linter = new eslint.Linter();
|
||||
const languageJavaScript = /js|javascript/i;
|
||||
|
||||
/** @type {import("../../lib/markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "lint-javascript" ],
|
||||
"description": "Rule that lints JavaScript code",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
const { parse, printParseErrorCode } = require("jsonc-parser");
|
||||
|
||||
/** @type {import("../../lib/markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "validate-json" ],
|
||||
"description": "Rule that validates JSON code",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue