markdownlint-cli 0.42.0 → 0.44.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 +29 -35
- package/package.json +18 -14
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.44.0
|
|
143
146
|
hooks:
|
|
144
147
|
- id: markdownlint
|
|
145
148
|
```
|
package/markdownlint.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
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.44.0';
|
|
20
|
+
const description = 'MarkdownLint Command Line Interface';
|
|
19
21
|
|
|
20
22
|
function posixPath(p) {
|
|
21
23
|
return p.split(path.sep).join(path.posix.sep);
|
|
@@ -60,7 +62,7 @@ function readConfiguration(userConfigFile) {
|
|
|
60
62
|
for (const projectConfigFile of projectConfigFiles) {
|
|
61
63
|
try {
|
|
62
64
|
fs.accessSync(projectConfigFile, fs.R_OK);
|
|
63
|
-
const projectConfig =
|
|
65
|
+
const projectConfig = readConfig(projectConfigFile, configParsers);
|
|
64
66
|
config = {...config, ...projectConfig};
|
|
65
67
|
break;
|
|
66
68
|
} catch {
|
|
@@ -73,7 +75,7 @@ function readConfiguration(userConfigFile) {
|
|
|
73
75
|
if (userConfigFile) {
|
|
74
76
|
try {
|
|
75
77
|
const jsConfigFile = /\.c?js$/i.test(userConfigFile);
|
|
76
|
-
const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) :
|
|
78
|
+
const userConfig = jsConfigFile ? require(path.resolve(processCwd, userConfigFile)) : readConfig(userConfigFile, configParsers);
|
|
77
79
|
config = require('deep-extend')(config, userConfig);
|
|
78
80
|
} catch (error) {
|
|
79
81
|
console.error(`Cannot read or parse config file '${userConfigFile}': ${error.message}`);
|
|
@@ -195,9 +197,8 @@ function concatArray(item, array) {
|
|
|
195
197
|
}
|
|
196
198
|
|
|
197
199
|
program
|
|
198
|
-
.version(
|
|
199
|
-
.description(
|
|
200
|
-
.usage('[options] <files|directories|globs>')
|
|
200
|
+
.version(version)
|
|
201
|
+
.description(description)
|
|
201
202
|
.option('-c, --config <configFile>', 'configuration file (JSON, JSONC, JS, YAML, or TOML)')
|
|
202
203
|
.option('--configPointer <pointer>', 'JSON Pointer to object within configuration file', '')
|
|
203
204
|
.option('-d, --dot', 'include files/folders with a dot (for example `.github`)')
|
|
@@ -210,7 +211,8 @@ program
|
|
|
210
211
|
.option('-r, --rules <file|directory|glob|package>', 'include custom rule files', concatArray, [])
|
|
211
212
|
.option('-s, --stdin', 'read from STDIN (does not work with files)')
|
|
212
213
|
.option('--enable <rules...>', 'Enable certain rules, e.g. --enable MD013 MD041 --')
|
|
213
|
-
.option('--disable <rules...>', 'Disable certain rules, e.g. --disable MD013 MD041 --')
|
|
214
|
+
.option('--disable <rules...>', 'Disable certain rules, e.g. --disable MD013 MD041 --')
|
|
215
|
+
.argument('[files|directories|globs...]', 'files, directories, and/or globs to lint');
|
|
214
216
|
|
|
215
217
|
program.parse(process.argv);
|
|
216
218
|
|
|
@@ -241,7 +243,7 @@ function loadCustomRules(rules) {
|
|
|
241
243
|
return rules.flatMap(rule => {
|
|
242
244
|
try {
|
|
243
245
|
const resolvedPath = [tryResolvePath(rule)];
|
|
244
|
-
const fileList = prepareFileList(resolvedPath, ['js']).flatMap(filepath => require(filepath.absolute));
|
|
246
|
+
const fileList = prepareFileList(resolvedPath, ['js', 'cjs', 'mjs']).flatMap(filepath => require(filepath.absolute));
|
|
245
247
|
if (fileList.length === 0) {
|
|
246
248
|
throw new Error('No such rule');
|
|
247
249
|
}
|
|
@@ -300,23 +302,15 @@ function lintAndPrint(stdin, files) {
|
|
|
300
302
|
};
|
|
301
303
|
}
|
|
302
304
|
|
|
303
|
-
if (options.json) {
|
|
304
|
-
lintOptions.resultVersion = 3;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
305
|
if (options.fix) {
|
|
308
|
-
const fixOptions = {
|
|
309
|
-
...lintOptions,
|
|
310
|
-
resultVersion: 3
|
|
311
|
-
};
|
|
312
|
-
const markdownlintRuleHelpers = require('markdownlint/helpers');
|
|
306
|
+
const fixOptions = {...lintOptions};
|
|
313
307
|
for (const file of files) {
|
|
314
308
|
fixOptions.files = [file];
|
|
315
|
-
const fixResult =
|
|
309
|
+
const fixResult = lint(fixOptions);
|
|
316
310
|
const fixes = fixResult[file].filter(error => error.fixInfo);
|
|
317
311
|
if (fixes.length > 0) {
|
|
318
312
|
const originalText = fs.readFileSync(file, fsOptions);
|
|
319
|
-
const fixedText =
|
|
313
|
+
const fixedText = applyFixes(originalText, fixes);
|
|
320
314
|
if (originalText !== fixedText) {
|
|
321
315
|
fs.writeFileSync(file, fixedText, fsOptions);
|
|
322
316
|
}
|
|
@@ -324,7 +318,7 @@ function lintAndPrint(stdin, files) {
|
|
|
324
318
|
}
|
|
325
319
|
}
|
|
326
320
|
|
|
327
|
-
const lintResult =
|
|
321
|
+
const lintResult = lint(lintOptions);
|
|
328
322
|
printResult(lintResult);
|
|
329
323
|
}
|
|
330
324
|
|
|
@@ -332,7 +326,7 @@ try {
|
|
|
332
326
|
if (files.length > 0 && !options.stdin) {
|
|
333
327
|
lintAndPrint(null, diff);
|
|
334
328
|
} else if (files.length === 0 && options.stdin && !options.fix) {
|
|
335
|
-
import('
|
|
329
|
+
import('node:stream/consumers').then(module => module.text(process.stdin)).then(lintAndPrint);
|
|
336
330
|
} else {
|
|
337
331
|
program.help();
|
|
338
332
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "MarkdownLint Command Line Interface",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "markdownlint.js",
|
|
6
7
|
"bin": {
|
|
7
8
|
"markdownlint": "markdownlint.js"
|
|
@@ -37,23 +38,22 @@
|
|
|
37
38
|
},
|
|
38
39
|
"homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"commander": "~
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"js-yaml": "^4.1.0",
|
|
41
|
+
"commander": "~13.1.0",
|
|
42
|
+
"glob": "~10.4.5",
|
|
43
|
+
"ignore": "~7.0.3",
|
|
44
|
+
"js-yaml": "~4.1.0",
|
|
45
45
|
"jsonc-parser": "~3.3.1",
|
|
46
|
-
"jsonpointer": "5.0.1",
|
|
47
|
-
"markdownlint": "~0.
|
|
48
|
-
"minimatch": "~
|
|
46
|
+
"jsonpointer": "~5.0.1",
|
|
47
|
+
"markdownlint": "~0.37.4",
|
|
48
|
+
"minimatch": "~9.0.5",
|
|
49
49
|
"run-con": "~1.3.2",
|
|
50
|
-
"smol-toml": "~1.3.
|
|
50
|
+
"smol-toml": "~1.3.1"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"ava": "^6.
|
|
53
|
+
"ava": "^6.2.0",
|
|
54
54
|
"markdownlint-cli-local-test-rule": "./test/custom-rules/markdownlint-cli-local-test-rule",
|
|
55
|
-
"nano-spawn": "^0.
|
|
56
|
-
"xo": "^0.
|
|
55
|
+
"nano-spawn": "^0.2.0",
|
|
56
|
+
"xo": "^0.60.0"
|
|
57
57
|
},
|
|
58
58
|
"xo": {
|
|
59
59
|
"prettier": true,
|
|
@@ -81,8 +81,12 @@
|
|
|
81
81
|
"ava": {
|
|
82
82
|
"files": [
|
|
83
83
|
"test/**/*.js",
|
|
84
|
+
"test/**/*.cjs",
|
|
85
|
+
"test/**/*.mjs",
|
|
84
86
|
"!test/custom-rules/**/*.js",
|
|
85
|
-
"!test/
|
|
87
|
+
"!test/custom-rules/**/*.cjs",
|
|
88
|
+
"!test/custom-rules/**/*.mjs",
|
|
89
|
+
"!test/md043-config.cjs"
|
|
86
90
|
],
|
|
87
91
|
"failFast": true,
|
|
88
92
|
"timeout": "1m",
|