markdownlint-cli 0.31.1 → 0.32.2
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 +11 -5
- package/markdownlint.js +11 -8
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -37,8 +37,8 @@ markdownlint --help
|
|
|
37
37
|
-q, --quiet do not write issues to STDOUT
|
|
38
38
|
-r, --rules [file|directory|glob|package] include custom rule files (default: [])
|
|
39
39
|
-s, --stdin read from STDIN (does not work with files)
|
|
40
|
-
--enable [rules...] Enable certain rules, e.g. --enable MD013 MD041
|
|
41
|
-
--disable [rules...] Disable certain rules, e.g. --disable MD013 MD041
|
|
40
|
+
--enable [rules...] Enable certain rules, e.g. --enable MD013 MD041 --
|
|
41
|
+
--disable [rules...] Disable certain rules, e.g. --disable MD013 MD041 --
|
|
42
42
|
-h, --help display help for command
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -48,6 +48,9 @@ Or run using [Docker](https://www.docker.com) and [GitHub Packages](https://gith
|
|
|
48
48
|
docker run -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "*.md"
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
> **Note**
|
|
52
|
+
> Because `--enable` and `--disable` are [variadic arguments that accept multiple values][commander-variadic], it is necessary to end the list by passing `--` before the `<files|directories|globs>` argument like so: `markdownlint --disable MD013 -- README.md`.
|
|
53
|
+
|
|
51
54
|
### Globbing
|
|
52
55
|
|
|
53
56
|
`markdownlint-cli` supports advanced globbing patterns like `**/*.md` ([more information][globprimer]).
|
|
@@ -102,10 +105,11 @@ A sample configuration file:
|
|
|
102
105
|
For more examples, see [.markdownlint.jsonc][markdownlint-jsonc], [.markdownlint.yaml][markdownlint-yaml], or the [style folder][style-folder].
|
|
103
106
|
|
|
104
107
|
The CLI argument `--config` is not required.
|
|
105
|
-
If it is not provided, `markdownlint-cli` looks for the file `.markdownlint.json`/`.markdownlint.yaml`/`.markdownlint.yml` in current folder, or for the file `.markdownlintrc` in the current or all parent folders.
|
|
108
|
+
If it is not provided, `markdownlint-cli` looks for the file `.markdownlint.jsonc`/`.markdownlint.json`/`.markdownlint.yaml`/`.markdownlint.yml` in current folder, or for the file `.markdownlintrc` in the current or all parent folders.
|
|
106
109
|
The algorithm is described in detail on the [`rc` package page][rc-standards].
|
|
107
110
|
If the `--config` argument is provided, the file must be valid JSON, JSONC, JS, or YAML.
|
|
108
|
-
JS configuration files contain JavaScript code, must have the `.js` extension, and must export (via `module.exports = ...`) a configuration object of the form shown above.
|
|
111
|
+
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.
|
|
112
|
+
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**.
|
|
109
113
|
A JS configuration file may internally `require` one or more npm packages as a way of reusing configuration across projects.
|
|
110
114
|
|
|
111
115
|
`--enable` and `--disable` override configuration files; if a configuration file disables `MD002` and you pass `--enable MD002`, it will be enabled.
|
|
@@ -129,7 +133,7 @@ To run `markdownlint-cli` as part of a [pre-commit][pre-commit] workflow, add so
|
|
|
129
133
|
|
|
130
134
|
```yaml
|
|
131
135
|
- repo: https://github.com/igorshubovych/markdownlint-cli
|
|
132
|
-
rev: v0.
|
|
136
|
+
rev: v0.32.2
|
|
133
137
|
hooks:
|
|
134
138
|
- id: markdownlint
|
|
135
139
|
```
|
|
@@ -148,6 +152,7 @@ MIT © Igor Shubovych
|
|
|
148
152
|
|
|
149
153
|
[actions-badge]: https://github.com/igorshubovych/markdownlint-cli/workflows/CI/badge.svg?branch=master
|
|
150
154
|
[actions-url]: https://github.com/igorshubovych/markdownlint-cli/actions?query=workflow%3ACI
|
|
155
|
+
[commander-variadic]: https://github.com/tj/commander.js#variadic-option
|
|
151
156
|
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
|
152
157
|
[markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc
|
|
153
158
|
[markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
|
|
@@ -161,3 +166,4 @@ MIT © Igor Shubovych
|
|
|
161
166
|
[gitignore]: https://git-scm.com/docs/gitignore
|
|
162
167
|
[pre-commit]: https://pre-commit.com/
|
|
163
168
|
[pre-commit-version]: https://pre-commit.com/#overriding-language-version
|
|
169
|
+
[ESM-only]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
package/markdownlint.js
CHANGED
|
@@ -16,6 +16,10 @@ const rc = require('run-con');
|
|
|
16
16
|
const minimatch = require('minimatch');
|
|
17
17
|
const pkg = require('./package.json');
|
|
18
18
|
|
|
19
|
+
function posixPath(p) {
|
|
20
|
+
return p.split(path.sep).join(path.posix.sep);
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
function jsoncParse(text) {
|
|
20
24
|
return JSON.parse(require('jsonc-parser').stripComments(text));
|
|
21
25
|
}
|
|
@@ -31,13 +35,13 @@ const exitCodes = {
|
|
|
31
35
|
unexpectedError: 4
|
|
32
36
|
};
|
|
33
37
|
|
|
34
|
-
const projectConfigFiles = ['.markdownlint.json', '.markdownlint.yaml', '.markdownlint.yml'];
|
|
38
|
+
const projectConfigFiles = ['.markdownlint.jsonc', '.markdownlint.json', '.markdownlint.yaml', '.markdownlint.yml'];
|
|
35
39
|
const configFileParsers = [jsoncParse, jsYamlSafeLoad];
|
|
36
40
|
const fsOptions = {encoding: 'utf8'};
|
|
37
41
|
const processCwd = process.cwd();
|
|
38
42
|
|
|
39
43
|
function readConfiguration(userConfigFile) {
|
|
40
|
-
const jsConfigFile = /\.js$/i.test(userConfigFile);
|
|
44
|
+
const jsConfigFile = /\.c?js$/i.test(userConfigFile);
|
|
41
45
|
|
|
42
46
|
// Load from well-known config files
|
|
43
47
|
let config = rc('markdownlint', {});
|
|
@@ -85,16 +89,16 @@ function prepareFileList(files, fileExtensions, previousResults) {
|
|
|
85
89
|
if (fs.lstatSync(file).isDirectory()) {
|
|
86
90
|
// Directory (file falls through to below)
|
|
87
91
|
if (previousResults) {
|
|
88
|
-
const matcher = new minimatch.Minimatch(path.resolve(processCwd, path.join(file, '**', extensionGlobPart)), globOptions);
|
|
92
|
+
const matcher = new minimatch.Minimatch(posixPath(path.resolve(processCwd, path.join(file, '**', extensionGlobPart))), globOptions);
|
|
89
93
|
return previousResults.filter(fileInfo => matcher.match(fileInfo.absolute)).map(fileInfo => fileInfo.original);
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
return glob.sync(path.join(file, '**', extensionGlobPart), globOptions);
|
|
96
|
+
return glob.sync(posixPath(path.join(file, '**', extensionGlobPart)), globOptions);
|
|
93
97
|
}
|
|
94
98
|
} catch {
|
|
95
99
|
// Not a directory, not a file, may be a glob
|
|
96
100
|
if (previousResults) {
|
|
97
|
-
const matcher = new minimatch.Minimatch(path.resolve(processCwd, file), globOptions);
|
|
101
|
+
const matcher = new minimatch.Minimatch(posixPath(path.resolve(processCwd, file)), globOptions);
|
|
98
102
|
return previousResults.filter(fileInfo => matcher.match(fileInfo.absolute)).map(fileInfo => fileInfo.original);
|
|
99
103
|
}
|
|
100
104
|
|
|
@@ -188,8 +192,8 @@ program
|
|
|
188
192
|
.option('-q, --quiet', 'do not write issues to STDOUT')
|
|
189
193
|
.option('-r, --rules [file|directory|glob|package]', 'include custom rule files', concatArray, [])
|
|
190
194
|
.option('-s, --stdin', 'read from STDIN (does not work with files)')
|
|
191
|
-
.option('--enable [rules...]', 'Enable certain rules, e.g. --enable MD013 MD041')
|
|
192
|
-
.option('--disable [rules...]', 'Disable certain rules, e.g. --disable MD013 MD041');
|
|
195
|
+
.option('--enable [rules...]', 'Enable certain rules, e.g. --enable MD013 MD041 --')
|
|
196
|
+
.option('--disable [rules...]', 'Disable certain rules, e.g. --disable MD013 MD041 --');
|
|
193
197
|
|
|
194
198
|
program.parse(process.argv);
|
|
195
199
|
|
|
@@ -311,7 +315,6 @@ try {
|
|
|
311
315
|
if (files.length > 0 && !options.stdin) {
|
|
312
316
|
lintAndPrint(null, diff);
|
|
313
317
|
} else if (files.length === 0 && options.stdin && !options.fix) {
|
|
314
|
-
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
|
315
318
|
import('get-stdin')
|
|
316
319
|
.then(module => module.default())
|
|
317
320
|
.then(lintAndPrint);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.2",
|
|
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": ">=14"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"invalid": "node ./markdownlint.js --config test/test-config.json -- test/incorrect.md",
|
|
@@ -37,22 +37,22 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/igorshubovych/markdownlint-cli#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"commander": "~9.
|
|
40
|
+
"commander": "~9.4.0",
|
|
41
41
|
"get-stdin": "~9.0.0",
|
|
42
|
-
"glob": "~
|
|
42
|
+
"glob": "~8.0.3",
|
|
43
43
|
"ignore": "~5.2.0",
|
|
44
44
|
"js-yaml": "^4.1.0",
|
|
45
|
-
"jsonc-parser": "~3.
|
|
46
|
-
"markdownlint": "~0.
|
|
47
|
-
"markdownlint-rule-helpers": "~0.
|
|
48
|
-
"minimatch": "~
|
|
49
|
-
"run-con": "~1.2.
|
|
45
|
+
"jsonc-parser": "~3.1.0",
|
|
46
|
+
"markdownlint": "~0.26.2",
|
|
47
|
+
"markdownlint-rule-helpers": "~0.17.2",
|
|
48
|
+
"minimatch": "~5.1.0",
|
|
49
|
+
"run-con": "~1.2.11"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"ava": "^4.
|
|
53
|
-
"execa": "^6.
|
|
52
|
+
"ava": "^4.3.1",
|
|
53
|
+
"execa": "^6.1.0",
|
|
54
54
|
"test-rule-package": "./test/custom-rules/test-rule-package",
|
|
55
|
-
"xo": "^0.
|
|
55
|
+
"xo": "^0.51.0"
|
|
56
56
|
},
|
|
57
57
|
"xo": {
|
|
58
58
|
"prettier": true,
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"!test/md043-config.js"
|
|
84
84
|
],
|
|
85
85
|
"failFast": true,
|
|
86
|
+
"timeout": "1m",
|
|
86
87
|
"workerThreads": false
|
|
87
88
|
}
|
|
88
89
|
}
|