Skip to content

Commit bb7c4dd

Browse files
committed
Output progress to stdout (disable via noProgress property in .markdownlint-cli2.jsonc).
1 parent 0fb5a42 commit bb7c4dd

40 files changed

+123
-4
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"unicorn/no-null": "off",
110110
"unicorn/no-object-as-default-parameter": "error",
111111
"unicorn/no-process-exit": "error",
112-
"unicorn/no-reduce": "error",
112+
"unicorn/no-reduce": "off",
113113
"unicorn/no-unreadable-array-destructuring": "error",
114114
"unicorn/no-unsafe-regex": "error",
115115
"unicorn/no-unused-properties": "error",

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,18 @@ $ markdownlint-cli2 "**/*.md" "#node_modules"
141141
- `noInlineConfig`: `Boolean` value to disable the support of
142142
[HTML comments][html-comment] within Markdown content
143143
- For example: `<!-- markdownlint-disable some-rule -->`
144+
- `noProgress`: `Boolean` value to disable the display of progress on `stdout`
145+
- This top-level setting is valid **only** in the directory from which
146+
`markdownlint-cli2` is run
144147
- `outputFormatters`: `Array` of `Array`s, each of which has a `String`
145148
naming a [markdownlint-cli2-formatter][markdownlint-cli2-formatter] followed
146149
by parameters
147150
- Formatters can be used to customize the tool's output for different
148151
scenarios
149152
- Relative paths are resolved based on the location of the `JSONC` file
150153
- For example: `[ [ "formatter-name", param_0, param_1, ... ], ... ]`
151-
- This setting affects output for the entire pass, so is valid **only** in
152-
the directory from which `markdownlint-cli2` is run
154+
- This top-level setting is valid **only** in the directory from which
155+
`markdownlint-cli2` is run
153156
- Settings in this file apply to the directory it is in and all subdirectories.
154157
- Settings **merge with** those applied by any versions of this file in a parent
155158
directory.

markdownlint-cli2.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,12 @@ $ ${name} "**/*.md" "#node_modules"`
186186
map(negateGlob);
187187
appendToArray(globPatterns, ignorePatterns);
188188
delete baseMarkdownlintOptions.ignores;
189+
const showProgress = !baseMarkdownlintOptions.noProgress;
189190

190191
// Enumerate files from globs and build directory info list
192+
if (showProgress) {
193+
logMessage(`Finding: ${globPatterns.join(" ")}`);
194+
}
191195
for await (const file of globby.stream(globPatterns)) {
192196
// @ts-ignore
193197
const dir = path.dirname(file);
@@ -280,6 +284,10 @@ $ ${name} "**/*.md" "#node_modules"`
280284
}
281285

282286
// Lint each list of files
287+
if (showProgress) {
288+
const fileCount = dirInfos.reduce((p, c) => p + c.files.length, 0);
289+
logMessage(`Linting: ${fileCount} file(s)`);
290+
}
283291
for (const dirInfo of dirInfos) {
284292
const { dir, files, markdownlintConfig, markdownlintOptions } = dirInfo;
285293
let filteredFiles = files;
@@ -364,6 +372,9 @@ $ ${name} "**/*.md" "#node_modules"`
364372
summary.forEach((result) => delete result.counter);
365373

366374
// Output summary via formatters
375+
if (showProgress) {
376+
logMessage(`Summary: ${summary.length} error(s)`);
377+
}
367378
const { outputFormatters } = baseMarkdownlintOptions;
368379
const errorsPresent = (summary.length > 0);
369380
if (errorsPresent || outputFormatters) {

test/all-ok.stdout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Finding: **/*.md **/*.markdown
2+
Linting: 3 file(s)
3+
Summary: 0 error(s)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Finding: viewme.md
2+
Linting: 1 file(s)
3+
Summary: 3 error(s)

test/customRules-invalid.stdout

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Finding: .*
2+
Linting: 1 file(s)

test/customRules-missing.stdout

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Finding: .*
2+
Linting: 1 file(s)

test/customRules-throws.stdout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Finding: **/*.md
2+
Linting: 1 file(s)
3+
Summary: 6 error(s)

test/customRules.stdout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Finding: **/*.md
2+
Linting: 5 file(s)
3+
Summary: 31 error(s)

test/dot.stdout

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Finding: *.{md,markdown}
2+
Linting: 2 file(s)
3+
Summary: 10 error(s)

0 commit comments

Comments
 (0)