markdownlint-cli 0.43.0 → 0.45.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 +24 -21
- package/markdownlint.js +34 -34
- package/package.json +18 -12
package/README.md
CHANGED
|
@@ -21,26 +21,29 @@ brew install markdownlint-cli
|
|
|
21
21
|
```bash
|
|
22
22
|
markdownlint --help
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
Usage: markdownlint [options] [files|directories|globs...]
|
|
25
|
+
|
|
26
|
+
MarkdownLint Command Line Interface
|
|
27
|
+
|
|
28
|
+
Arguments:
|
|
29
|
+
files|directories|globs files, directories, and/or globs to lint
|
|
30
|
+
|
|
31
|
+
Options:
|
|
32
|
+
-V, --version output the version number
|
|
33
|
+
-c, --config <configFile> configuration file (JSON, JSONC, JS, YAML, or TOML)
|
|
34
|
+
--configPointer <pointer> JSON Pointer to object within configuration file (default: "")
|
|
35
|
+
-d, --dot include files/folders with a dot (for example `.github`)
|
|
36
|
+
-f, --fix fix basic errors (does not work with STDIN)
|
|
37
|
+
-i, --ignore <file|directory|glob> file(s) to ignore/exclude (default: [])
|
|
38
|
+
-j, --json write issues in json format
|
|
39
|
+
-o, --output <outputFile> write issues to file (no console)
|
|
40
|
+
-p, --ignore-path <file> path to file with ignore pattern(s)
|
|
41
|
+
-q, --quiet do not write issues to STDOUT
|
|
42
|
+
-r, --rules <file|directory|glob|package> include custom rule files (default: [])
|
|
43
|
+
-s, --stdin read from STDIN (does not work with files)
|
|
44
|
+
--enable <rules...> Enable certain rules, e.g. --enable MD013 MD041 --
|
|
45
|
+
--disable <rules...> Disable certain rules, e.g. --disable MD013 MD041 --
|
|
46
|
+
-h, --help display help for command
|
|
44
47
|
```
|
|
45
48
|
|
|
46
49
|
Or run using [Docker](https://www.docker.com) and [GitHub Packages](https://github.com/features/packages):
|
|
@@ -139,7 +142,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
|
|
|
139
142
|
|
|
140
143
|
```yaml
|
|
141
144
|
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
142
|
-
rev: v0.
|
|
145
|
+
rev: v0.45.0
|
|
143
146
|
hooks:
|
|
144
147
|
- id: markdownlint
|
|
145
148
|
```
|
package/markdownlint.js
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import Module from 'node:module';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import process from 'node:process';
|
|
8
|
+
import {program} from 'commander';
|
|
9
|
+
import {glob} from 'glob';
|
|
10
|
+
import {applyFixes} from 'markdownlint';
|
|
11
|
+
import {lint, readConfig} from 'markdownlint/sync';
|
|
12
|
+
import rc from 'run-con';
|
|
13
|
+
import {minimatch} from 'minimatch';
|
|
14
|
+
import jsonpointer from 'jsonpointer';
|
|
15
|
+
|
|
16
|
+
const require = Module.createRequire(import.meta.url);
|
|
18
17
|
const options = program.opts();
|
|
18
|
+
// The following two values are copied from package.json (and validated by tests)
|
|
19
|
+
const version = '0.45.0';
|
|
20
|
+
const description = 'MarkdownLint Command Line Interface';
|
|
21
|
+
|
|
22
|
+
function markdownItFactory() {
|
|
23
|
+
return require('markdown-it')({html: true});
|
|
24
|
+
}
|
|
19
25
|
|
|
20
26
|
function posixPath(p) {
|
|
21
27
|
return p.split(path.sep).join(path.posix.sep);
|
|
@@ -59,8 +65,8 @@ function readConfiguration(userConfigFile) {
|
|
|
59
65
|
let config = rc('markdownlint', {});
|
|
60
66
|
for (const projectConfigFile of projectConfigFiles) {
|
|
61
67
|
try {
|
|
62
|
-
fs.accessSync(projectConfigFile
|
|
63
|
-
const projectConfig =
|
|
68
|
+
fs.accessSync(projectConfigFile);
|
|
69
|
+
const projectConfig = readConfig(projectConfigFile, configParsers);
|
|
64
70
|
config = {...config, ...projectConfig};
|
|
65
71
|
break;
|
|
66
72
|
} catch {
|
|
@@ -73,7 +79,7 @@ function readConfiguration(userConfigFile) {
|
|
|
73
79
|
if (userConfigFile) {
|
|
74
80
|
try {
|
|
75
81
|
const jsConfigFile = /\.c?js$/i.test(userConfigFile);
|
|
76
|
-
const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) :
|
|
82
|
+
const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) : readConfig(userConfigFile, configParsers);
|
|
77
83
|
config = require('deep-extend')(config, userConfig);
|
|
78
84
|
} catch (error) {
|
|
79
85
|
console.error(`Cannot read or parse config file '${userConfigFile}': ${error.message}`);
|
|
@@ -195,9 +201,8 @@ function concatArray(item, array) {
|
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
program
|
|
198
|
-
.version(
|
|
199
|
-
.description(
|
|
200
|
-
.usage('[options] <files|directories|globs>')
|
|
204
|
+
.version(version)
|
|
205
|
+
.description(description)
|
|
201
206
|
.option('-c, --config <configFile>', 'configuration file (JSON, JSONC, JS, YAML, or TOML)')
|
|
202
207
|
.option('--configPointer <pointer>', 'JSON Pointer to object within configuration file', '')
|
|
203
208
|
.option('-d, --dot', 'include files/folders with a dot (for example `.github`)')
|
|
@@ -210,7 +215,8 @@ program
|
|
|
210
215
|
.option('-r, --rules <file|directory|glob|package>', 'include custom rule files', concatArray, [])
|
|
211
216
|
.option('-s, --stdin', 'read from STDIN (does not work with files)')
|
|
212
217
|
.option('--enable <rules...>', 'Enable certain rules, e.g. --enable MD013 MD041 --')
|
|
213
|
-
.option('--disable <rules...>', 'Disable certain rules, e.g. --disable MD013 MD041 --')
|
|
218
|
+
.option('--disable <rules...>', 'Disable certain rules, e.g. --disable MD013 MD041 --')
|
|
219
|
+
.argument('[files|directories|globs...]', 'files, directories, and/or globs to lint');
|
|
214
220
|
|
|
215
221
|
program.parse(process.argv);
|
|
216
222
|
|
|
@@ -241,7 +247,7 @@ function loadCustomRules(rules) {
|
|
|
241
247
|
return rules.flatMap(rule => {
|
|
242
248
|
try {
|
|
243
249
|
const resolvedPath = [tryResolvePath(rule)];
|
|
244
|
-
const fileList = prepareFileList(resolvedPath, ['js']).flatMap(filepath => require(filepath.absolute));
|
|
250
|
+
const fileList = prepareFileList(resolvedPath, ['js', 'cjs', 'mjs']).flatMap(filepath => require(filepath.absolute));
|
|
245
251
|
if (fileList.length === 0) {
|
|
246
252
|
throw new Error('No such rule');
|
|
247
253
|
}
|
|
@@ -289,6 +295,7 @@ function lintAndPrint(stdin, files) {
|
|
|
289
295
|
}
|
|
290
296
|
|
|
291
297
|
const lintOptions = {
|
|
298
|
+
markdownItFactory,
|
|
292
299
|
config,
|
|
293
300
|
configParsers,
|
|
294
301
|
customRules,
|
|
@@ -300,22 +307,15 @@ function lintAndPrint(stdin, files) {
|
|
|
300
307
|
};
|
|
301
308
|
}
|
|
302
309
|
|
|
303
|
-
if (options.json) {
|
|
304
|
-
lintOptions.resultVersion = 3;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
310
|
if (options.fix) {
|
|
308
|
-
const fixOptions = {
|
|
309
|
-
...lintOptions,
|
|
310
|
-
resultVersion: 3
|
|
311
|
-
};
|
|
311
|
+
const fixOptions = {...lintOptions};
|
|
312
312
|
for (const file of files) {
|
|
313
313
|
fixOptions.files = [file];
|
|
314
|
-
const fixResult =
|
|
314
|
+
const fixResult = lint(fixOptions);
|
|
315
315
|
const fixes = fixResult[file].filter(error => error.fixInfo);
|
|
316
316
|
if (fixes.length > 0) {
|
|
317
317
|
const originalText = fs.readFileSync(file, fsOptions);
|
|
318
|
-
const fixedText =
|
|
318
|
+
const fixedText = applyFixes(originalText, fixes);
|
|
319
319
|
if (originalText !== fixedText) {
|
|
320
320
|
fs.writeFileSync(file, fixedText, fsOptions);
|
|
321
321
|
}
|
|
@@ -323,7 +323,7 @@ function lintAndPrint(stdin, files) {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
const lintResult =
|
|
326
|
+
const lintResult = lint(lintOptions);
|
|
327
327
|
printResult(lintResult);
|
|
328
328
|
}
|
|
329
329
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "MarkdownLint Command Line Interface",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "markdownlint.js",
|
|
6
7
|
"bin": {
|
|
7
8
|
"markdownlint": "markdownlint.js"
|
|
8
9
|
},
|
|
9
10
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
11
|
+
"node": ">=20"
|
|
11
12
|
},
|
|
12
13
|
"scripts": {
|
|
13
14
|
"invalid": "node ./markdownlint.js --config test/test-config.json -- test/incorrect.md",
|
|
@@ -37,22 +38,23 @@
|
|
|
37
38
|
},
|
|
38
39
|
"homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"commander": "~
|
|
41
|
-
"glob": "~11.0.
|
|
42
|
-
"ignore": "~
|
|
43
|
-
"js-yaml": "
|
|
41
|
+
"commander": "~13.1.0",
|
|
42
|
+
"glob": "~11.0.2",
|
|
43
|
+
"ignore": "~7.0.4",
|
|
44
|
+
"js-yaml": "~4.1.0",
|
|
44
45
|
"jsonc-parser": "~3.3.1",
|
|
45
|
-
"jsonpointer": "5.0.1",
|
|
46
|
-
"markdownlint": "~0.
|
|
46
|
+
"jsonpointer": "~5.0.1",
|
|
47
|
+
"markdownlint": "~0.38.0",
|
|
48
|
+
"markdown-it": "~14.1.0",
|
|
47
49
|
"minimatch": "~10.0.1",
|
|
48
50
|
"run-con": "~1.3.2",
|
|
49
|
-
"smol-toml": "~1.3.
|
|
51
|
+
"smol-toml": "~1.3.4"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"ava": "^6.2.0",
|
|
53
55
|
"markdownlint-cli-local-test-rule": "./test/custom-rules/markdownlint-cli-local-test-rule",
|
|
54
|
-
"nano-spawn": "^0.
|
|
55
|
-
"xo": "^0.
|
|
56
|
+
"nano-spawn": "^1.0.1",
|
|
57
|
+
"xo": "^0.60.0"
|
|
56
58
|
},
|
|
57
59
|
"xo": {
|
|
58
60
|
"prettier": true,
|
|
@@ -80,8 +82,12 @@
|
|
|
80
82
|
"ava": {
|
|
81
83
|
"files": [
|
|
82
84
|
"test/**/*.js",
|
|
85
|
+
"test/**/*.cjs",
|
|
86
|
+
"test/**/*.mjs",
|
|
83
87
|
"!test/custom-rules/**/*.js",
|
|
84
|
-
"!test/
|
|
88
|
+
"!test/custom-rules/**/*.cjs",
|
|
89
|
+
"!test/custom-rules/**/*.mjs",
|
|
90
|
+
"!test/md043-config.cjs"
|
|
85
91
|
],
|
|
86
92
|
"failFast": true,
|
|
87
93
|
"timeout": "1m",
|