Skip to content

Commit 22f1f06

Browse files
committed
Incorporate markdownlint-rule-extended-ascii into tests, linting, and documentation.
1 parent 4a1b355 commit 22f1f06

5 files changed

+54
-15
lines changed

Diff for: .markdownlint.json

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"emphasis-style": {
99
"style": "asterisk"
1010
},
11+
"extended-ascii": {
12+
"ascii-only": true
13+
},
1114
"fenced-code-language": {
1215
"allowed_languages": [
1316
"bash",

Diff for: doc/CustomRules.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Custom Rules
22

33
In addition to its built-in rules, `markdownlint` lets you enhance the linting
4-
experience by passing a list of custom rules using the [`options.customRules`
4+
experience by passing an array of custom rules using the [`options.customRules`
55
property][options-custom-rules]. Custom rules can do everything the built-in
66
rules can and are defined inline or imported from another package ([keyword
7-
`markdownlint-rule` on npm][markdownlint-rule]). Custom rules can be disabled,
8-
enabled, and customized using the same syntax as built-in rules.
7+
`markdownlint-rule` on npm][markdownlint-rule]). When defined by a file or
8+
package, the export can be a single rule object (see below) or an array of them.
9+
Custom rules can be disabled, enabled, and customized using the same syntax as
10+
built-in rules.
911

1012
## Implementing Simple Rules
1113

@@ -129,8 +131,7 @@ exception.
129131

130132
- [Simple rules used by the project's test cases][test-rules]
131133
- [Code for all `markdownlint` built-in rules][lib]
132-
- [Package configuration for publishing to npm][test-rules-npm]
133-
- Packages should export a single rule object or an `Array` of rule objects
134+
- [Complete example rule including npm configuration][extended-ascii]
134135
- [Custom rules from the webhintio/hint repository][hint]
135136

136137
## References
@@ -372,6 +373,7 @@ Yields the `params` object:
372373
```
373374

374375
[commonmark]: https://commonmark.org/
376+
[extended-ascii]: https://github.com/DavidAnson/markdownlint-rule-extended-ascii
375377
[hint]: https://github.com/webhintio/hint/blob/main/scripts/lint-markdown.js
376378
[lib]: ../lib
377379
[markdown-it]: https://github.com/markdown-it/markdown-it
@@ -380,4 +382,3 @@ Yields the `params` object:
380382
[rule-helpers]: https://www.npmjs.com/package/markdownlint-rule-helpers
381383
[options-custom-rules]: ../README.md#optionscustomrules
382384
[test-rules]: ../test/rules
383-
[test-rules-npm]: ../test/rules/npm

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"markdown-it-for-inline": "2.0.1",
8888
"markdown-it-sub": "2.0.0",
8989
"markdown-it-sup": "2.0.0",
90+
"markdownlint-rule-extended-ascii": "0.1.0",
9091
"npm-run-all": "4.1.5",
9192
"terser-webpack-plugin": "5.3.10",
9293
"toml": "3.0.0",

Diff for: test/markdownlint-test-custom-rules.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,20 @@ test("customRulesNpmPackage", (t) => new Promise((resolve) => {
343343
// eslint-disable-next-line jsdoc/valid-types
344344
/** @type import("../lib/markdownlint").Options */
345345
const options = {
346-
"customRules": [ require("./rules/npm") ],
346+
"customRules": [
347+
require("./rules/npm"),
348+
require("markdownlint-rule-extended-ascii")
349+
],
347350
"strings": {
348-
"string": "# Text\n\n---\n\nText\n"
351+
"string": "# Text\n\n---\n\nText\n"
349352
},
350353
"resultVersion": 0
351354
};
352355
markdownlint(options, function callback(err, actualResult) {
353356
t.falsy(err);
354357
const expectedResult = {};
355358
expectedResult.string = {
359+
"extended-ascii": [ 5 ],
356360
"sample-rule": [ 3 ]
357361
};
358362
// @ts-ignore

Diff for: test/markdownlint-test.js

+37-7
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,18 @@ test("simplePromise", (t) => {
7373
});
7474
});
7575

76+
const projectFiles = [
77+
"*.md",
78+
"doc/*.md",
79+
"helpers/*.md",
80+
"micromark/*.md",
81+
"schema/*.md"
82+
];
83+
7684
test("projectFiles", (t) => {
7785
t.plan(2);
7886
return import("globby")
79-
.then((module) => module.globby([
80-
"*.md",
81-
"doc/*.md",
82-
"helpers/*.md",
83-
"micromark/*.md",
84-
"schema/*.md"
85-
]))
87+
.then((module) => module.globby(projectFiles))
8688
.then((files) => {
8789
t.is(files.length, 60);
8890
const options = {
@@ -100,6 +102,34 @@ test("projectFiles", (t) => {
100102
});
101103
});
102104

105+
test("projectFilesExtendedAscii", (t) => {
106+
t.plan(2);
107+
return import("globby")
108+
.then((module) => module.globby([
109+
...projectFiles,
110+
"!doc/Rules.md",
111+
"!doc/md010.md",
112+
"!doc/md026.md",
113+
"!doc/md036.md"
114+
]))
115+
.then((files) => {
116+
t.is(files.length, 56);
117+
const options = {
118+
files,
119+
"config": require("../.markdownlint.json"),
120+
"customRules": [ require("markdownlint-rule-extended-ascii") ]
121+
};
122+
// @ts-ignore
123+
return markdownlint.promises.markdownlint(options).then((actual) => {
124+
const expected = {};
125+
for (const file of files) {
126+
expected[file] = [];
127+
}
128+
t.deepEqual(actual, expected, "Issue(s) with project files.");
129+
});
130+
});
131+
});
132+
103133
test("stringInputLineEndings", (t) => new Promise((resolve) => {
104134
t.plan(2);
105135
const options = {

0 commit comments

Comments
 (0)