Skip to content

Commit 2d718f4

Browse files
authored
WIP
1 parent 0cfb7d0 commit 2d718f4

21 files changed

+198
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dir1/viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]
2+
dir1/viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]
3+
dir2/viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]
4+
viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]
5+
viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
markdownlint-cli2-config vX.Y.Z (markdownlint vX.Y.Z)
2+
Finding: **/*.md
3+
Linting: 3 file(s)
4+
Summary: 5 error(s)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
markdownlint-cli2-config vX.Y.Z (markdownlint vX.Y.Z)

test/config-files-cli2-jsonc.stderr

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dir1/viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]
2+
dir1/viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]
3+
dir2/viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]
4+
viewme.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2]
5+
viewme.md:6 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# Description"]

test/config-files-cli2-jsonc.stdout

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
markdownlint-cli2-config vX.Y.Z (markdownlint vX.Y.Z)
2+
Finding: **/*.md
3+
Linting: 3 file(s)
4+
Summary: 5 error(s)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @ts-check
2+
3+
"use strict";
4+
5+
module.exports = {
6+
"config": {
7+
"no-trailing-spaces": false,
8+
"no-multiple-space-atx": false,
9+
"single-trailing-newline": false
10+
}
11+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"config": {
3+
"no-trailing-spaces": false,
4+
"no-multiple-space-atx": false,
5+
"single-trailing-newline": false
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
config:
2+
no-trailing-spaces: false
3+
no-multiple-space-atx: false
4+
single-trailing-newline: false
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @ts-check
2+
3+
"use strict";
4+
5+
module.exports = {
6+
"no-trailing-spaces": false,
7+
"no-multiple-space-atx": false,
8+
"single-trailing-newline": false
9+
};
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"no-trailing-spaces": false,
3+
"no-multiple-space-atx": false,
4+
"single-trailing-newline": false
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"no-trailing-spaces": false,
3+
"no-multiple-space-atx": false,
4+
"single-trailing-newline": false
5+
}
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
no-trailing-spaces: false
2+
no-multiple-space-atx: false
3+
single-trailing-newline: false
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
no-trailing-spaces: false
2+
no-multiple-space-atx: false
3+
single-trailing-newline: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"config": {
3+
"no-trailing-spaces": false,
4+
"no-multiple-space-atx": false,
5+
"single-trailing-newline": false
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{

test/config-files/dir1/viewme.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Title
2+
3+
> Tagline
4+
5+
6+
# Description
7+
8+
Text text text
9+
Text text text
10+
Text text text
11+
12+
## Summary
13+
14+
Text text text
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"config": {
3+
"no-trailing-spaces": false,
4+
"no-multiple-blanks": false,
5+
"no-multiple-space-atx": false,
6+
"single-trailing-newline": false
7+
}
8+
}

test/config-files/dir2/viewme.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Title
2+
3+
> Tagline
4+
5+
6+
# Description
7+
8+
Text text text
9+
Text text text
10+
Text text text
11+
12+
## Summary
13+
14+
Text text text

test/config-files/viewme.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Title
2+
3+
> Tagline
4+
5+
6+
# Description
7+
8+
Text text text
9+
Text text text
10+
Text text text
11+
12+
## Summary
13+
14+
Text text text

test/markdownlint-cli2-test-cases.js

+37
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ const testCases =
156156
"usesScript": true
157157
});
158158

159+
testCase({
160+
"name": "one-argument-config",
161+
"script": "markdownlint-cli2-config.js",
162+
"args": [ "../config-files/cfg/.markdownlint-cli2.jsonc" ],
163+
"exitCode": 1,
164+
"cwd": "no-config",
165+
"usesScript": true
166+
});
167+
159168
testCase({
160169
"name": "no-files",
161170
"args": [ "nothing-matches" ],
@@ -468,6 +477,34 @@ const testCases =
468477
"usesScript": true
469478
});
470479

480+
testCase({
481+
"name": "config-files-cli2-jsonc",
482+
"script": "markdownlint-cli2-config.js",
483+
"args": [ "cfg/.markdownlint-cli2.jsonc", "**/*.md" ],
484+
"exitCode": 1,
485+
"cwd": "config-files",
486+
"usesScript": true
487+
});
488+
489+
testCase({
490+
"name": "config-files-cli2-jsonc-alternate",
491+
"script": "markdownlint-cli2-config.js",
492+
"args": [ "cfg/alternate.markdownlint-cli2.jsonc", "**/*.md" ],
493+
"exitCode": 1,
494+
"cwd": "config-files",
495+
"usesScript": true
496+
});
497+
498+
testCase({
499+
"name": "config-files-cli2-jsonc-invalid",
500+
"script": "markdownlint-cli2-config.js",
501+
"args": [ "cfg/invalid.markdownlint-cli2.jsonc", "**/*.md" ],
502+
"exitCode": 2,
503+
"stderrRe": /Unexpected end of JSON input/u,
504+
"cwd": "config-files",
505+
"usesScript": true
506+
});
507+
471508
testCase({
472509
"name": "customRules",
473510
"args": [ "**/*.md" ],

test/one-argument-config.stdout

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
markdownlint-cli2-config vX.Y.Z (markdownlint vX.Y.Z)
2+
https://github.com/DavidAnson/markdownlint-cli2
3+
4+
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN]
5+
markdownlint-cli2-fix glob0 [glob1] [...] [globN]
6+
markdownlint-cli2-config config-file glob0 [glob1] [...] [globN]
7+
8+
Glob expressions (from the globby library):
9+
- * matches any number of characters, but not /
10+
- ? matches a single character, but not /
11+
- ** matches any number of characters, including /
12+
- {} allows for a comma-separated list of "or" expressions
13+
- ! or # at the beginning of a pattern negate the match
14+
- : at the beginning identifies a literal file path
15+
16+
Dot-only glob:
17+
- The command "markdownlint-cli2 ." would lint every file in the current directory tree which is probably not intended
18+
- Instead, it is mapped to "markdownlint-cli2 *.{md,markdown}" which lints all Markdown files in the current directory
19+
- To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
20+
21+
Configuration via:
22+
- .markdownlint-cli2.jsonc
23+
- .markdownlint-cli2.yaml
24+
- .markdownlint-cli2.js
25+
- .markdownlint.jsonc or .markdownlint.json
26+
- .markdownlint.yaml or .markdownlint.yml
27+
- .markdownlint.js
28+
29+
Cross-platform compatibility:
30+
- UNIX and Windows shells expand globs according to different rules; quoting arguments is recommended
31+
- Some Windows shells don't handle single-quoted (') arguments well; double-quote (") is recommended
32+
- Shells that expand globs do not support negated patterns (!node_modules); quoting is required here
33+
- Some UNIX shells parse exclamation (!) in double-quotes; hashtag (#) is recommended in these cases
34+
- The path separator is forward slash (/) on all platforms; backslash (\) is automatically converted
35+
36+
The most compatible syntax for cross-platform support:
37+
$ markdownlint-cli2 "**/*.md" "#node_modules"

0 commit comments

Comments
 (0)