markdownlint-cli 0.49.0 → 0.50.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 -7
- package/markdownlint.js +25 -19
- package/package.json +35 -24
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Arguments:
|
|
|
30
30
|
|
|
31
31
|
Options:
|
|
32
32
|
-V, --version output the version number
|
|
33
|
-
-c, --config <configFile> configuration file (JSON, JSONC, JS,
|
|
33
|
+
-c, --config <configFile> configuration file (JSON, JSONC, JS, TOML, or YAML)
|
|
34
34
|
--configPointer <pointer> JSON Pointer to object within configuration file (default: "")
|
|
35
35
|
-d, --dot include files/folders with a dot (for example `.github`)
|
|
36
36
|
-f, --fix fix basic issues (does not work with STDIN)
|
|
@@ -109,10 +109,10 @@ A sample configuration file:
|
|
|
109
109
|
For more examples, see [.markdownlint.jsonc][markdownlint-jsonc], [.markdownlint.yaml][markdownlint-yaml], [test-config.toml](test/test-config.toml) or the [style folder][style-folder].
|
|
110
110
|
|
|
111
111
|
The CLI argument `--config` is not required.
|
|
112
|
-
If it is not provided, `markdownlint-cli`
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
If the `--config` argument is provided, the
|
|
112
|
+
If it is not provided, `markdownlint-cli` uses the [`run-con` package to merge configuration from all supported locations][run-con-standards], then overlays any configuration from the first matching file of `.markdownlint.jsonc`/`.markdownlint.json`/`.markdownlint.yaml`/`.markdownlint.yml` in the current folder.
|
|
113
|
+
(For compatibility with other `markdownlint` tooling, use of `run-con` configuration files is discouraged.)
|
|
114
|
+
|
|
115
|
+
If the `--config` argument is provided, the `configFile` specified must be valid JSON, JSONC, JS, TOML, or YAML.
|
|
116
116
|
JS configuration files contain JavaScript code, must have the `.js` or `.cjs` file extension, and must export (via `module.exports = ...`) a configuration object of the form shown above.
|
|
117
117
|
If your workspace _(project)_ is [ESM-only] _(`"type": "module"` set in the root `package.json` file)_, then the configuration file **should end with `.cjs` file extension**.
|
|
118
118
|
A JS configuration file may internally `require` one or more npm packages as a way of reusing configuration across projects.
|
|
@@ -142,7 +142,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
|
|
|
142
142
|
|
|
143
143
|
```yaml
|
|
144
144
|
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
145
|
-
rev: v0.
|
|
145
|
+
rev: v0.50.0
|
|
146
146
|
hooks:
|
|
147
147
|
- id: markdownlint
|
|
148
148
|
```
|
|
@@ -171,7 +171,7 @@ MIT © Igor Shubovych
|
|
|
171
171
|
[rules]: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
|
|
172
172
|
[config]: https://github.com/DavidAnson/markdownlint#optionsconfig
|
|
173
173
|
[style-folder]: https://github.com/DavidAnson/markdownlint/tree/main/style
|
|
174
|
-
[
|
|
174
|
+
[run-con-standards]: https://www.npmjs.com/package/run-con#standards
|
|
175
175
|
[glob]: https://github.com/isaacs/node-glob
|
|
176
176
|
[globprimer]: https://github.com/isaacs/node-glob/blob/master/README.md#glob-primer
|
|
177
177
|
[ignore]: https://github.com/kaelzhang/node-ignore
|
package/markdownlint.js
CHANGED
|
@@ -16,7 +16,7 @@ import jsonpointer from 'jsonpointer';
|
|
|
16
16
|
const require = Module.createRequire(import.meta.url);
|
|
17
17
|
const options = program.opts();
|
|
18
18
|
// The following two values are copied from package.json (and validated by tests)
|
|
19
|
-
const version = '0.
|
|
19
|
+
const version = '0.50.0';
|
|
20
20
|
const description = 'MarkdownLint Command Line Interface';
|
|
21
21
|
|
|
22
22
|
function markdownItFactory() {
|
|
@@ -51,7 +51,7 @@ const exitCodes = {
|
|
|
51
51
|
lintErrorsPresent: 1,
|
|
52
52
|
failedToWriteOutputFile: 2,
|
|
53
53
|
failedToLoadCustomRules: 3,
|
|
54
|
-
unexpectedError: 4
|
|
54
|
+
unexpectedError: 4,
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
const projectConfigFiles = ['.markdownlint.jsonc', '.markdownlint.json', '.markdownlint.yaml', '.markdownlint.yml'];
|
|
@@ -78,8 +78,8 @@ function readConfiguration(userConfigFile) {
|
|
|
78
78
|
// However I have to do it to overwrite configuration from .markdownlint.{jsonc,json,yaml,yml}.
|
|
79
79
|
if (userConfigFile) {
|
|
80
80
|
try {
|
|
81
|
-
const
|
|
82
|
-
const userConfig =
|
|
81
|
+
const isJsConfigFile = /\.c?js$/iv.test(userConfigFile);
|
|
82
|
+
const userConfig = isJsConfigFile ? require(path.resolve(processCwd, userConfigFile)) : readConfig(userConfigFile, configParsers);
|
|
83
83
|
config = require('deep-extend')(config, userConfig);
|
|
84
84
|
} catch (error) {
|
|
85
85
|
console.error(`Cannot read or parse config file '${userConfigFile}': ${error.message}`);
|
|
@@ -95,7 +95,7 @@ function prepareFileList(files, fileExtensions, previousResults) {
|
|
|
95
95
|
dot: Boolean(options.dot),
|
|
96
96
|
onlyFiles: true,
|
|
97
97
|
expandDirectories: false,
|
|
98
|
-
caseSensitiveMatch: !(os.platform() === 'win32' || os.platform() === 'darwin')
|
|
98
|
+
caseSensitiveMatch: !(os.platform() === 'win32' || os.platform() === 'darwin'),
|
|
99
99
|
};
|
|
100
100
|
let extensionGlobPart = '*.';
|
|
101
101
|
if (!fileExtensions) {
|
|
@@ -135,7 +135,7 @@ function prepareFileList(files, fileExtensions, previousResults) {
|
|
|
135
135
|
return files.flat().map(file => ({
|
|
136
136
|
original: file,
|
|
137
137
|
relative: path.relative(processCwd, file),
|
|
138
|
-
absolute: path.resolve(file)
|
|
138
|
+
absolute: path.resolve(file),
|
|
139
139
|
}));
|
|
140
140
|
}
|
|
141
141
|
|
|
@@ -145,7 +145,7 @@ function printResult(lintResult) {
|
|
|
145
145
|
if (options.json) {
|
|
146
146
|
return {
|
|
147
147
|
fileName: file,
|
|
148
|
-
...result
|
|
148
|
+
...result,
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -155,9 +155,9 @@ function printResult(lintResult) {
|
|
|
155
155
|
column: (result.errorRange && result.errorRange[0]) || 0,
|
|
156
156
|
names: result.ruleNames.join('/'),
|
|
157
157
|
description: result.ruleDescription + (result.errorDetail ? ' [' + result.errorDetail + ']' : '') + (result.errorContext ? ' [Context: "' + result.errorContext + '"]' : ''),
|
|
158
|
-
severity: result.severity
|
|
158
|
+
severity: result.severity,
|
|
159
159
|
};
|
|
160
|
-
})
|
|
160
|
+
}),
|
|
161
161
|
);
|
|
162
162
|
|
|
163
163
|
let lintResultString = '';
|
|
@@ -170,9 +170,9 @@ function printResult(lintResult) {
|
|
|
170
170
|
|
|
171
171
|
lintResultString = results
|
|
172
172
|
.map(result => {
|
|
173
|
-
const {file, lineNumber, column, names,
|
|
173
|
+
const {file, lineNumber, column, names, severity} = result;
|
|
174
174
|
const columnText = column ? `:${column}` : '';
|
|
175
|
-
return `${file}:${lineNumber}${columnText} ${severity} ${names} ${description}`;
|
|
175
|
+
return `${file}:${lineNumber}${columnText} ${severity} ${names} ${result.description}`;
|
|
176
176
|
})
|
|
177
177
|
.join('\n');
|
|
178
178
|
}
|
|
@@ -209,7 +209,7 @@ function concatArray(item, array) {
|
|
|
209
209
|
program
|
|
210
210
|
.version(version)
|
|
211
211
|
.description(description)
|
|
212
|
-
.option('-c, --config <configFile>', 'configuration file (JSON, JSONC, JS,
|
|
212
|
+
.option('-c, --config <configFile>', 'configuration file (JSON, JSONC, JS, TOML, or YAML)')
|
|
213
213
|
.option('--configPointer <pointer>', 'JSON Pointer to object within configuration file', '')
|
|
214
214
|
.option('-d, --dot', 'include files/folders with a dot (for example `.github`)')
|
|
215
215
|
.option('-f, --fix', 'fix basic issues (does not work with STDIN)')
|
|
@@ -273,6 +273,7 @@ if (options.ignorePath) {
|
|
|
273
273
|
existsSync = () => true;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
+
// eslint-disable-next-line unicorn/consistent-boolean-name
|
|
276
277
|
let ignoreFilter = () => true;
|
|
277
278
|
if (existsSync(ignorePath)) {
|
|
278
279
|
const ignoreText = fs.readFileSync(ignorePath, fsOptions);
|
|
@@ -281,10 +282,10 @@ if (existsSync(ignorePath)) {
|
|
|
281
282
|
ignoreFilter = fileInfo => !ignoreInstance.ignores(fileInfo.relative);
|
|
282
283
|
}
|
|
283
284
|
|
|
284
|
-
const
|
|
285
|
-
const ignores = prepareFileList(options.ignore, null,
|
|
285
|
+
const inputs = prepareFileList(program.args, ['md', 'markdown']).filter(value => ignoreFilter(value));
|
|
286
|
+
const ignores = prepareFileList(options.ignore, null, inputs);
|
|
286
287
|
const customRules = loadCustomRules(options.rules);
|
|
287
|
-
const diff =
|
|
288
|
+
const diff = inputs.filter(file => ignores.every(ignore => ignore.absolute !== file.absolute)).map(paths => paths.original);
|
|
288
289
|
|
|
289
290
|
function lintAndPrint(stdin, files) {
|
|
290
291
|
files ||= [];
|
|
@@ -305,11 +306,12 @@ function lintAndPrint(stdin, files) {
|
|
|
305
306
|
config,
|
|
306
307
|
configParsers,
|
|
307
308
|
customRules,
|
|
308
|
-
files
|
|
309
|
+
files,
|
|
309
310
|
};
|
|
311
|
+
// eslint-disable-next-line unicorn/no-immediate-mutation
|
|
310
312
|
if (stdin) {
|
|
311
313
|
lintOptions.strings = {
|
|
312
|
-
stdin
|
|
314
|
+
stdin,
|
|
313
315
|
};
|
|
314
316
|
}
|
|
315
317
|
|
|
@@ -319,6 +321,7 @@ function lintAndPrint(stdin, files) {
|
|
|
319
321
|
fixOptions.files = [file];
|
|
320
322
|
const fixResult = lint(fixOptions);
|
|
321
323
|
const fixes = fixResult[file].filter(error => error.fixInfo);
|
|
324
|
+
// eslint-disable-next-line unicorn/prefer-continue
|
|
322
325
|
if (fixes.length > 0) {
|
|
323
326
|
const originalText = fs.readFileSync(file, fsOptions);
|
|
324
327
|
const fixedText = applyFixes(originalText, fixes);
|
|
@@ -334,10 +337,13 @@ function lintAndPrint(stdin, files) {
|
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
try {
|
|
337
|
-
if (
|
|
340
|
+
if (inputs.length > 0 && !options.stdin) {
|
|
338
341
|
lintAndPrint(null, diff);
|
|
339
|
-
} else if (
|
|
342
|
+
} else if (inputs.length === 0 && options.stdin && !options.fix) {
|
|
340
343
|
import('node:stream/consumers').then(module => module.text(process.stdin)).then(lintAndPrint);
|
|
344
|
+
} else if (program.args.length > 0 && !options.stdin) {
|
|
345
|
+
// Files, directories, or globs were given, but none of them resolved to a Markdown file.
|
|
346
|
+
console.warn('No matching files found');
|
|
341
347
|
} else {
|
|
342
348
|
program.help();
|
|
343
349
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "MarkdownLint Command Line Interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "markdownlint.js",
|
|
@@ -40,38 +40,49 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"commander": "~15.0.0",
|
|
42
42
|
"deep-extend": "~0.6.0",
|
|
43
|
-
"ignore": "~7.0.
|
|
44
|
-
"js-yaml": "~
|
|
43
|
+
"ignore": "~7.0.13",
|
|
44
|
+
"js-yaml": "~5.5.0",
|
|
45
45
|
"jsonc-parser": "~3.3.1",
|
|
46
46
|
"jsonpointer": "~5.0.1",
|
|
47
|
-
"markdownlint": "~0.
|
|
48
|
-
"markdown-it": "~
|
|
49
|
-
"minimatch": "~10.2.
|
|
50
|
-
"run-con": "~1.3.
|
|
51
|
-
"smol-toml": "~1.
|
|
47
|
+
"markdownlint": "~0.42.0",
|
|
48
|
+
"markdown-it": "~15.0.3",
|
|
49
|
+
"minimatch": "~10.2.6",
|
|
50
|
+
"run-con": "~1.3.3",
|
|
51
|
+
"smol-toml": "~1.9.1",
|
|
52
52
|
"tinyglobby": "~0.2.17"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"ava": "^8.0
|
|
55
|
+
"ava": "^8.1.0",
|
|
56
56
|
"markdownlint-cli-local-test-rule": "./test/custom-rules/markdownlint-cli-local-test-rule",
|
|
57
57
|
"nano-spawn": "^2.1.0",
|
|
58
|
-
"xo": "^
|
|
58
|
+
"xo": "^5.0.1"
|
|
59
59
|
},
|
|
60
|
-
"xo":
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
"xo": [
|
|
61
|
+
{
|
|
62
|
+
"files": "**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,svelte,astro,html}",
|
|
63
|
+
"rules": {
|
|
64
|
+
"comma-dangle": 0,
|
|
65
|
+
"linebreak-style": 0,
|
|
66
|
+
"no-var": 0,
|
|
67
|
+
"prefer-arrow-callback": 0,
|
|
68
|
+
"promise/prefer-await-to-then": 0,
|
|
69
|
+
"object-shorthand": 0,
|
|
70
|
+
"@stylistic/indent": [ "error", 2 ],
|
|
71
|
+
"@stylistic/max-len": 0,
|
|
72
|
+
"regexp/prefer-named-capture-group": 0,
|
|
73
|
+
"unicorn/max-nested-calls": 0,
|
|
74
|
+
"unicorn/prefer-module": 0,
|
|
75
|
+
"unicorn/prefer-ternary": 0,
|
|
76
|
+
"unicorn/prefer-top-level-await": 0
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"ignores": [
|
|
81
|
+
"**/package.json",
|
|
82
|
+
"test/config-files/json-c/.markdownlint.json"
|
|
83
|
+
]
|
|
73
84
|
}
|
|
74
|
-
|
|
85
|
+
],
|
|
75
86
|
"prettier": {
|
|
76
87
|
"arrowParens": "avoid",
|
|
77
88
|
"bracketSpacing": false,
|