mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Incorporate markdownlint-rule-extended-ascii into tests, linting, and documentation.
This commit is contained in:
parent
4a1b3550d3
commit
22f1f064fd
5 changed files with 54 additions and 15 deletions
|
@ -8,6 +8,9 @@
|
|||
"emphasis-style": {
|
||||
"style": "asterisk"
|
||||
},
|
||||
"extended-ascii": {
|
||||
"ascii-only": true
|
||||
},
|
||||
"fenced-code-language": {
|
||||
"allowed_languages": [
|
||||
"bash",
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
# Custom Rules
|
||||
|
||||
In addition to its built-in rules, `markdownlint` lets you enhance the linting
|
||||
experience by passing a list of custom rules using the [`options.customRules`
|
||||
experience by passing an array of custom rules using the [`options.customRules`
|
||||
property][options-custom-rules]. Custom rules can do everything the built-in
|
||||
rules can and are defined inline or imported from another package ([keyword
|
||||
`markdownlint-rule` on npm][markdownlint-rule]). Custom rules can be disabled,
|
||||
enabled, and customized using the same syntax as built-in rules.
|
||||
`markdownlint-rule` on npm][markdownlint-rule]). When defined by a file or
|
||||
package, the export can be a single rule object (see below) or an array of them.
|
||||
Custom rules can be disabled, enabled, and customized using the same syntax as
|
||||
built-in rules.
|
||||
|
||||
## Implementing Simple Rules
|
||||
|
||||
|
@ -129,8 +131,7 @@ exception.
|
|||
|
||||
- [Simple rules used by the project's test cases][test-rules]
|
||||
- [Code for all `markdownlint` built-in rules][lib]
|
||||
- [Package configuration for publishing to npm][test-rules-npm]
|
||||
- Packages should export a single rule object or an `Array` of rule objects
|
||||
- [Complete example rule including npm configuration][extended-ascii]
|
||||
- [Custom rules from the webhintio/hint repository][hint]
|
||||
|
||||
## References
|
||||
|
@ -372,6 +373,7 @@ Yields the `params` object:
|
|||
```
|
||||
|
||||
[commonmark]: https://commonmark.org/
|
||||
[extended-ascii]: https://github.com/DavidAnson/markdownlint-rule-extended-ascii
|
||||
[hint]: https://github.com/webhintio/hint/blob/main/scripts/lint-markdown.js
|
||||
[lib]: ../lib
|
||||
[markdown-it]: https://github.com/markdown-it/markdown-it
|
||||
|
@ -380,4 +382,3 @@ Yields the `params` object:
|
|||
[rule-helpers]: https://www.npmjs.com/package/markdownlint-rule-helpers
|
||||
[options-custom-rules]: ../README.md#optionscustomrules
|
||||
[test-rules]: ../test/rules
|
||||
[test-rules-npm]: ../test/rules/npm
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
"markdown-it-for-inline": "2.0.1",
|
||||
"markdown-it-sub": "2.0.0",
|
||||
"markdown-it-sup": "2.0.0",
|
||||
"markdownlint-rule-extended-ascii": "0.1.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"terser-webpack-plugin": "5.3.10",
|
||||
"toml": "3.0.0",
|
||||
|
|
|
@ -343,9 +343,12 @@ test("customRulesNpmPackage", (t) => new Promise((resolve) => {
|
|||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../lib/markdownlint").Options */
|
||||
const options = {
|
||||
"customRules": [ require("./rules/npm") ],
|
||||
"customRules": [
|
||||
require("./rules/npm"),
|
||||
require("markdownlint-rule-extended-ascii")
|
||||
],
|
||||
"strings": {
|
||||
"string": "# Text\n\n---\n\nText\n"
|
||||
"string": "# Text\n\n---\n\nText ✅\n"
|
||||
},
|
||||
"resultVersion": 0
|
||||
};
|
||||
|
@ -353,6 +356,7 @@ test("customRulesNpmPackage", (t) => new Promise((resolve) => {
|
|||
t.falsy(err);
|
||||
const expectedResult = {};
|
||||
expectedResult.string = {
|
||||
"extended-ascii": [ 5 ],
|
||||
"sample-rule": [ 3 ]
|
||||
};
|
||||
// @ts-ignore
|
||||
|
|
|
@ -73,16 +73,18 @@ test("simplePromise", (t) => {
|
|||
});
|
||||
});
|
||||
|
||||
const projectFiles = [
|
||||
"*.md",
|
||||
"doc/*.md",
|
||||
"helpers/*.md",
|
||||
"micromark/*.md",
|
||||
"schema/*.md"
|
||||
];
|
||||
|
||||
test("projectFiles", (t) => {
|
||||
t.plan(2);
|
||||
return import("globby")
|
||||
.then((module) => module.globby([
|
||||
"*.md",
|
||||
"doc/*.md",
|
||||
"helpers/*.md",
|
||||
"micromark/*.md",
|
||||
"schema/*.md"
|
||||
]))
|
||||
.then((module) => module.globby(projectFiles))
|
||||
.then((files) => {
|
||||
t.is(files.length, 60);
|
||||
const options = {
|
||||
|
@ -100,6 +102,34 @@ test("projectFiles", (t) => {
|
|||
});
|
||||
});
|
||||
|
||||
test("projectFilesExtendedAscii", (t) => {
|
||||
t.plan(2);
|
||||
return import("globby")
|
||||
.then((module) => module.globby([
|
||||
...projectFiles,
|
||||
"!doc/Rules.md",
|
||||
"!doc/md010.md",
|
||||
"!doc/md026.md",
|
||||
"!doc/md036.md"
|
||||
]))
|
||||
.then((files) => {
|
||||
t.is(files.length, 56);
|
||||
const options = {
|
||||
files,
|
||||
"config": require("../.markdownlint.json"),
|
||||
"customRules": [ require("markdownlint-rule-extended-ascii") ]
|
||||
};
|
||||
// @ts-ignore
|
||||
return markdownlint.promises.markdownlint(options).then((actual) => {
|
||||
const expected = {};
|
||||
for (const file of files) {
|
||||
expected[file] = [];
|
||||
}
|
||||
t.deepEqual(actual, expected, "Issue(s) with project files.");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("stringInputLineEndings", (t) => new Promise((resolve) => {
|
||||
t.plan(2);
|
||||
const options = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue