markdownlint-cli 0.27.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/markdownlint.js +43 -22
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ markdownlint --help
|
|
|
33
33
|
-d, --dot include files/folders with a dot (for example `.github`)
|
|
34
34
|
-f, --fix fix basic errors (does not work with STDIN)
|
|
35
35
|
-i, --ignore [file|directory|glob] file(s) to ignore/exclude
|
|
36
|
+
-j, --json write issues in json format
|
|
36
37
|
-o, --output [outputFile] write issues to file (no console)
|
|
37
38
|
-p, --ignore-path [file] path to file with ignore pattern(s)
|
|
38
39
|
-r, --rules [file|directory|glob|package] custom rule files
|
|
@@ -112,15 +113,17 @@ A JS configuration file may internally `require` one or more npm packages as a w
|
|
|
112
113
|
|
|
113
114
|
## Use with pre-commit
|
|
114
115
|
|
|
115
|
-
To run `markdownlint-cli` as part of a [pre-commit]
|
|
116
|
+
To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add something like the below to the `repos` list in the project's `.pre-commit-config.yaml`:
|
|
116
117
|
|
|
117
118
|
```yaml
|
|
118
119
|
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
119
|
-
rev: v0.
|
|
120
|
+
rev: v0.29.0
|
|
120
121
|
hooks:
|
|
121
122
|
- id: markdownlint
|
|
122
123
|
```
|
|
123
124
|
|
|
125
|
+
> Depending on the environment this workflow runs in, it may be necessary to [override the language version of Node.js used by pre-commit][pre-commit-version].
|
|
126
|
+
|
|
124
127
|
## Related
|
|
125
128
|
|
|
126
129
|
- [markdownlint][markdownlint] - API for this module
|
|
@@ -144,3 +147,5 @@ MIT © Igor Shubovych
|
|
|
144
147
|
[globprimer]: https://github.com/isaacs/node-glob/blob/master/README.md#glob-primer
|
|
145
148
|
[ignore]: https://github.com/kaelzhang/node-ignore
|
|
146
149
|
[gitignore]: https://git-scm.com/docs/gitignore
|
|
150
|
+
[pre-commit]: https://pre-commit.com/
|
|
151
|
+
[pre-commit-version]: https://pre-commit.com/#overriding-language-version
|
package/markdownlint.js
CHANGED
|
@@ -10,7 +10,7 @@ const options = program.opts();
|
|
|
10
10
|
const differenceWith = require('lodash.differencewith');
|
|
11
11
|
const flatten = require('lodash.flatten');
|
|
12
12
|
const markdownlint = require('markdownlint');
|
|
13
|
-
const rc = require('
|
|
13
|
+
const rc = require('run-con');
|
|
14
14
|
const glob = require('glob');
|
|
15
15
|
const minimatch = require('minimatch');
|
|
16
16
|
const minimist = require('minimist');
|
|
@@ -34,8 +34,7 @@ const configFileParsers = [jsoncParse, jsYamlSafeLoad];
|
|
|
34
34
|
const fsOptions = {encoding: 'utf8'};
|
|
35
35
|
const processCwd = process.cwd();
|
|
36
36
|
|
|
37
|
-
function readConfiguration(
|
|
38
|
-
const userConfigFile = args.config;
|
|
37
|
+
function readConfiguration(userConfigFile) {
|
|
39
38
|
const jsConfigFile = /\.js$/i.test(userConfigFile);
|
|
40
39
|
const rcArgv = minimist(process.argv.slice(2));
|
|
41
40
|
if (jsConfigFile) {
|
|
@@ -132,30 +131,48 @@ function prepareFileList(files, fileExtensions, previousResults) {
|
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
function printResult(lintResult) {
|
|
134
|
+
|
|
135
135
|
const results = flatten(Object.keys(lintResult).map(file => {
|
|
136
136
|
return lintResult[file].map(result => {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
if (options.json) {
|
|
138
|
+
return {
|
|
139
|
+
fileName: file,
|
|
140
|
+
...result
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
return {
|
|
144
|
+
file: file,
|
|
145
|
+
lineNumber: result.lineNumber,
|
|
146
|
+
column: (result.errorRange && result.errorRange[0]) || 0,
|
|
147
|
+
names: result.ruleNames.join('/'),
|
|
148
|
+
description: result.ruleDescription +
|
|
149
|
+
(result.errorDetail ? ' [' + result.errorDetail + ']' : '') +
|
|
150
|
+
(result.errorContext ? ' [Context: "' + result.errorContext + '"]' : '')
|
|
151
|
+
};
|
|
152
|
+
}
|
|
146
153
|
});
|
|
147
154
|
}));
|
|
155
|
+
|
|
148
156
|
let lintResultString = '';
|
|
149
157
|
if (results.length > 0) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
a.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
if (options.json) {
|
|
159
|
+
results.sort((a, b) => {
|
|
160
|
+
return a.fileName.localeCompare(b.fileName) || a.lineNumber - b.lineNumber ||
|
|
161
|
+
a.ruleDescription.localeCompare(b.ruleDescription);
|
|
162
|
+
});
|
|
163
|
+
lintResultString = JSON.stringify(results, null, 2);
|
|
164
|
+
} else {
|
|
165
|
+
results.sort((a, b) => {
|
|
166
|
+
return a.file.localeCompare(b.file) || a.lineNumber - b.lineNumber ||
|
|
167
|
+
a.names.localeCompare(b.names) || a.description.localeCompare(b.description);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
lintResultString = results.map(result => {
|
|
171
|
+
const {file, lineNumber, column, names, description} = result;
|
|
172
|
+
const columnText = column ? `:${column}` : '';
|
|
173
|
+
return `${file}:${lineNumber}${columnText} ${names} ${description}`;
|
|
174
|
+
}).join('\n');
|
|
175
|
+
}
|
|
159
176
|
// Note: process.exit(1) will end abruptly, interrupting asynchronous IO
|
|
160
177
|
// streams (e.g., when the output is being piped). Just set the exit code
|
|
161
178
|
// and let the program terminate normally.
|
|
@@ -192,6 +209,7 @@ program
|
|
|
192
209
|
.option('-d, --dot', 'include files/folders with a dot (for example `.github`)')
|
|
193
210
|
.option('-f, --fix', 'fix basic errors (does not work with STDIN)')
|
|
194
211
|
.option('-i, --ignore [file|directory|glob]', 'file(s) to ignore/exclude', concatArray, [])
|
|
212
|
+
.option('-j, --json', 'write issues in json format')
|
|
195
213
|
.option('-o, --output [outputFile]', 'write issues to file (no console)')
|
|
196
214
|
.option('-p, --ignore-path [file]', 'path to file with ignore pattern(s)')
|
|
197
215
|
.option('-r, --rules [file|directory|glob|package]', 'custom rule files', concatArray, [])
|
|
@@ -268,7 +286,7 @@ const diff = differenceWith(files, ignores, function (a, b) {
|
|
|
268
286
|
|
|
269
287
|
function lintAndPrint(stdin, files) {
|
|
270
288
|
files = files || [];
|
|
271
|
-
const config = readConfiguration(
|
|
289
|
+
const config = readConfiguration(options.config);
|
|
272
290
|
const lintOptions = {
|
|
273
291
|
config,
|
|
274
292
|
customRules,
|
|
@@ -279,6 +297,9 @@ function lintAndPrint(stdin, files) {
|
|
|
279
297
|
stdin
|
|
280
298
|
};
|
|
281
299
|
}
|
|
300
|
+
if (options.json) {
|
|
301
|
+
lintOptions.resultVersion = 3;
|
|
302
|
+
}
|
|
282
303
|
|
|
283
304
|
if (options.fix) {
|
|
284
305
|
const fixOptions = {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "MarkdownLint Command Line Interface",
|
|
5
5
|
"main": "markdownlint.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"markdownlint": "markdownlint.js"
|
|
8
8
|
},
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=12"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"invalid": "node ./markdownlint.js --config test/test-config.json -- test/incorrect.md",
|
|
@@ -37,28 +37,28 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"commander": "~
|
|
40
|
+
"commander": "~8.2.0",
|
|
41
41
|
"deep-extend": "~0.6.0",
|
|
42
42
|
"get-stdin": "~8.0.0",
|
|
43
|
-
"glob": "~7.
|
|
43
|
+
"glob": "~7.2.0",
|
|
44
44
|
"ignore": "~5.1.8",
|
|
45
|
-
"js-yaml": "^4.
|
|
45
|
+
"js-yaml": "^4.1.0",
|
|
46
46
|
"jsonc-parser": "~3.0.0",
|
|
47
47
|
"lodash.differencewith": "~4.5.0",
|
|
48
48
|
"lodash.flatten": "~4.4.0",
|
|
49
|
-
"markdownlint": "~0.
|
|
50
|
-
"markdownlint-rule-helpers": "~0.
|
|
49
|
+
"markdownlint": "~0.24.0",
|
|
50
|
+
"markdownlint-rule-helpers": "~0.15.0",
|
|
51
51
|
"minimatch": "~3.0.4",
|
|
52
52
|
"minimist": "~1.2.5",
|
|
53
|
-
"
|
|
53
|
+
"run-con": "~1.2.10"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"ava": "^3.15.0",
|
|
57
|
-
"execa": "^5.
|
|
58
|
-
"husky": "^
|
|
57
|
+
"execa": "^5.1.1",
|
|
58
|
+
"husky": "^7.0.2",
|
|
59
59
|
"tap-growl": "^3.0.0",
|
|
60
60
|
"test-rule-package": "./test/custom-rules/test-rule-package",
|
|
61
|
-
"xo": "^0.
|
|
61
|
+
"xo": "^0.45.0"
|
|
62
62
|
},
|
|
63
63
|
"xo": {
|
|
64
64
|
"space": true,
|