2019-10-30 20:37:06 -07:00
|
|
|
// @ts-check
|
|
|
|
|
2015-02-23 23:39:20 -08:00
|
|
|
"use strict";
|
|
|
|
|
2022-08-16 04:01:53 +00:00
|
|
|
const fs = require("node:fs");
|
|
|
|
const path = require("node:path");
|
2021-01-21 19:50:57 -08:00
|
|
|
const jsYaml = require("js-yaml");
|
2018-04-27 22:05:34 -07:00
|
|
|
const md = require("markdown-it")();
|
2019-01-19 12:52:13 -08:00
|
|
|
const pluginInline = require("markdown-it-for-inline");
|
|
|
|
const pluginSub = require("markdown-it-sub");
|
|
|
|
const pluginSup = require("markdown-it-sup");
|
2020-10-16 20:59:04 -07:00
|
|
|
const pluginTexMath = require("markdown-it-texmath");
|
2021-01-10 20:46:00 -08:00
|
|
|
const test = require("ava").default;
|
2018-04-27 22:05:34 -07:00
|
|
|
const tv4 = require("tv4");
|
2022-10-02 19:28:54 -07:00
|
|
|
const { "exports": packageExports, homepage, version } =
|
|
|
|
require("../package.json");
|
2018-04-27 22:05:34 -07:00
|
|
|
const markdownlint = require("../lib/markdownlint");
|
2021-11-10 21:48:15 -08:00
|
|
|
const constants = require("../lib/constants");
|
2018-04-27 22:05:34 -07:00
|
|
|
const rules = require("../lib/rules");
|
2018-07-20 22:31:41 -07:00
|
|
|
const customRules = require("./rules/rules.js");
|
2018-04-27 22:05:34 -07:00
|
|
|
const configSchema = require("../schema/markdownlint-config-schema.json");
|
2015-02-27 22:06:54 -08:00
|
|
|
|
2020-10-16 20:59:04 -07:00
|
|
|
const pluginTexMathOptions = {
|
|
|
|
"engine": {
|
|
|
|
"renderToString": () => ""
|
|
|
|
}
|
|
|
|
};
|
2021-11-11 22:37:16 -08:00
|
|
|
const deprecatedRuleNames = new Set(constants.deprecatedRuleNames);
|
2020-09-15 21:48:00 -07:00
|
|
|
const configSchemaStrict = {
|
|
|
|
...configSchema,
|
|
|
|
"additionalProperties": false
|
|
|
|
};
|
2019-07-08 13:10:08 -05:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("simpleAsync", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2020-09-13 12:58:09 -07:00
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": "# Heading"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const expected = "content: 1: MD047/single-trailing-newline " +
|
|
|
|
"Files should end with a single newline character";
|
|
|
|
markdownlint(options, (err, actual) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
|
|
|
t.is(actual.toString(), expected, "Unexpected results.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-09-13 12:58:09 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2020-09-13 12:58:09 -07:00
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("simpleSync", (t) => {
|
|
|
|
t.plan(1);
|
2020-09-13 12:58:09 -07:00
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": "# Heading"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const expected = "content: 1: MD047/single-trailing-newline " +
|
|
|
|
"Files should end with a single newline character";
|
|
|
|
const actual = markdownlint.sync(options).toString();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(actual, expected, "Unexpected results.");
|
2020-09-13 12:58:09 -07:00
|
|
|
});
|
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("simplePromise", (t) => {
|
|
|
|
t.plan(1);
|
2020-09-13 12:58:09 -07:00
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": "# Heading"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const expected = "content: 1: MD047/single-trailing-newline " +
|
|
|
|
"Files should end with a single newline character";
|
2021-01-10 20:46:00 -08:00
|
|
|
return markdownlint.promises.markdownlint(options).then((actual) => {
|
|
|
|
t.is(actual.toString(), expected, "Unexpected results.");
|
2020-09-13 12:58:09 -07:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("projectFilesNoInlineConfig", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2018-06-24 20:01:44 -07:00
|
|
|
"files": [
|
|
|
|
"README.md",
|
2019-04-13 11:18:57 -07:00
|
|
|
"CONTRIBUTING.md",
|
2020-09-06 16:31:26 -07:00
|
|
|
"doc/CustomRules.md",
|
2021-08-13 22:18:39 -07:00
|
|
|
"doc/Prettier.md",
|
2019-04-13 11:18:57 -07:00
|
|
|
"helpers/README.md"
|
2018-06-24 20:01:44 -07:00
|
|
|
],
|
2022-03-10 06:07:07 +00:00
|
|
|
"config": require("../.markdownlint.json"),
|
2021-12-23 20:52:17 +00:00
|
|
|
"customRules": [ require("markdownlint-rule-github-internal-links") ],
|
|
|
|
"noInlineConfig": true
|
2015-03-12 23:42:06 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-06-24 20:01:44 -07:00
|
|
|
const expected = {
|
|
|
|
"README.md": [],
|
2019-04-13 11:18:57 -07:00
|
|
|
"CONTRIBUTING.md": [],
|
2020-09-06 16:31:26 -07:00
|
|
|
"doc/CustomRules.md": [],
|
2021-08-13 22:18:39 -07:00
|
|
|
"doc/Prettier.md": [],
|
2019-04-13 11:18:57 -07:00
|
|
|
"helpers/README.md": []
|
2018-06-24 20:01:44 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actual, expected, "Issue(s) with project files.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-12 23:42:06 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-12 23:42:06 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("projectFilesInlineConfig", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2020-09-06 16:31:26 -07:00
|
|
|
const options = {
|
|
|
|
"files": [ "doc/Rules.md" ],
|
2022-04-10 05:37:57 +00:00
|
|
|
"config": require("../.markdownlint.json")
|
2020-09-06 16:31:26 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2020-09-06 16:31:26 -07:00
|
|
|
const expected = {
|
|
|
|
"doc/Rules.md": []
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actual, expected, "Issue(s) with project files.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-09-07 20:05:36 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2020-09-07 20:05:36 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("stringInputLineEndings", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-04-29 18:46:52 -07:00
|
|
|
"strings": {
|
2019-04-05 12:36:12 +02:00
|
|
|
"cr": "One\rTwo\r#Three\n",
|
|
|
|
"lf": "One\nTwo\n#Three\n",
|
|
|
|
"crlf": "One\r\nTwo\r\n#Three\n",
|
2019-09-14 13:53:35 -07:00
|
|
|
"mixed": "One\rTwo\n#Three\n"
|
2015-07-20 22:06:48 -07:00
|
|
|
},
|
2020-11-15 17:03:20 -08:00
|
|
|
"config": {
|
|
|
|
"MD041": false
|
|
|
|
},
|
2017-07-05 21:53:21 -07:00
|
|
|
"resultVersion": 0
|
2015-04-29 18:46:52 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2015-05-02 17:41:41 -07:00
|
|
|
"cr": { "MD018": [ 3 ] },
|
2015-04-29 18:46:52 -07:00
|
|
|
"lf": { "MD018": [ 3 ] },
|
|
|
|
"crlf": { "MD018": [ 3 ] },
|
2019-09-14 13:53:35 -07:00
|
|
|
"mixed": { "MD018": [ 3 ] }
|
2015-04-29 18:46:52 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-04-29 18:46:52 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-04-29 18:46:52 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("inputOnlyNewline", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-07-22 23:17:08 -07:00
|
|
|
"strings": {
|
|
|
|
"cr": "\r",
|
|
|
|
"lf": "\n",
|
|
|
|
"crlf": "\r\n"
|
|
|
|
},
|
|
|
|
"config": {
|
|
|
|
"default": false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2017-07-05 21:53:21 -07:00
|
|
|
"cr": [],
|
|
|
|
"lf": [],
|
|
|
|
"crlf": []
|
2015-07-22 23:17:08 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-07-22 23:17:08 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-07-22 23:17:08 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("defaultTrue", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-16 23:25:06 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-16 23:25:06 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"default": true
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-03-16 23:25:06 -07:00
|
|
|
"MD018": [ 1 ],
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD019": [ 3, 5 ],
|
|
|
|
"MD041": [ 1 ]
|
2015-03-16 23:25:06 -07:00
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD041": [ 1 ]
|
2015-03-16 23:25:06 -07:00
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-16 23:25:06 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-16 23:25:06 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("defaultFalse", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-16 23:25:06 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-16 23:25:06 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"default": false
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {},
|
|
|
|
"./test/first_heading_bad_atx.md": {}
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-16 23:25:06 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-16 23:25:06 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("defaultUndefined", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-18 22:45:51 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-18 22:45:51 -07:00
|
|
|
],
|
2017-07-05 21:53:21 -07:00
|
|
|
"config": {},
|
|
|
|
"resultVersion": 0
|
2015-03-18 22:45:51 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-03-18 22:45:51 -07:00
|
|
|
"MD018": [ 1 ],
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD019": [ 3, 5 ],
|
|
|
|
"MD041": [ 1 ]
|
2015-03-18 22:45:51 -07:00
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD041": [ 1 ]
|
2015-03-18 22:45:51 -07:00
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-18 22:45:51 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-18 22:45:51 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("disableRules", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-16 23:25:06 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-16 23:25:06 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"MD002": false,
|
|
|
|
"default": true,
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD019": false,
|
2016-01-12 21:29:17 -08:00
|
|
|
"first-line-h1": false
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-03-16 23:25:06 -07:00
|
|
|
"MD018": [ 1 ]
|
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {}
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-16 23:25:06 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-16 23:25:06 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("enableRules", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-16 23:25:06 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-16 23:25:06 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"MD002": true,
|
|
|
|
"default": false,
|
2016-01-12 21:29:17 -08:00
|
|
|
"no-multiple-space-atx": true
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-03-16 23:25:06 -07:00
|
|
|
"MD002": [ 3 ],
|
|
|
|
"MD019": [ 3, 5 ]
|
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {
|
2015-03-16 23:25:06 -07:00
|
|
|
"MD002": [ 1 ]
|
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-16 23:25:06 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-16 23:25:06 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("enableRulesMixedCase", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-09-21 23:21:17 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-09-21 23:21:17 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"Md002": true,
|
|
|
|
"DeFaUlT": false,
|
2016-01-12 21:29:17 -08:00
|
|
|
"nO-mUlTiPlE-sPaCe-AtX": true
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-09-21 23:21:17 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-09-21 23:21:17 -07:00
|
|
|
"MD002": [ 3 ],
|
|
|
|
"MD019": [ 3, 5 ]
|
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {
|
2015-09-21 23:21:17 -07:00
|
|
|
"MD002": [ 1 ]
|
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-09-21 23:21:17 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-09-21 23:21:17 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("disableTag", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-16 23:25:06 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-16 23:25:06 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"default": true,
|
|
|
|
"spaces": false
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD041": [ 1 ]
|
2015-03-16 23:25:06 -07:00
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD041": [ 1 ]
|
2015-03-16 23:25:06 -07:00
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-16 23:25:06 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-16 23:25:06 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("enableTag", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-16 23:25:06 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-16 23:25:06 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"default": false,
|
2015-09-26 16:55:33 -07:00
|
|
|
"spaces": true,
|
|
|
|
"notatag": true
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-03-16 23:25:06 -07:00
|
|
|
"MD018": [ 1 ],
|
|
|
|
"MD019": [ 3, 5 ]
|
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {}
|
2015-03-16 23:25:06 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-16 23:25:06 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-16 23:25:06 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("enableTagMixedCase", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-09-21 23:21:17 -07:00
|
|
|
"files": [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-09-21 23:21:17 -07:00
|
|
|
],
|
|
|
|
"config": {
|
|
|
|
"DeFaUlT": false,
|
2015-09-26 16:55:33 -07:00
|
|
|
"SpAcEs": true,
|
|
|
|
"NoTaTaG": true
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-09-21 23:21:17 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md": {
|
2015-09-21 23:21:17 -07:00
|
|
|
"MD018": [ 1 ],
|
|
|
|
"MD019": [ 3, 5 ]
|
|
|
|
},
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/first_heading_bad_atx.md": {}
|
2015-09-21 23:21:17 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-09-21 23:21:17 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-09-21 23:21:17 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("styleFiles", (t) => new Promise((resolve) => {
|
2022-10-02 19:28:54 -07:00
|
|
|
t.plan(7);
|
2015-03-17 22:34:47 -07:00
|
|
|
fs.readdir("./style", function readdir(err, files) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const file of files) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.truthy(require(path.join("../style", file)), "Unable to load/parse.");
|
2022-10-02 19:28:54 -07:00
|
|
|
const exportValue = `./style/${file}`;
|
|
|
|
const exportKey = exportValue.replace(/\.json$/, "");
|
|
|
|
t.is(packageExports[exportKey], exportValue);
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-17 22:34:47 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-17 22:34:47 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("styleAll", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-17 18:02:05 -07:00
|
|
|
"files": [ "./test/break-all-the-rules.md" ],
|
2017-07-05 21:53:21 -07:00
|
|
|
"config": require("../style/all.json"),
|
|
|
|
"resultVersion": 0
|
2015-03-17 18:02:05 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2015-03-17 18:02:05 -07:00
|
|
|
"./test/break-all-the-rules.md": {
|
|
|
|
"MD001": [ 3 ],
|
2019-09-08 16:51:00 -07:00
|
|
|
"MD003": [ 5, 31 ],
|
2015-03-17 18:02:05 -07:00
|
|
|
"MD004": [ 8 ],
|
|
|
|
"MD005": [ 12 ],
|
|
|
|
"MD007": [ 8, 11 ],
|
|
|
|
"MD009": [ 14 ],
|
|
|
|
"MD010": [ 14 ],
|
|
|
|
"MD011": [ 16 ],
|
|
|
|
"MD012": [ 18 ],
|
|
|
|
"MD013": [ 21 ],
|
|
|
|
"MD014": [ 23 ],
|
|
|
|
"MD018": [ 25 ],
|
|
|
|
"MD019": [ 27 ],
|
|
|
|
"MD020": [ 29 ],
|
2019-09-08 16:51:00 -07:00
|
|
|
"MD021": [ 31 ],
|
2019-10-08 21:10:02 -07:00
|
|
|
"MD022": [ 86 ],
|
2019-09-08 16:51:00 -07:00
|
|
|
"MD023": [ 40 ],
|
|
|
|
"MD024": [ 35 ],
|
2015-03-17 18:02:05 -07:00
|
|
|
"MD026": [ 40 ],
|
|
|
|
"MD027": [ 42 ],
|
|
|
|
"MD028": [ 43 ],
|
|
|
|
"MD029": [ 47 ],
|
|
|
|
"MD030": [ 8 ],
|
|
|
|
"MD031": [ 50 ],
|
2019-01-21 18:21:36 -08:00
|
|
|
"MD032": [ 7, 8, 51 ],
|
2015-04-16 09:39:04 -07:00
|
|
|
"MD033": [ 55 ],
|
|
|
|
"MD034": [ 57 ],
|
|
|
|
"MD035": [ 61 ],
|
|
|
|
"MD036": [ 65 ],
|
|
|
|
"MD037": [ 67 ],
|
|
|
|
"MD038": [ 69 ],
|
|
|
|
"MD039": [ 71 ],
|
2015-07-20 22:06:48 -07:00
|
|
|
"MD040": [ 73 ],
|
2016-06-27 22:19:02 -07:00
|
|
|
"MD041": [ 1 ],
|
2019-10-08 21:10:02 -07:00
|
|
|
"MD042": [ 81 ],
|
|
|
|
"MD045": [ 85 ],
|
|
|
|
"MD046": [ 49, 73, 77 ],
|
2022-06-01 20:23:08 -07:00
|
|
|
"MD047": [ 101 ],
|
2021-10-21 06:42:48 +02:00
|
|
|
"MD048": [ 77 ],
|
2021-10-24 06:54:58 +02:00
|
|
|
"MD049": [ 90 ],
|
2022-04-10 05:37:57 +00:00
|
|
|
"MD050": [ 94 ],
|
2022-06-01 20:23:08 -07:00
|
|
|
"MD051": [ 96 ],
|
|
|
|
"MD052": [ 98 ],
|
|
|
|
"MD053": [ 99 ]
|
2015-03-17 18:02:05 -07:00
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-17 18:02:05 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-17 18:02:05 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("styleRelaxed", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const options = {
|
2015-03-17 18:02:05 -07:00
|
|
|
"files": [ "./test/break-all-the-rules.md" ],
|
2017-07-05 21:53:21 -07:00
|
|
|
"config": require("../style/relaxed.json"),
|
|
|
|
"resultVersion": 0
|
2015-03-17 18:02:05 -07:00
|
|
|
};
|
|
|
|
markdownlint(options, function callback(err, actualResult) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2015-03-17 18:02:05 -07:00
|
|
|
"./test/break-all-the-rules.md": {
|
|
|
|
"MD001": [ 3 ],
|
2019-09-08 16:51:00 -07:00
|
|
|
"MD003": [ 5, 31 ],
|
2015-03-17 18:02:05 -07:00
|
|
|
"MD004": [ 8 ],
|
|
|
|
"MD005": [ 12 ],
|
|
|
|
"MD011": [ 16 ],
|
|
|
|
"MD014": [ 23 ],
|
|
|
|
"MD018": [ 25 ],
|
|
|
|
"MD019": [ 27 ],
|
|
|
|
"MD020": [ 29 ],
|
2019-09-08 16:51:00 -07:00
|
|
|
"MD021": [ 31 ],
|
2019-10-08 21:10:02 -07:00
|
|
|
"MD022": [ 86 ],
|
2019-09-08 16:51:00 -07:00
|
|
|
"MD023": [ 40 ],
|
|
|
|
"MD024": [ 35 ],
|
2015-03-17 18:02:05 -07:00
|
|
|
"MD026": [ 40 ],
|
|
|
|
"MD029": [ 47 ],
|
|
|
|
"MD031": [ 50 ],
|
2019-01-21 18:21:36 -08:00
|
|
|
"MD032": [ 7, 8, 51 ],
|
2015-04-16 09:39:04 -07:00
|
|
|
"MD035": [ 61 ],
|
2016-06-27 22:19:02 -07:00
|
|
|
"MD036": [ 65 ],
|
2019-10-08 21:10:02 -07:00
|
|
|
"MD042": [ 81 ],
|
|
|
|
"MD045": [ 85 ],
|
|
|
|
"MD046": [ 49, 73, 77 ],
|
2022-06-01 20:23:08 -07:00
|
|
|
"MD047": [ 101 ],
|
2021-10-21 06:42:48 +02:00
|
|
|
"MD048": [ 77 ],
|
2021-10-24 06:54:58 +02:00
|
|
|
"MD049": [ 90 ],
|
2022-04-10 05:37:57 +00:00
|
|
|
"MD050": [ 94 ],
|
2022-06-01 20:23:08 -07:00
|
|
|
"MD051": [ 96 ],
|
|
|
|
"MD052": [ 98 ],
|
|
|
|
"MD053": [ 99 ]
|
2015-03-17 18:02:05 -07:00
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actualResult, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-17 18:02:05 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-17 18:02:05 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("nullFrontMatter", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2015-07-25 22:18:30 -07:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
2018-03-19 23:39:42 +01:00
|
|
|
"content": "---\n\t\n---\n# Heading\n"
|
2015-07-25 22:18:30 -07:00
|
|
|
},
|
|
|
|
"frontMatter": null,
|
|
|
|
"config": {
|
|
|
|
"default": false,
|
|
|
|
"MD010": true
|
2017-07-05 21:53:21 -07:00
|
|
|
},
|
|
|
|
"resultVersion": 0
|
2015-07-25 22:18:30 -07:00
|
|
|
}, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2015-07-25 22:18:30 -07:00
|
|
|
"content": { "MD010": [ 2 ] }
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(result, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-07-25 22:18:30 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-07-25 22:18:30 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("customFrontMatter", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2015-07-25 22:18:30 -07:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
2018-03-19 23:39:42 +01:00
|
|
|
"content": "<head>\n\t\n</head>\n# Heading\n"
|
2015-07-25 22:18:30 -07:00
|
|
|
},
|
|
|
|
"frontMatter": /<head>[^]*<\/head>/,
|
|
|
|
"config": {
|
|
|
|
"default": false,
|
|
|
|
"MD010": true
|
|
|
|
}
|
|
|
|
}, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2017-07-05 21:53:21 -07:00
|
|
|
"content": []
|
2015-07-25 22:18:30 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(result, expectedResult, "Did not get empty results.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-07-25 22:18:30 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-07-25 22:18:30 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("noInlineConfig", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2017-05-21 22:58:10 -07:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
|
|
|
"content": [
|
|
|
|
"# Heading",
|
|
|
|
"",
|
|
|
|
"\tTab",
|
|
|
|
"",
|
|
|
|
"<!-- markdownlint-disable-->",
|
|
|
|
"",
|
|
|
|
"\tTab",
|
|
|
|
"",
|
|
|
|
"<!-- markdownlint-enable-->",
|
|
|
|
"",
|
2019-04-05 12:36:12 +02:00
|
|
|
"\tTab\n"
|
2017-05-21 22:58:10 -07:00
|
|
|
].join("\n")
|
|
|
|
},
|
2017-07-05 21:53:21 -07:00
|
|
|
"noInlineConfig": true,
|
|
|
|
"resultVersion": 0
|
2017-05-21 22:58:10 -07:00
|
|
|
}, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2017-05-21 22:58:10 -07:00
|
|
|
"content": {
|
|
|
|
"MD010": [ 3, 7, 11 ]
|
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(result, expectedResult, "Undetected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2017-05-21 22:58:10 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2017-05-21 22:58:10 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("readmeHeadings", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2016-07-02 22:37:52 -07:00
|
|
|
markdownlint({
|
|
|
|
"files": "README.md",
|
2017-05-21 22:58:10 -07:00
|
|
|
"noInlineConfig": true,
|
2016-07-02 22:37:52 -07:00
|
|
|
"config": {
|
|
|
|
"default": false,
|
2016-10-16 21:46:02 -07:00
|
|
|
"MD013": {
|
|
|
|
"line_length": 150
|
|
|
|
},
|
2016-07-02 22:37:52 -07:00
|
|
|
"MD043": {
|
2018-03-19 23:39:42 +01:00
|
|
|
"headings": [
|
2016-07-02 22:37:52 -07:00
|
|
|
"# markdownlint",
|
|
|
|
"## Install",
|
|
|
|
"## Overview",
|
|
|
|
"### Related",
|
|
|
|
"## Demonstration",
|
|
|
|
"## Rules / Aliases",
|
|
|
|
"## Tags",
|
|
|
|
"## Configuration",
|
|
|
|
"## API",
|
2017-05-19 22:36:46 -07:00
|
|
|
"### Linting",
|
|
|
|
"#### options",
|
2022-06-04 15:06:07 -07:00
|
|
|
"##### options.config",
|
2022-06-05 22:32:22 -07:00
|
|
|
"##### options.configParsers",
|
2018-02-15 21:35:58 -08:00
|
|
|
"##### options.customRules",
|
2017-05-19 22:36:46 -07:00
|
|
|
"##### options.files",
|
2017-05-21 22:58:10 -07:00
|
|
|
"##### options.frontMatter",
|
2022-06-04 15:06:07 -07:00
|
|
|
"##### options.fs",
|
2019-05-18 12:32:52 -07:00
|
|
|
"##### options.handleRuleFailures",
|
2022-06-04 15:06:07 -07:00
|
|
|
"##### options.markdownItPlugins",
|
2017-05-21 22:58:10 -07:00
|
|
|
"##### options.noInlineConfig",
|
2017-05-19 22:36:46 -07:00
|
|
|
"##### options.resultVersion",
|
2022-06-04 15:06:07 -07:00
|
|
|
"##### options.strings",
|
2017-05-19 22:36:46 -07:00
|
|
|
"#### callback",
|
|
|
|
"#### result",
|
|
|
|
"### Config",
|
|
|
|
"#### file",
|
2018-05-23 22:24:40 -07:00
|
|
|
"#### parsers",
|
2021-08-12 19:38:03 -07:00
|
|
|
"#### fs",
|
2017-05-19 22:36:46 -07:00
|
|
|
"#### callback",
|
|
|
|
"#### result",
|
2016-07-02 22:37:52 -07:00
|
|
|
"## Usage",
|
|
|
|
"## Browser",
|
2017-11-21 21:58:42 -08:00
|
|
|
"## Examples",
|
2018-06-24 20:01:44 -07:00
|
|
|
"## Contributing",
|
2016-07-02 22:37:52 -07:00
|
|
|
"## History"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expected = { "README.md": [] };
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(result, expected, "Unexpected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2016-07-02 22:37:52 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2016-07-02 22:37:52 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("filesArrayNotModified", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2018-04-27 22:05:34 -07:00
|
|
|
const files = [
|
2018-03-19 23:39:42 +01:00
|
|
|
"./test/atx_heading_spacing.md",
|
|
|
|
"./test/first_heading_bad_atx.md"
|
2015-03-13 18:20:56 -07:00
|
|
|
];
|
Update dependencies: c8 to 7.7.2, eslint to 7.28.0, eslint-plugin-jsdoc to 35.1.3, eslint-plugin-unicorn to 33.0.1, globby to 11.0.3, js-yaml to 4.1.0, markdown-it-texmath to 0.9.0, markdownlint-rule-helpers to 0.14.0, ts-loader to 9.2.3, typescript to 4.3.2, webpack to 5.38.1, webpack-cli to 4.7.2.
2021-06-08 22:20:13 -07:00
|
|
|
const expectedFiles = [ ...files ];
|
2015-03-13 18:20:56 -07:00
|
|
|
markdownlint({ "files": files }, function callback(err) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
|
|
|
t.deepEqual(files, expectedFiles, "Files modified.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-13 18:20:56 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-13 18:20:56 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("filesArrayAsString", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2016-01-15 22:00:34 -08:00
|
|
|
markdownlint({
|
|
|
|
"files": "README.md",
|
2017-05-21 22:58:10 -07:00
|
|
|
"noInlineConfig": true,
|
|
|
|
"config": {
|
|
|
|
"MD013": { "line_length": 150 },
|
|
|
|
"MD024": false
|
|
|
|
}
|
2016-01-15 22:00:34 -08:00
|
|
|
}, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expected = { "README.md": [] };
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actual, expected, "Unexpected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2016-01-15 22:00:34 -08:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2016-01-15 22:00:34 -08:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("missingOptions", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2015-03-11 21:13:21 -07:00
|
|
|
markdownlint(null, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
|
|
|
t.deepEqual(
|
2020-09-05 17:24:52 -07:00
|
|
|
result,
|
|
|
|
{},
|
|
|
|
"Did not get empty result for missing options."
|
|
|
|
);
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-11 21:13:21 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-11 21:13:21 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("missingFilesAndStrings", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2015-03-11 21:13:21 -07:00
|
|
|
markdownlint({}, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
|
|
|
t.truthy(result, "Did not get result for missing files/strings.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-11 21:13:21 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-11 21:13:21 -07:00
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("missingCallback", (t) => {
|
|
|
|
t.plan(0);
|
2019-10-30 20:37:06 -07:00
|
|
|
// @ts-ignore
|
2015-03-11 21:13:21 -07:00
|
|
|
markdownlint();
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
2015-03-11 21:13:21 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("badFile", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(4);
|
2015-03-11 21:13:21 -07:00
|
|
|
markdownlint({
|
|
|
|
"files": [ "./badFile" ]
|
|
|
|
}, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.truthy(err, "Did not get an error for bad file.");
|
|
|
|
t.true(err instanceof Error, "Error not instance of Error.");
|
2019-10-30 20:37:06 -07:00
|
|
|
// @ts-ignore
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(err.code, "ENOENT", "Error code for bad file not ENOENT.");
|
|
|
|
t.true(!result, "Got result for bad file.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-11 21:13:21 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-17 22:34:47 -07:00
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("badFileSync", (t) => {
|
|
|
|
t.plan(1);
|
|
|
|
t.throws(
|
2020-01-08 22:13:51 -08:00
|
|
|
function badFileCall() {
|
|
|
|
markdownlint.sync({
|
|
|
|
"files": [ "./badFile" ]
|
|
|
|
});
|
|
|
|
},
|
2021-01-10 20:46:00 -08:00
|
|
|
{
|
|
|
|
"message": /ENOENT/
|
|
|
|
},
|
2020-01-08 22:13:51 -08:00
|
|
|
"Did not get correct exception for bad file."
|
|
|
|
);
|
|
|
|
});
|
2015-03-20 00:09:55 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("badFilePromise", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(3);
|
2020-09-13 12:58:09 -07:00
|
|
|
markdownlint.promises.markdownlint({
|
|
|
|
"files": [ "./badFile" ]
|
|
|
|
}).then(
|
|
|
|
null,
|
|
|
|
(error) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.truthy(error, "Did not get an error for bad file.");
|
|
|
|
t.true(error instanceof Error, "Error not instance of Error.");
|
|
|
|
t.is(error.code, "ENOENT", "Error code for bad file not ENOENT.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-09-13 12:58:09 -07:00
|
|
|
}
|
|
|
|
);
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2020-09-13 12:58:09 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("missingStringValue", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2015-04-29 18:46:52 -07:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
|
|
|
"undefined": undefined,
|
|
|
|
"null": null,
|
|
|
|
"empty": ""
|
2020-11-15 17:03:20 -08:00
|
|
|
}
|
2015-04-29 18:46:52 -07:00
|
|
|
}, function callback(err, result) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2018-04-27 22:05:34 -07:00
|
|
|
const expectedResult = {
|
2017-07-05 21:53:21 -07:00
|
|
|
"undefined": [],
|
|
|
|
"null": [],
|
|
|
|
"empty": []
|
2015-04-29 18:46:52 -07:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(result, expectedResult, "Did not get empty results.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-04-29 18:46:52 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-04-29 18:46:52 -07:00
|
|
|
|
2021-08-12 19:38:03 -07:00
|
|
|
test("customFileSystemSync", (t) => {
|
|
|
|
t.plan(2);
|
|
|
|
const file = "/dir/file.md";
|
|
|
|
const fsApi = {
|
|
|
|
"readFileSync": (p) => {
|
|
|
|
t.is(p, file);
|
|
|
|
return "# Heading";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const result = markdownlint.sync({
|
|
|
|
"files": file,
|
|
|
|
"fs": fsApi
|
|
|
|
});
|
|
|
|
t.deepEqual(result[file].length, 1, "Did not report violations.");
|
|
|
|
});
|
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("customFileSystemAsync", (t) => new Promise((resolve) => {
|
2021-08-12 19:38:03 -07:00
|
|
|
t.plan(3);
|
|
|
|
const file = "/dir/file.md";
|
|
|
|
const fsApi = {
|
|
|
|
"readFile": (p, o, cb) => {
|
|
|
|
t.is(p, file);
|
|
|
|
cb(null, "# Heading");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
markdownlint({
|
|
|
|
"files": file,
|
|
|
|
"fs": fsApi
|
|
|
|
}, function callback(err, result) {
|
|
|
|
t.falsy(err);
|
|
|
|
t.deepEqual(result[file].length, 1, "Did not report violations.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2021-08-12 19:38:03 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2021-11-30 22:03:31 -08:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("readme", (t) => new Promise((resolve) => {
|
2022-06-01 20:23:08 -07:00
|
|
|
t.plan(125);
|
2018-04-27 22:05:34 -07:00
|
|
|
const tagToRules = {};
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const rule of rules) {
|
|
|
|
for (const tag of rule.tags) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const tagRules = tagToRules[tag] || [];
|
2018-01-12 23:21:06 -08:00
|
|
|
tagRules.push(rule.names[0]);
|
2015-04-14 00:01:57 -07:00
|
|
|
tagToRules[tag] = tagRules;
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
|
|
|
}
|
2020-09-12 12:42:46 -07:00
|
|
|
fs.readFile("README.md", "utf8",
|
2015-03-17 22:34:47 -07:00
|
|
|
function readFile(err, contents) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
Update dependencies: c8 to 7.7.2, eslint to 7.28.0, eslint-plugin-jsdoc to 35.1.3, eslint-plugin-unicorn to 33.0.1, globby to 11.0.3, js-yaml to 4.1.0, markdown-it-texmath to 0.9.0, markdownlint-rule-helpers to 0.14.0, ts-loader to 9.2.3, typescript to 4.3.2, webpack to 5.38.1, webpack-cli to 4.7.2.
2021-06-08 22:20:13 -07:00
|
|
|
const rulesLeft = [ ...rules ];
|
2018-04-27 22:05:34 -07:00
|
|
|
let seenRelated = false;
|
|
|
|
let seenRules = false;
|
|
|
|
let inRules = false;
|
|
|
|
let seenTags = false;
|
|
|
|
let inTags = false;
|
Update dependencies: c8 to 7.7.2, eslint to 7.28.0, eslint-plugin-jsdoc to 35.1.3, eslint-plugin-unicorn to 33.0.1, globby to 11.0.3, js-yaml to 4.1.0, markdown-it-texmath to 0.9.0, markdownlint-rule-helpers to 0.14.0, ts-loader to 9.2.3, typescript to 4.3.2, webpack to 5.38.1, webpack-cli to 4.7.2.
2021-06-08 22:20:13 -07:00
|
|
|
// @ts-ignore
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const token of md.parse(contents, {})) {
|
2020-06-22 20:59:13 -07:00
|
|
|
if (
|
|
|
|
(token.type === "bullet_list_open") &&
|
|
|
|
(token.level === 0)
|
|
|
|
) {
|
2016-01-14 22:15:44 -08:00
|
|
|
if (!seenRelated) {
|
|
|
|
seenRelated = true;
|
2020-10-02 13:33:05 -07:00
|
|
|
} else if (!seenRules) {
|
2019-03-30 14:36:04 -07:00
|
|
|
seenRules = true;
|
|
|
|
inRules = true;
|
2020-10-02 13:33:05 -07:00
|
|
|
} else if (!seenTags) {
|
2019-03-30 14:36:04 -07:00
|
|
|
seenTags = true;
|
|
|
|
inTags = true;
|
2015-03-17 22:34:47 -07:00
|
|
|
}
|
2020-06-22 20:59:13 -07:00
|
|
|
} else if (
|
|
|
|
(token.type === "bullet_list_close") &&
|
|
|
|
(token.level === 0)
|
|
|
|
) {
|
2019-03-30 14:36:04 -07:00
|
|
|
inRules = false;
|
|
|
|
inTags = false;
|
2015-03-17 22:34:47 -07:00
|
|
|
} else if (token.type === "inline") {
|
|
|
|
if (inRules) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const rule = rulesLeft.shift();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.truthy(rule,
|
2015-04-14 00:01:57 -07:00
|
|
|
"Missing rule implementation for " + token.content + ".");
|
|
|
|
if (rule) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const ruleName = rule.names[0];
|
|
|
|
const ruleAliases = rule.names.slice(1);
|
2019-07-08 13:10:08 -05:00
|
|
|
let expected = "**[" + ruleName + "](doc/Rules.md#" +
|
2018-01-12 23:21:06 -08:00
|
|
|
ruleName.toLowerCase() + ")** *" +
|
2018-04-18 22:25:45 -07:00
|
|
|
ruleAliases.join("/") + "* - " + rule.description;
|
2020-09-06 20:34:10 -07:00
|
|
|
if (deprecatedRuleNames.has(ruleName)) {
|
2019-07-08 13:10:08 -05:00
|
|
|
expected = "~~" + expected + "~~";
|
|
|
|
}
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(token.content, expected, "Rule mismatch.");
|
2015-04-14 00:01:57 -07:00
|
|
|
}
|
2015-03-17 22:34:47 -07:00
|
|
|
} else if (inTags) {
|
2018-04-27 22:05:34 -07:00
|
|
|
const parts =
|
|
|
|
token.content.replace(/\*\*/g, "").split(/ - |, |,\n/);
|
|
|
|
const tag = parts.shift();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(parts, tagToRules[tag] || [],
|
2015-04-14 00:01:57 -07:00
|
|
|
"Rule mismatch for tag " + tag + ".");
|
|
|
|
delete tagToRules[tag];
|
2015-03-17 22:34:47 -07:00
|
|
|
}
|
|
|
|
}
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2018-04-27 22:05:34 -07:00
|
|
|
const ruleLeft = rulesLeft.shift();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(!ruleLeft,
|
2018-01-12 23:21:06 -08:00
|
|
|
"Missing rule documentation for " +
|
|
|
|
(ruleLeft || "[NO RULE]").toString() + ".");
|
2018-04-27 22:05:34 -07:00
|
|
|
const tagLeft = Object.keys(tagToRules).shift();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(!tagLeft, "Undocumented tag " + tagLeft + ".");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-17 22:34:47 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-03-17 22:34:47 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("rules", (t) => new Promise((resolve) => {
|
2022-08-02 20:36:47 -07:00
|
|
|
t.plan(374);
|
2020-09-12 12:42:46 -07:00
|
|
|
fs.readFile("doc/Rules.md", "utf8",
|
2020-01-23 19:42:46 -08:00
|
|
|
(err, contents) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
Update dependencies: c8 to 7.7.2, eslint to 7.28.0, eslint-plugin-jsdoc to 35.1.3, eslint-plugin-unicorn to 33.0.1, globby to 11.0.3, js-yaml to 4.1.0, markdown-it-texmath to 0.9.0, markdownlint-rule-helpers to 0.14.0, ts-loader to 9.2.3, typescript to 4.3.2, webpack to 5.38.1, webpack-cli to 4.7.2.
2021-06-08 22:20:13 -07:00
|
|
|
const rulesLeft = [ ...rules ];
|
2018-04-27 22:05:34 -07:00
|
|
|
let inHeading = false;
|
|
|
|
let rule = null;
|
|
|
|
let ruleHasTags = true;
|
|
|
|
let ruleHasAliases = true;
|
|
|
|
let ruleUsesParams = null;
|
|
|
|
const tagAliasParameterRe = /, |: | /;
|
2020-01-23 19:42:46 -08:00
|
|
|
const testTagsAliasesParams = (r) => {
|
2021-02-06 19:55:22 -08:00
|
|
|
// eslint-disable-next-line unicorn/prefer-default-parameters
|
2018-01-12 23:21:06 -08:00
|
|
|
r = r || "[NO RULE]";
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(ruleHasTags,
|
2018-07-19 21:49:30 -07:00
|
|
|
"Missing tags for rule " + r.names + ".");
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(ruleHasAliases,
|
2018-07-19 21:49:30 -07:00
|
|
|
"Missing aliases for rule " + r.names + ".");
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(!ruleUsesParams,
|
2018-07-19 21:49:30 -07:00
|
|
|
"Missing parameters for rule " + r.names + ".");
|
2020-01-23 19:42:46 -08:00
|
|
|
};
|
Update dependencies: c8 to 7.7.2, eslint to 7.28.0, eslint-plugin-jsdoc to 35.1.3, eslint-plugin-unicorn to 33.0.1, globby to 11.0.3, js-yaml to 4.1.0, markdown-it-texmath to 0.9.0, markdownlint-rule-helpers to 0.14.0, ts-loader to 9.2.3, typescript to 4.3.2, webpack to 5.38.1, webpack-cli to 4.7.2.
2021-06-08 22:20:13 -07:00
|
|
|
// @ts-ignore
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const token of md.parse(contents, {})) {
|
2015-03-18 23:14:44 -07:00
|
|
|
if ((token.type === "heading_open") && (token.tag === "h2")) {
|
2015-03-17 22:34:47 -07:00
|
|
|
inHeading = true;
|
|
|
|
} else if (token.type === "heading_close") {
|
|
|
|
inHeading = false;
|
|
|
|
} else if (token.type === "inline") {
|
|
|
|
if (inHeading) {
|
2018-01-12 23:21:06 -08:00
|
|
|
testTagsAliasesParams(rule);
|
2015-03-17 22:34:47 -07:00
|
|
|
rule = rulesLeft.shift();
|
2019-03-30 14:36:04 -07:00
|
|
|
ruleHasTags = false;
|
|
|
|
ruleHasAliases = false;
|
2021-01-10 20:46:00 -08:00
|
|
|
t.truthy(rule,
|
2015-04-14 00:01:57 -07:00
|
|
|
"Missing rule implementation for " + token.content + ".");
|
2019-07-08 13:10:08 -05:00
|
|
|
const ruleName = rule.names[0];
|
|
|
|
let headingContent = ruleName + " - " + rule.description;
|
2020-09-06 20:34:10 -07:00
|
|
|
if (deprecatedRuleNames.has(ruleName)) {
|
2019-07-08 13:10:08 -05:00
|
|
|
headingContent = "~~" + headingContent + "~~";
|
|
|
|
}
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(token.content,
|
2019-07-08 13:10:08 -05:00
|
|
|
headingContent,
|
2018-02-05 21:26:07 -08:00
|
|
|
"Rule mismatch.");
|
|
|
|
ruleUsesParams = rule.function.toString()
|
|
|
|
.match(/params\.config\.[_a-z]*/gi);
|
|
|
|
if (ruleUsesParams) {
|
|
|
|
ruleUsesParams = ruleUsesParams.map(function forUse(use) {
|
|
|
|
return use.split(".").pop();
|
|
|
|
});
|
2019-12-09 22:05:57 -08:00
|
|
|
ruleUsesParams.sort();
|
2015-04-14 00:01:57 -07:00
|
|
|
}
|
2020-09-06 20:34:10 -07:00
|
|
|
} else if (token.content.startsWith("Tags: ") && rule) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(token.content.split(tagAliasParameterRe).slice(1),
|
2018-07-19 21:49:30 -07:00
|
|
|
rule.tags, "Tag mismatch for rule " + rule.names + ".");
|
2015-12-13 21:42:51 -08:00
|
|
|
ruleHasTags = true;
|
2020-09-06 20:34:10 -07:00
|
|
|
} else if (token.content.startsWith("Aliases: ") && rule) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(token.content.split(tagAliasParameterRe).slice(1),
|
2018-01-12 23:21:06 -08:00
|
|
|
rule.names.slice(1),
|
2018-07-19 21:49:30 -07:00
|
|
|
"Alias mismatch for rule " + rule.names + ".");
|
2016-01-12 21:29:17 -08:00
|
|
|
ruleHasAliases = true;
|
2020-09-06 20:34:10 -07:00
|
|
|
} else if (token.content.startsWith("Parameters: ") && rule) {
|
2018-04-27 22:05:34 -07:00
|
|
|
let inDetails = false;
|
|
|
|
const parameters = token.content.split(tagAliasParameterRe)
|
2015-12-13 21:42:51 -08:00
|
|
|
.slice(1)
|
|
|
|
.filter(function forPart(part) {
|
|
|
|
inDetails = inDetails || (part[0] === "(");
|
|
|
|
return !inDetails;
|
|
|
|
});
|
2019-12-09 22:05:57 -08:00
|
|
|
parameters.sort();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(parameters, ruleUsesParams,
|
2018-07-19 21:49:30 -07:00
|
|
|
"Missing parameter for rule " + rule.names);
|
2015-12-13 21:42:51 -08:00
|
|
|
ruleUsesParams = null;
|
2015-03-17 22:34:47 -07:00
|
|
|
}
|
|
|
|
}
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2018-04-27 22:05:34 -07:00
|
|
|
const ruleLeft = rulesLeft.shift();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(!ruleLeft,
|
2018-01-12 23:21:06 -08:00
|
|
|
"Missing rule documentation for " +
|
2018-07-19 21:49:30 -07:00
|
|
|
(ruleLeft || { "names": "[NO RULE]" }).names + ".");
|
2016-06-27 22:19:02 -07:00
|
|
|
if (rule) {
|
2018-01-12 23:21:06 -08:00
|
|
|
testTagsAliasesParams(rule);
|
2016-06-27 22:19:02 -07:00
|
|
|
}
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2015-03-17 22:34:47 -07:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2015-05-07 17:42:13 -07:00
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("validateJsonUsingConfigSchemaStrict", (t) => {
|
2018-04-27 22:05:34 -07:00
|
|
|
const jsonFileRe = /\.json$/i;
|
|
|
|
const resultsFileRe = /\.results\.json$/i;
|
2019-10-30 20:37:06 -07:00
|
|
|
const jsConfigFileRe = /^jsconfig\.json$/i;
|
2020-01-25 18:40:39 -08:00
|
|
|
const wrongTypesFileRe = /wrong-types-in-config-file.json$/i;
|
2018-04-27 22:05:34 -07:00
|
|
|
const testDirectory = __dirname;
|
2022-06-08 22:10:27 -07:00
|
|
|
const testFiles = fs
|
|
|
|
.readdirSync(testDirectory)
|
|
|
|
.filter(function filterFile(file) {
|
|
|
|
return jsonFileRe.test(file) &&
|
|
|
|
!resultsFileRe.test(file) &&
|
|
|
|
!jsConfigFileRe.test(file) &&
|
|
|
|
!wrongTypesFileRe.test(file);
|
|
|
|
});
|
|
|
|
for (const file of testFiles) {
|
2019-10-30 20:37:06 -07:00
|
|
|
const data = fs.readFileSync(
|
|
|
|
path.join(testDirectory, file),
|
Update dependencies: c8 to 7.11.3, eslint to 8.18.0, eslint-plugin-jsdoc to 39.3.3, eslint-plugin-unicorn to 42.0.0, globby to 13.1.2, markdown-it-texmath to 1.0.0, markdownlint-rule-helpers to 0.16.0, ts-loader to 9.3.0, typescript to 4.7.4, webpack to 5.73.0, webpack-cli to 4.10.0.
2022-06-20 04:41:08 +00:00
|
|
|
// eslint-disable-next-line unicorn/prefer-json-parse-buffer
|
2020-09-12 12:42:46 -07:00
|
|
|
"utf8"
|
2019-10-30 20:37:06 -07:00
|
|
|
);
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(
|
2020-09-15 21:48:00 -07:00
|
|
|
// @ts-ignore
|
|
|
|
tv4.validate(JSON.parse(data), configSchemaStrict),
|
2016-10-05 22:21:54 -07:00
|
|
|
file + "\n" + JSON.stringify(tv4.error, null, 2));
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
2016-10-05 22:21:54 -07:00
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("validateConfigSchemaAllowsUnknownProperties", (t) => {
|
|
|
|
t.plan(4);
|
2020-09-15 21:48:00 -07:00
|
|
|
const testCases = [
|
|
|
|
{
|
|
|
|
"property": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"property": {
|
|
|
|
"object": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const testCase of testCases) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(
|
2020-09-15 21:48:00 -07:00
|
|
|
// @ts-ignore
|
|
|
|
tv4.validate(testCase, configSchema),
|
|
|
|
"Unknown property blocked by default: " + JSON.stringify(testCase));
|
2021-01-10 20:46:00 -08:00
|
|
|
t.false(
|
2020-09-15 21:48:00 -07:00
|
|
|
// @ts-ignore
|
|
|
|
tv4.validate(testCase, configSchemaStrict),
|
|
|
|
"Unknown property allowed when strict: " + JSON.stringify(testCase));
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2020-09-15 21:48:00 -07:00
|
|
|
});
|
|
|
|
|
2021-06-15 22:25:51 -07:00
|
|
|
test("validateConfigSchemaAppliesToUnknownProperties", (t) => {
|
|
|
|
t.plan(4);
|
|
|
|
for (const allowed of [ true, {} ]) {
|
|
|
|
t.true(
|
|
|
|
// @ts-ignore
|
|
|
|
tv4.validate({ "property": allowed }, configSchema),
|
|
|
|
`Unknown property value ${allowed} blocked`);
|
|
|
|
}
|
|
|
|
for (const blocked of [ 2, "string" ]) {
|
|
|
|
t.false(
|
|
|
|
// @ts-ignore
|
|
|
|
tv4.validate({ "property": blocked }, configSchema),
|
|
|
|
`Unknown property value ${blocked} allowed`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-12-27 21:59:56 +00:00
|
|
|
test("validateConfigExampleJson", async(t) => {
|
2021-01-21 19:50:57 -08:00
|
|
|
t.plan(2);
|
2021-12-27 21:59:56 +00:00
|
|
|
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
|
|
const { "default": stripJsonComments } = await import("strip-json-comments");
|
2021-01-21 19:50:57 -08:00
|
|
|
// Validate JSONC
|
|
|
|
const fileJson = ".markdownlint.jsonc";
|
|
|
|
const dataJson = fs.readFileSync(
|
|
|
|
path.join(__dirname, "../schema", fileJson),
|
2021-01-19 20:41:04 -08:00
|
|
|
"utf8"
|
|
|
|
);
|
2021-01-21 19:50:57 -08:00
|
|
|
const jsonObject = JSON.parse(stripJsonComments(dataJson));
|
2021-01-19 20:41:04 -08:00
|
|
|
t.true(
|
|
|
|
// @ts-ignore
|
2021-01-21 19:50:57 -08:00
|
|
|
tv4.validate(jsonObject, configSchemaStrict),
|
|
|
|
fileJson + "\n" + JSON.stringify(tv4.error, null, 2));
|
|
|
|
// Validate YAML
|
|
|
|
const fileYaml = ".markdownlint.yaml";
|
|
|
|
const dataYaml = fs.readFileSync(
|
|
|
|
path.join(__dirname, "../schema", fileYaml),
|
|
|
|
"utf8"
|
|
|
|
);
|
2021-02-06 19:23:55 -08:00
|
|
|
const yamlObject = jsYaml.load(dataYaml);
|
2021-01-21 19:50:57 -08:00
|
|
|
t.deepEqual(yamlObject, jsonObject,
|
|
|
|
"YAML example does not match JSON example.");
|
2021-01-19 20:41:04 -08:00
|
|
|
});
|
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("allBuiltInRulesHaveValidUrl", (t) => {
|
2022-06-01 20:23:08 -07:00
|
|
|
t.plan(147);
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const rule of rules) {
|
|
|
|
// @ts-ignore
|
2021-01-10 20:46:00 -08:00
|
|
|
t.truthy(rule.information);
|
2022-06-08 22:10:27 -07:00
|
|
|
// @ts-ignore
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(Object.getPrototypeOf(rule.information) === URL.prototype);
|
2020-01-08 22:13:51 -08:00
|
|
|
const name = rule.names[0].toLowerCase();
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(
|
2022-06-08 22:10:27 -07:00
|
|
|
// @ts-ignore
|
2020-01-08 22:13:51 -08:00
|
|
|
rule.information.href,
|
|
|
|
`${homepage}/blob/v${version}/doc/Rules.md#${name}`
|
|
|
|
);
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("someCustomRulesHaveValidUrl", (t) => {
|
2022-01-11 23:08:53 -08:00
|
|
|
t.plan(8);
|
2022-06-08 22:10:27 -07:00
|
|
|
for (const rule of customRules.all) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.true(!rule.information ||
|
2020-01-08 22:13:51 -08:00
|
|
|
(Object.getPrototypeOf(rule.information) === URL.prototype));
|
|
|
|
if (rule === customRules.anyBlockquote) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(
|
2019-01-15 21:56:38 -08:00
|
|
|
rule.information.href,
|
2020-08-11 22:52:29 -07:00
|
|
|
`${homepage}/blob/main/test/rules/any-blockquote.js`
|
2019-01-15 21:56:38 -08:00
|
|
|
);
|
2020-01-08 22:13:51 -08:00
|
|
|
} else if (rule === customRules.lettersEX) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(
|
2020-01-08 22:13:51 -08:00
|
|
|
rule.information.href,
|
2020-08-11 22:52:29 -07:00
|
|
|
`${homepage}/blob/main/test/rules/letters-E-X.js`
|
2020-01-08 22:13:51 -08:00
|
|
|
);
|
|
|
|
}
|
2022-06-08 22:10:27 -07:00
|
|
|
}
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
2019-01-15 21:56:38 -08:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("markdownItPluginsSingle", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2020-01-08 22:13:51 -08:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
|
|
|
"string": "# Heading\n\nText [ link ](https://example.com)\n"
|
|
|
|
},
|
|
|
|
"markdownItPlugins": [
|
|
|
|
[
|
|
|
|
pluginInline,
|
|
|
|
"trim_text_plugin",
|
|
|
|
"text",
|
|
|
|
function iterator(tokens, index) {
|
|
|
|
tokens[index].content = tokens[index].content.trim();
|
|
|
|
}
|
2019-01-19 12:52:13 -08:00
|
|
|
]
|
2020-01-08 22:13:51 -08:00
|
|
|
]
|
|
|
|
}, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2020-01-08 22:13:51 -08:00
|
|
|
const expected = { "string": [] };
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actual, expected, "Unexpected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2019-01-19 12:52:13 -08:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("markdownItPluginsMultiple", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(4);
|
2020-01-08 22:13:51 -08:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
|
|
|
"string": "# Heading\n\nText H~2~0 text 29^th^ text\n"
|
|
|
|
},
|
|
|
|
"markdownItPlugins": [
|
|
|
|
[ pluginSub ],
|
|
|
|
[ pluginSup ],
|
2021-01-10 20:46:00 -08:00
|
|
|
[ pluginInline, "check_sub_plugin", "sub_open", () => t.true(true) ],
|
|
|
|
[ pluginInline, "check_sup_plugin", "sup_open", () => t.true(true) ]
|
2020-01-08 22:13:51 -08:00
|
|
|
]
|
|
|
|
}, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2020-01-08 22:13:51 -08:00
|
|
|
const expected = { "string": [] };
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actual, expected, "Unexpected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2020-01-08 22:13:51 -08:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("markdownItPluginsMathjax", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2020-01-08 22:13:51 -08:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
|
|
|
"string":
|
|
|
|
"# Heading\n" +
|
|
|
|
"\n" +
|
|
|
|
"$1 *2* 3$\n" +
|
|
|
|
"\n" +
|
|
|
|
"$$1 *2* 3$$\n" +
|
|
|
|
"\n" +
|
|
|
|
"$$1\n" +
|
|
|
|
"+ 2\n" +
|
|
|
|
"+ 3$$\n"
|
|
|
|
},
|
2020-10-16 20:59:04 -07:00
|
|
|
"markdownItPlugins": [ [ pluginTexMath, pluginTexMathOptions ] ]
|
2020-01-08 22:13:51 -08:00
|
|
|
}, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2020-01-08 22:13:51 -08:00
|
|
|
const expected = { "string": [] };
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actual, expected, "Unexpected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2019-02-13 19:52:34 -08:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("markdownItPluginsMathjaxIssue166", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2020-01-08 22:13:51 -08:00
|
|
|
markdownlint({
|
|
|
|
"strings": {
|
|
|
|
"string":
|
2019-02-13 19:52:34 -08:00
|
|
|
`## Heading
|
|
|
|
|
|
|
|
$$
|
|
|
|
1
|
|
|
|
$$$$
|
|
|
|
2
|
2019-04-05 12:36:12 +02:00
|
|
|
$$\n`
|
2020-01-08 22:13:51 -08:00
|
|
|
},
|
2020-10-16 20:59:04 -07:00
|
|
|
"markdownItPlugins": [ [ pluginTexMath, pluginTexMathOptions ] ],
|
2020-01-08 22:13:51 -08:00
|
|
|
"resultVersion": 0
|
|
|
|
}, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2020-01-08 22:13:51 -08:00
|
|
|
const expected = {
|
|
|
|
"string": {
|
|
|
|
"MD041": [ 1 ]
|
|
|
|
}
|
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
// @ts-ignore
|
|
|
|
t.deepEqual(actual, expected, "Unexpected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-01-08 22:13:51 -08:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2020-10-17 14:17:35 -07:00
|
|
|
|
2022-06-21 04:40:38 +00:00
|
|
|
test("texmath test files with texmath plugin", (t) => new Promise((resolve) => {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.plan(2);
|
2020-11-12 23:08:46 -08:00
|
|
|
markdownlint({
|
2021-01-24 17:50:39 -08:00
|
|
|
"files": [
|
|
|
|
"./test/texmath-content-in-lists.md",
|
|
|
|
"./test/texmath-content-violating-md037.md"
|
|
|
|
],
|
2020-11-12 23:08:46 -08:00
|
|
|
"markdownItPlugins": [ [ pluginTexMath, pluginTexMathOptions ] ]
|
|
|
|
}, function callback(err, actual) {
|
2021-01-10 20:46:00 -08:00
|
|
|
t.falsy(err);
|
2020-11-12 23:08:46 -08:00
|
|
|
const expected = {
|
2021-01-24 17:50:39 -08:00
|
|
|
"./test/texmath-content-in-lists.md": [],
|
|
|
|
"./test/texmath-content-violating-md037.md": []
|
2020-11-12 23:08:46 -08:00
|
|
|
};
|
2021-01-10 20:46:00 -08:00
|
|
|
t.deepEqual(actual, expected, "Unexpected issues.");
|
2022-06-21 04:40:38 +00:00
|
|
|
resolve();
|
2020-11-12 23:08:46 -08:00
|
|
|
});
|
2022-06-21 04:40:38 +00:00
|
|
|
}));
|
2020-11-12 23:08:46 -08:00
|
|
|
|
2021-11-26 04:26:15 +00:00
|
|
|
test("token-map-spans", (t) => {
|
|
|
|
t.plan(38);
|
|
|
|
const options = {
|
|
|
|
"customRules": [
|
|
|
|
{
|
|
|
|
"names": [ "token-map-spans" ],
|
|
|
|
"description": "token-map-spans",
|
|
|
|
"tags": [ "tms" ],
|
|
|
|
"function": function tokenMapSpans(params) {
|
|
|
|
const tokenLines = [];
|
|
|
|
let lastLineNumber = -1;
|
|
|
|
const inlines = params.tokens.filter((c) => c.type === "inline");
|
|
|
|
for (const token of inlines) {
|
|
|
|
t.truthy(token.map);
|
|
|
|
for (let i = token.map[0]; i < token.map[1]; i++) {
|
|
|
|
if (tokenLines.includes(i)) {
|
|
|
|
t.true(
|
|
|
|
lastLineNumber === token.lineNumber,
|
|
|
|
`Line ${i + 1} is part of token maps from multiple lines.`
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
tokenLines.push(i);
|
|
|
|
}
|
|
|
|
lastLineNumber = token.lineNumber;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"files": [ "./test/token-map-spans.md" ]
|
|
|
|
};
|
|
|
|
markdownlint.sync(options);
|
|
|
|
});
|
|
|
|
|
2022-06-05 22:32:22 -07:00
|
|
|
test("configParsersInvalid", async(t) => {
|
|
|
|
t.plan(1);
|
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": [
|
|
|
|
"Text",
|
|
|
|
"",
|
|
|
|
"<!-- markdownlint-configure-file",
|
|
|
|
" \"first-line-heading\": false",
|
|
|
|
"-->",
|
|
|
|
""
|
|
|
|
].join("\n")
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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);
|
|
|
|
t.is(actual.toString(), expected, "Unexpected results.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("configParsersJSON", async(t) => {
|
|
|
|
t.plan(1);
|
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": [
|
|
|
|
"Text",
|
|
|
|
"",
|
|
|
|
"<!-- markdownlint-configure-file",
|
|
|
|
"{",
|
|
|
|
" \"first-line-heading\": false",
|
|
|
|
"}",
|
|
|
|
"-->",
|
|
|
|
""
|
|
|
|
].join("\n")
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const actual = await markdownlint.promises.markdownlint(options);
|
|
|
|
t.is(actual.toString(), "", "Unexpected results.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("configParsersJSONC", async(t) => {
|
|
|
|
t.plan(1);
|
|
|
|
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
|
|
const { "default": stripJsonComments } = await import("strip-json-comments");
|
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": [
|
|
|
|
"Text",
|
|
|
|
"",
|
|
|
|
"<!-- markdownlint-configure-file",
|
|
|
|
"/* Comment */",
|
|
|
|
"{",
|
|
|
|
" \"first-line-heading\": false // Comment",
|
|
|
|
"}",
|
|
|
|
"-->",
|
|
|
|
""
|
|
|
|
].join("\n")
|
|
|
|
},
|
|
|
|
"configParsers": [ (content) => JSON.parse(stripJsonComments(content)) ]
|
|
|
|
};
|
|
|
|
const actual = await markdownlint.promises.markdownlint(options);
|
|
|
|
t.is(actual.toString(), "", "Unexpected results.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("configParsersYAML", async(t) => {
|
|
|
|
t.plan(1);
|
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": [
|
|
|
|
"Text",
|
|
|
|
"",
|
|
|
|
"<!-- markdownlint-configure-file",
|
|
|
|
"# Comment",
|
|
|
|
"first-line-heading: false",
|
|
|
|
"-->",
|
|
|
|
""
|
|
|
|
].join("\n")
|
|
|
|
},
|
|
|
|
"configParsers": [ jsYaml.load ]
|
|
|
|
};
|
|
|
|
const actual = await markdownlint.promises.markdownlint(options);
|
|
|
|
t.is(actual.toString(), "", "Unexpected results.");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("configParsersTOML", async(t) => {
|
|
|
|
t.plan(1);
|
|
|
|
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
|
|
const { "default": stripJsonComments } = await import("strip-json-comments");
|
|
|
|
const options = {
|
|
|
|
"strings": {
|
|
|
|
"content": [
|
|
|
|
"Text",
|
|
|
|
"",
|
|
|
|
"<!-- markdownlint-configure-file",
|
|
|
|
"# Comment",
|
|
|
|
"first-line-heading = false",
|
|
|
|
"-->",
|
|
|
|
""
|
|
|
|
].join("\n")
|
|
|
|
},
|
|
|
|
"configParsers": [
|
|
|
|
(content) => JSON.parse(stripJsonComments(content)),
|
|
|
|
require("toml").parse
|
|
|
|
]
|
|
|
|
};
|
|
|
|
const actual = await markdownlint.promises.markdownlint(options);
|
|
|
|
t.is(actual.toString(), "", "Unexpected results.");
|
|
|
|
});
|
|
|
|
|
2021-01-10 20:46:00 -08:00
|
|
|
test("getVersion", (t) => {
|
|
|
|
t.plan(1);
|
2020-10-17 14:17:35 -07:00
|
|
|
const actual = markdownlint.getVersion();
|
2020-11-15 17:03:20 -08:00
|
|
|
const expected = version;
|
2021-01-10 20:46:00 -08:00
|
|
|
t.is(actual, expected, "Version string not correct.");
|
2020-10-17 14:17:35 -07:00
|
|
|
});
|
2021-11-10 21:48:15 -08:00
|
|
|
|
|
|
|
test("constants", (t) => {
|
|
|
|
t.plan(2);
|
2022-10-02 19:28:54 -07:00
|
|
|
// @ts-ignore
|
2021-11-10 21:48:15 -08:00
|
|
|
t.is(constants.homepage, homepage);
|
2022-10-02 19:28:54 -07:00
|
|
|
// @ts-ignore
|
2021-11-10 21:48:15 -08:00
|
|
|
t.is(constants.version, version);
|
|
|
|
});
|