markdownlint-cli2 0.11.0 → 0.12.1
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/CHANGELOG.md +16 -0
- package/README.md +28 -49
- package/markdownlint-cli2.js +46 -38
- package/package.json +16 -19
- package/schema/ValidatingConfiguration.md +24 -0
- package/schema/markdownlint-cli2-config-schema.json +16 -15
- package/schema/markdownlint-config-schema.json +165 -113
- package/markdownlint-cli2-config.js +0 -14
- package/markdownlint-cli2-fix.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.12.1
|
|
4
|
+
|
|
5
|
+
- Update JSONC parsing to handle trailing commas
|
|
6
|
+
- Add documentation links to JSON schema
|
|
7
|
+
- Update dependencies
|
|
8
|
+
|
|
9
|
+
## 0.12.0
|
|
10
|
+
|
|
11
|
+
- Remove deprecated `markdownlint-cli2-config` entry point
|
|
12
|
+
- Use `markdownlint-cli2 --config ...` instead
|
|
13
|
+
- Remove deprecated `markdownlint-cli2-fix` entry point
|
|
14
|
+
- Use `markdownlint-cli2 --fix ...` instead
|
|
15
|
+
- Add `--help` and `--no-globs` parameters
|
|
16
|
+
- Improve and document included JSON schemas
|
|
17
|
+
- Update dependencies (including `markdownlint`)
|
|
18
|
+
|
|
3
19
|
## 0.11.0
|
|
4
20
|
|
|
5
21
|
- Add `modulePaths` configuration option
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ As a [GitHub Action][github-action] via
|
|
|
67
67
|
markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)
|
|
68
68
|
https://github.com/DavidAnson/markdownlint-cli2
|
|
69
69
|
|
|
70
|
-
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix]
|
|
70
|
+
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix] [--help]
|
|
71
71
|
|
|
72
72
|
Glob expressions (from the globby library):
|
|
73
73
|
- * matches any number of characters, but not /
|
|
@@ -83,8 +83,10 @@ Dot-only glob:
|
|
|
83
83
|
- To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
|
|
84
84
|
|
|
85
85
|
Optional parameters:
|
|
86
|
-
- --config
|
|
87
|
-
- --fix
|
|
86
|
+
- --config specifies the path to a configuration file to define the base configuration
|
|
87
|
+
- --fix updates files to resolve fixable issues (can be overridden in configuration)
|
|
88
|
+
- --help writes this message to the console and exits without doing anything else
|
|
89
|
+
- --no-globs ignores the "globs" property if present in the top-level options object
|
|
88
90
|
|
|
89
91
|
Configuration via:
|
|
90
92
|
- .markdownlint-cli2.jsonc
|
|
@@ -126,17 +128,6 @@ below) to `true` (though it can still be overridden by a configuration file):
|
|
|
126
128
|
markdownlint-cli2 --fix "**/*.md" "#node_modules"
|
|
127
129
|
```
|
|
128
130
|
|
|
129
|
-
> **Deprecated**
|
|
130
|
-
>
|
|
131
|
-
> The following command behaves similarly, defaulting the `fix` property to
|
|
132
|
-
> `true`:
|
|
133
|
-
>
|
|
134
|
-
> ```bash
|
|
135
|
-
> markdownlint-cli2-fix "**/*.md" "#node_modules"
|
|
136
|
-
> ```
|
|
137
|
-
>
|
|
138
|
-
> Otherwise, `markdownlint-cli2-fix` behaves the same as `markdownlint-cli2`.
|
|
139
|
-
|
|
140
131
|
In cases where it is not convenient to store a configuration file in the root
|
|
141
132
|
of a project, the `--config` argument can be used to provide a path to any
|
|
142
133
|
supported configuration file (except `package.json`):
|
|
@@ -150,24 +141,13 @@ above. For example, `.markdownlint.json` or `example.markdownlint-cli2.jsonc`.
|
|
|
150
141
|
The specified configuration file will be loaded, parsed, and applied as a base
|
|
151
142
|
configuration for the current directory - which will then be handled normally.
|
|
152
143
|
|
|
153
|
-
> **Deprecated**
|
|
154
|
-
>
|
|
155
|
-
> The following command behaves similarly, accepting a base configuration file
|
|
156
|
-
> path as its first parameter:
|
|
157
|
-
>
|
|
158
|
-
> ```bash
|
|
159
|
-
> markdownlint-cli2-config "config/.markdownlint-cli2.jsonc" "**/*.md" "#node_modules"
|
|
160
|
-
> ```
|
|
161
|
-
>
|
|
162
|
-
> Otherwise, `markdownlint-cli2-config` behaves the same as `markdownlint-cli2`.
|
|
163
|
-
|
|
164
144
|
### Container Image
|
|
165
145
|
|
|
166
146
|
A container image [`davidanson/markdownlint-cli2`][docker-hub-markdownlint-cli2]
|
|
167
147
|
can also be used (e.g., as part of a CI pipeline):
|
|
168
148
|
|
|
169
149
|
```bash
|
|
170
|
-
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.
|
|
150
|
+
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.12.1 "**/*.md" "#node_modules"
|
|
171
151
|
```
|
|
172
152
|
|
|
173
153
|
Notes:
|
|
@@ -184,18 +164,9 @@ Notes:
|
|
|
184
164
|
- A custom working directory can be specified with Docker's `-w` flag:
|
|
185
165
|
|
|
186
166
|
```bash
|
|
187
|
-
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.
|
|
167
|
+
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.12.1 "**/*.md" "#node_modules"
|
|
188
168
|
```
|
|
189
169
|
|
|
190
|
-
> **Deprecated**
|
|
191
|
-
>
|
|
192
|
-
> To invoke the `markdownlint-cli2-config` or `markdownlint-cli2-fix` commands
|
|
193
|
-
> instead, use Docker's `--entrypoint` flag:
|
|
194
|
-
>
|
|
195
|
-
> ```bash
|
|
196
|
-
> docker run -v $PWD:/workdir --entrypoint="markdownlint-cli2-fix" davidanson/markdownlint-cli2:v0.11.0 "**/*.md" "#node_modules"
|
|
197
|
-
> ```
|
|
198
|
-
|
|
199
170
|
For convenience, the container image
|
|
200
171
|
[`davidanson/markdownlint-cli2-rules`][docker-hub-markdownlint-cli2-rules]
|
|
201
172
|
includes the latest versions of custom rules published to npm with the tag
|
|
@@ -254,9 +225,12 @@ of the rules within.
|
|
|
254
225
|
4. `.markdownlint.yml`
|
|
255
226
|
5. `.markdownlint.cjs`
|
|
256
227
|
6. `.markdownlint.mjs`
|
|
257
|
-
- The VS Code extension
|
|
258
|
-
|
|
259
|
-
|
|
228
|
+
- The VS Code extension includes a [JSON Schema][json-schema] definition for the
|
|
229
|
+
`JSON(C)` configuration files described below. This adds auto-complete and can
|
|
230
|
+
make it easier to define proper structure.
|
|
231
|
+
- See [markdownlint-cli2-config-schema.json][markdownlint-cli2-config-schema]
|
|
232
|
+
for that schema and [ValidatingConfiguration.md][validating-configuration] for
|
|
233
|
+
ways to use it to validate configuration files.
|
|
260
234
|
|
|
261
235
|
### `.markdownlint-cli2.jsonc`
|
|
262
236
|
|
|
@@ -286,6 +260,8 @@ of the rules within.
|
|
|
286
260
|
command-line arguments
|
|
287
261
|
- This setting can be used instead of (or in addition to) passing globs on
|
|
288
262
|
the command-line and offers identical performance
|
|
263
|
+
- This setting is ignored when the `--no-globs` parameter is passed on the
|
|
264
|
+
command-line
|
|
289
265
|
- This top-level setting is valid **only** in the directory from which
|
|
290
266
|
`markdownlint-cli2` is run
|
|
291
267
|
- `ignores`: `Array` of `String`s defining glob expressions to ignore when
|
|
@@ -420,7 +396,7 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
|
|
|
420
396
|
|
|
421
397
|
```yaml
|
|
422
398
|
- repo: https://github.com/DavidAnson/markdownlint-cli2
|
|
423
|
-
rev: v0.
|
|
399
|
+
rev: v0.12.1
|
|
424
400
|
hooks:
|
|
425
401
|
- id: markdownlint-cli2
|
|
426
402
|
```
|
|
@@ -447,6 +423,7 @@ See [CHANGELOG.md][changelog].
|
|
|
447
423
|
[homebrew]: https://brew.sh
|
|
448
424
|
[html-comment]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started
|
|
449
425
|
[json]: https://wikipedia.org/wiki/JSON
|
|
426
|
+
[json-schema]: https://json-schema.org
|
|
450
427
|
[jsonc]: https://code.visualstudio.com/Docs/languages/json#_json-with-comments
|
|
451
428
|
[license-image]: https://img.shields.io/npm/l/markdownlint-cli2.svg
|
|
452
429
|
[license-url]: https://opensource.org/licenses/MIT
|
|
@@ -455,26 +432,27 @@ See [CHANGELOG.md][changelog].
|
|
|
455
432
|
[markdown-it-plugins]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
|
|
456
433
|
[markdown-it-syntax-extensions]: https://github.com/markdown-it/markdown-it#syntax-extensions
|
|
457
434
|
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
|
458
|
-
[markdownlint-config]: https://github.com/DavidAnson/markdownlint/blob/
|
|
459
|
-
[markdownlint-configuration]: https://github.com/DavidAnson/markdownlint/blob/
|
|
460
|
-
[markdownlint-custom-rules]: https://github.com/DavidAnson/markdownlint/blob/
|
|
461
|
-
[markdownlint-options]: https://github.com/DavidAnson/markdownlint/blob/
|
|
462
|
-
[markdownlint-rules-aliases]: https://github.com/DavidAnson/markdownlint/blob/
|
|
463
|
-
[markdownlint-rules-tags]: https://github.com/DavidAnson/markdownlint/blob/
|
|
435
|
+
[markdownlint-config]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#optionsconfig
|
|
436
|
+
[markdownlint-configuration]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#configuration
|
|
437
|
+
[markdownlint-custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/CustomRules.md
|
|
438
|
+
[markdownlint-options]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#options
|
|
439
|
+
[markdownlint-rules-aliases]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#rules--aliases
|
|
440
|
+
[markdownlint-rules-tags]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/README.md#tags
|
|
464
441
|
[markdownlint-cli]: https://github.com/igorshubovych/markdownlint-cli
|
|
465
442
|
[markdownlint-cli2]: https://github.com/DavidAnson/markdownlint-cli2
|
|
466
443
|
[markdownlint-cli2-action]: https://github.com/marketplace/actions/markdownlint-cli2-action
|
|
467
444
|
[markdownlint-cli2-blog]: https://dlaa.me/blog/post/markdownlintcli2
|
|
468
|
-
[markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter
|
|
469
445
|
[markdownlint-cli2-cjs]: test/markdownlint-cli2-cjs/.markdownlint-cli2.cjs
|
|
446
|
+
[markdownlint-cli2-config-schema]: schema/markdownlint-cli2-config-schema.json
|
|
447
|
+
[markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter
|
|
470
448
|
[markdownlint-cli2-jsonc]: test/markdownlint-cli2-jsonc-example/.markdownlint-cli2.jsonc
|
|
471
449
|
[markdownlint-cli2-mjs]: test/markdownlint-cli2-mjs/.markdownlint-cli2.mjs
|
|
472
450
|
[markdownlint-cli2-yaml]: test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml
|
|
473
451
|
[markdownlint-cjs]: test/markdownlint-cjs/.markdownlint.cjs
|
|
474
|
-
[markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/
|
|
452
|
+
[markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/schema/.markdownlint.jsonc
|
|
475
453
|
[markdownlint-mjs]: test/markdownlint-mjs/.markdownlint.mjs
|
|
476
454
|
[markdownlint-rule]: https://www.npmjs.com/search?q=keywords:markdownlint-rule
|
|
477
|
-
[markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/
|
|
455
|
+
[markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/v0.32.1/schema/.markdownlint.yaml
|
|
478
456
|
[nodejs]: https://nodejs.org/
|
|
479
457
|
[nodejs-docker]: https://github.com/nodejs/docker-node
|
|
480
458
|
[nodejs-docker-non-root]: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
|
|
@@ -490,6 +468,7 @@ See [CHANGELOG.md][changelog].
|
|
|
490
468
|
[pre-commit-version]: https://pre-commit.com/#overriding-language-version
|
|
491
469
|
[regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
|
492
470
|
[regexp-constructor]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp
|
|
471
|
+
[validating-configuration]: schema/ValidatingConfiguration.md
|
|
493
472
|
[vscode]: https://code.visualstudio.com/
|
|
494
473
|
[vscode-markdownlint]: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
|
|
495
474
|
[yaml]: https://wikipedia.org/wiki/YAML
|
package/markdownlint-cli2.js
CHANGED
|
@@ -26,7 +26,7 @@ const resolveAndRequire = require("./resolve-and-require");
|
|
|
26
26
|
|
|
27
27
|
// Variables
|
|
28
28
|
const packageName = "markdownlint-cli2";
|
|
29
|
-
const packageVersion = "0.
|
|
29
|
+
const packageVersion = "0.12.1";
|
|
30
30
|
const libraryName = "markdownlint";
|
|
31
31
|
const libraryVersion = markdownlintLibrary.getVersion();
|
|
32
32
|
const dotOnlySubstitute = "*.{md,markdown}";
|
|
@@ -35,12 +35,18 @@ const utf8 = "utf8";
|
|
|
35
35
|
// No-op function
|
|
36
36
|
const noop = () => null;
|
|
37
37
|
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
// Synchronous function to parse JSONC text
|
|
39
|
+
const jsoncParse = (text) => {
|
|
40
|
+
const { parse, printParseErrorCode } = require("jsonc-parser");
|
|
41
|
+
const errors = [];
|
|
42
|
+
const result = parse(text, errors, { "allowTrailingComma": true });
|
|
43
|
+
if (errors.length > 0) {
|
|
44
|
+
const aggregate = errors.map(
|
|
45
|
+
(err) => `${printParseErrorCode(err.error)} (offset ${err.offset}, length ${err.length})`
|
|
46
|
+
).join(", ");
|
|
47
|
+
throw new Error(`Unable to parse JSON(C) content, ${aggregate}`);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
// Synchronous function to parse YAML text
|
|
@@ -67,12 +73,10 @@ const readConfig = (fs, dir, name, otherwise) => {
|
|
|
67
73
|
const file = pathPosix.join(dir, name);
|
|
68
74
|
return () => fs.promises.access(file).
|
|
69
75
|
then(
|
|
70
|
-
() =>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
fs
|
|
75
|
-
)
|
|
76
|
+
() => markdownlintReadConfig(
|
|
77
|
+
file,
|
|
78
|
+
[ jsoncParse, yamlParse ],
|
|
79
|
+
fs
|
|
76
80
|
),
|
|
77
81
|
otherwise
|
|
78
82
|
);
|
|
@@ -139,9 +143,8 @@ const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => {
|
|
|
139
143
|
};
|
|
140
144
|
|
|
141
145
|
// Extend a config object if it has 'extends' property
|
|
142
|
-
const getExtendedConfig =
|
|
146
|
+
const getExtendedConfig = (config, configPath, fs) => {
|
|
143
147
|
if (config.extends) {
|
|
144
|
-
const jsoncParse = await getJsoncParse();
|
|
145
148
|
return markdownlintExtendConfig(
|
|
146
149
|
config,
|
|
147
150
|
configPath,
|
|
@@ -150,7 +153,7 @@ const getExtendedConfig = async (config, configPath, fs) => {
|
|
|
150
153
|
);
|
|
151
154
|
}
|
|
152
155
|
|
|
153
|
-
return config;
|
|
156
|
+
return Promise.resolve(config);
|
|
154
157
|
};
|
|
155
158
|
|
|
156
159
|
// Read an options or config file in any format and return the object
|
|
@@ -160,7 +163,6 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => {
|
|
|
160
163
|
let options = null;
|
|
161
164
|
let config = null;
|
|
162
165
|
if (basename.endsWith(".markdownlint-cli2.jsonc")) {
|
|
163
|
-
const jsoncParse = await getJsoncParse();
|
|
164
166
|
options = jsoncParse(await fs.promises.readFile(configPath, utf8));
|
|
165
167
|
} else if (basename.endsWith(".markdownlint-cli2.yaml")) {
|
|
166
168
|
options = yamlParse(await fs.promises.readFile(configPath, utf8));
|
|
@@ -177,7 +179,6 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => {
|
|
|
177
179
|
basename.endsWith(".markdownlint.yaml") ||
|
|
178
180
|
basename.endsWith(".markdownlint.yml")
|
|
179
181
|
) {
|
|
180
|
-
const jsoncParse = await getJsoncParse();
|
|
181
182
|
config =
|
|
182
183
|
await markdownlintReadConfig(configPath, [ jsoncParse, yamlParse ], fs);
|
|
183
184
|
} else if (
|
|
@@ -243,7 +244,7 @@ const processArgv = (argv) => {
|
|
|
243
244
|
const showHelp = (logMessage) => {
|
|
244
245
|
logMessage(`https://github.com/DavidAnson/markdownlint-cli2
|
|
245
246
|
|
|
246
|
-
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix]
|
|
247
|
+
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix] [--help]
|
|
247
248
|
|
|
248
249
|
Glob expressions (from the globby library):
|
|
249
250
|
- * matches any number of characters, but not /
|
|
@@ -259,8 +260,10 @@ Dot-only glob:
|
|
|
259
260
|
- To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
|
|
260
261
|
|
|
261
262
|
Optional parameters:
|
|
262
|
-
- --config
|
|
263
|
-
- --fix
|
|
263
|
+
- --config specifies the path to a configuration file to define the base configuration
|
|
264
|
+
- --fix updates files to resolve fixable issues (can be overridden in configuration)
|
|
265
|
+
- --help writes this message to the console and exits without doing anything else
|
|
266
|
+
- --no-globs ignores the "globs" property if present in the top-level options object
|
|
264
267
|
|
|
265
268
|
Configuration via:
|
|
266
269
|
- .markdownlint-cli2.jsonc
|
|
@@ -281,6 +284,7 @@ Cross-platform compatibility:
|
|
|
281
284
|
The most compatible syntax for cross-platform support:
|
|
282
285
|
$ markdownlint-cli2 "**/*.md" "#node_modules"`
|
|
283
286
|
);
|
|
287
|
+
return 2;
|
|
284
288
|
};
|
|
285
289
|
|
|
286
290
|
// Get (creating if necessary) and process a directory's info object
|
|
@@ -316,10 +320,7 @@ const getAndProcessDirInfo = (
|
|
|
316
320
|
then(
|
|
317
321
|
() => fs.promises.
|
|
318
322
|
readFile(markdownlintCli2Jsonc, utf8).
|
|
319
|
-
then(
|
|
320
|
-
(content) => getJsoncParse().
|
|
321
|
-
then((jsoncParse) => jsoncParse(content))
|
|
322
|
-
),
|
|
323
|
+
then(jsoncParse),
|
|
323
324
|
() => fs.promises.access(markdownlintCli2Yaml).
|
|
324
325
|
then(
|
|
325
326
|
() => fs.promises.
|
|
@@ -343,11 +344,8 @@ const getAndProcessDirInfo = (
|
|
|
343
344
|
then(
|
|
344
345
|
() => fs.promises.
|
|
345
346
|
readFile(packageJson, utf8).
|
|
346
|
-
then(
|
|
347
|
-
|
|
348
|
-
then((jsoncParse) => jsoncParse(content)).
|
|
349
|
-
then((obj) => obj[packageName])
|
|
350
|
-
),
|
|
347
|
+
then(jsoncParse).
|
|
348
|
+
then((obj) => obj[packageName]),
|
|
351
349
|
noop
|
|
352
350
|
)
|
|
353
351
|
)
|
|
@@ -740,8 +738,7 @@ const createDirInfos = async (
|
|
|
740
738
|
};
|
|
741
739
|
|
|
742
740
|
// Lint files in groups by shared configuration
|
|
743
|
-
const lintFiles =
|
|
744
|
-
const jsoncParse = await getJsoncParse();
|
|
741
|
+
const lintFiles = (fs, dirInfos, fileContents) => {
|
|
745
742
|
const tasks = [];
|
|
746
743
|
// For each dirInfo
|
|
747
744
|
for (const dirInfo of dirInfos) {
|
|
@@ -893,9 +890,10 @@ const main = async (params) => {
|
|
|
893
890
|
optionsOverride,
|
|
894
891
|
fileContents,
|
|
895
892
|
nonFileContents,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
893
|
+
noRequire
|
|
894
|
+
} = params;
|
|
895
|
+
let {
|
|
896
|
+
noGlobs
|
|
899
897
|
} = params;
|
|
900
898
|
const logMessage = params.logMessage || noop;
|
|
901
899
|
const logError = params.logError || noop;
|
|
@@ -906,25 +904,36 @@ const main = async (params) => {
|
|
|
906
904
|
const baseDir = posixPath(baseDirSystem);
|
|
907
905
|
// Output banner
|
|
908
906
|
logMessage(
|
|
909
|
-
`${
|
|
907
|
+
`${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`
|
|
910
908
|
);
|
|
911
909
|
// Merge and process args/argv
|
|
912
910
|
let fixDefault = false;
|
|
913
911
|
// eslint-disable-next-line unicorn/no-useless-undefined
|
|
914
912
|
let configPath = undefined;
|
|
913
|
+
let shouldShowHelp = false;
|
|
915
914
|
const argvFiltered = (argv || []).filter((arg) => {
|
|
916
915
|
if (configPath === null) {
|
|
917
916
|
configPath = arg;
|
|
918
917
|
return false;
|
|
918
|
+
// eslint-disable-next-line unicorn/prefer-switch
|
|
919
919
|
} else if (arg === "--config") {
|
|
920
920
|
configPath = null;
|
|
921
921
|
return false;
|
|
922
922
|
} else if (arg === "--fix") {
|
|
923
923
|
fixDefault = true;
|
|
924
924
|
return false;
|
|
925
|
+
} else if (arg === "--help") {
|
|
926
|
+
shouldShowHelp = true;
|
|
927
|
+
return false;
|
|
928
|
+
} else if (arg === "--no-globs") {
|
|
929
|
+
noGlobs = true;
|
|
930
|
+
return false;
|
|
925
931
|
}
|
|
926
932
|
return true;
|
|
927
933
|
});
|
|
934
|
+
if (shouldShowHelp) {
|
|
935
|
+
return showHelp(logMessage);
|
|
936
|
+
}
|
|
928
937
|
// Read argv configuration file (if relevant and present)
|
|
929
938
|
let optionsArgv = null;
|
|
930
939
|
let relativeDir = null;
|
|
@@ -952,8 +961,7 @@ const main = async (params) => {
|
|
|
952
961
|
((globPatterns.length === 0) && !nonFileContents) ||
|
|
953
962
|
(configPath === null)
|
|
954
963
|
) {
|
|
955
|
-
showHelp(logMessage);
|
|
956
|
-
return 2;
|
|
964
|
+
return showHelp(logMessage);
|
|
957
965
|
}
|
|
958
966
|
// Include any file overrides or non-file content
|
|
959
967
|
const resolvedFileContents = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint-cli2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "David Anson",
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
"./markdownlint/helpers": "./export-markdownlint-helpers.js"
|
|
16
16
|
},
|
|
17
17
|
"bin": {
|
|
18
|
-
"markdownlint-cli2": "markdownlint-cli2.js"
|
|
19
|
-
"markdownlint-cli2-config": "markdownlint-cli2-config.js",
|
|
20
|
-
"markdownlint-cli2-fix": "markdownlint-cli2-fix.js"
|
|
18
|
+
"markdownlint-cli2": "markdownlint-cli2.js"
|
|
21
19
|
},
|
|
22
20
|
"homepage": "https://github.com/DavidAnson/markdownlint-cli2",
|
|
23
21
|
"repository": {
|
|
@@ -29,13 +27,13 @@
|
|
|
29
27
|
"scripts": {
|
|
30
28
|
"build-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2:v$VERSION -f docker/Dockerfile --label org.opencontainers.image.version=v$VERSION .",
|
|
31
29
|
"build-docker-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2-rules:v$VERSION -f docker/Dockerfile-rules --build-arg VERSION=v$VERSION --label org.opencontainers.image.version=v$VERSION .",
|
|
32
|
-
"ci": "npm-run-all --continue-on-error --parallel test-cover lint schema",
|
|
30
|
+
"ci": "npm-run-all --continue-on-error --parallel test-cover lint schema && git diff --exit-code",
|
|
33
31
|
"lint": "eslint --max-warnings 0 --no-eslintrc --config .eslintrc.json .",
|
|
34
32
|
"lint-dockerfile": "docker run --rm -i hadolint/hadolint:latest-alpine < docker/Dockerfile",
|
|
35
33
|
"lint-watch": "git ls-files | entr npm run lint",
|
|
36
34
|
"schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat",
|
|
37
35
|
"test": "ava --timeout=1m test/append-to-array-test.js test/fs-mock-test.js test/markdownlint-cli2-test.js test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js test/merge-options-test.js test/resolve-and-require-test.js",
|
|
38
|
-
"test-cover": "c8 --100 npm test
|
|
36
|
+
"test-cover": "c8 --100 npm test",
|
|
39
37
|
"test-docker-hub-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2:v$VERSION davidanson/markdownlint-cli2:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:latest \"*.md\"",
|
|
40
38
|
"test-docker-hub-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2-rules:v$VERSION davidanson/markdownlint-cli2-rules:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:latest \"*.md\"",
|
|
41
39
|
"test-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\"",
|
|
@@ -56,36 +54,35 @@
|
|
|
56
54
|
"export-markdownlint-helpers.js",
|
|
57
55
|
"LICENSE",
|
|
58
56
|
"markdownlint-cli2.js",
|
|
59
|
-
"markdownlint-cli2-config.js",
|
|
60
|
-
"markdownlint-cli2-fix.js",
|
|
61
57
|
"merge-options.js",
|
|
62
58
|
"README.md",
|
|
63
59
|
"resolve-and-require.js",
|
|
64
60
|
"schema/markdownlint-cli2-config-schema.json",
|
|
65
|
-
"schema/markdownlint-config-schema.json"
|
|
61
|
+
"schema/markdownlint-config-schema.json",
|
|
62
|
+
"schema/ValidatingConfiguration.md"
|
|
66
63
|
],
|
|
67
64
|
"dependencies": {
|
|
68
65
|
"globby": "14.0.0",
|
|
69
|
-
"
|
|
66
|
+
"jsonc-parser": "3.2.0",
|
|
67
|
+
"markdownlint": "0.33.0",
|
|
70
68
|
"markdownlint-cli2-formatter-default": "0.0.4",
|
|
71
69
|
"micromatch": "4.0.5",
|
|
72
|
-
"strip-json-comments": "5.0.1",
|
|
73
70
|
"yaml": "2.3.4"
|
|
74
71
|
},
|
|
75
72
|
"devDependencies": {
|
|
76
73
|
"@iktakahiro/markdown-it-katex": "4.0.1",
|
|
77
|
-
"
|
|
78
|
-
"
|
|
74
|
+
"ajv": "8.12.0",
|
|
75
|
+
"ava": "6.0.1",
|
|
76
|
+
"c8": "9.1.0",
|
|
79
77
|
"cpy": "11.0.0",
|
|
80
78
|
"cpy-cli": "5.0.0",
|
|
81
79
|
"del": "7.1.0",
|
|
82
|
-
"eslint": "8.
|
|
83
|
-
"eslint-plugin-n": "16.
|
|
84
|
-
"eslint-plugin-unicorn": "
|
|
80
|
+
"eslint": "8.56.0",
|
|
81
|
+
"eslint-plugin-n": "16.6.2",
|
|
82
|
+
"eslint-plugin-unicorn": "50.0.1",
|
|
85
83
|
"execa": "8.0.1",
|
|
86
|
-
"
|
|
87
|
-
"markdown-it-
|
|
88
|
-
"markdown-it-for-inline": "0.1.1",
|
|
84
|
+
"markdown-it-emoji": "3.0.0",
|
|
85
|
+
"markdown-it-for-inline": "2.0.1",
|
|
89
86
|
"markdownlint-cli2-formatter-codequality": "0.0.4",
|
|
90
87
|
"markdownlint-cli2-formatter-json": "0.0.7",
|
|
91
88
|
"markdownlint-cli2-formatter-junit": "0.0.8",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Validating Configuration
|
|
2
|
+
|
|
3
|
+
A [JSON Schema][json-schema] is provided to enable validating options objects:
|
|
4
|
+
[`markdownlint-cli2-config-schema.json`][markdownlint-cli2-config-schema]
|
|
5
|
+
|
|
6
|
+
Some editors automatically use a JSON Schema with files that reference it. For
|
|
7
|
+
example, a `.markdownlint-cli2.jsonc` file with:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/main/schema/markdownlint-cli2-config-schema.json"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
A JSON Schema validator can be used to check configuration files like so:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx ajv-cli validate -s ./markdownlint-cli2/schema/markdownlint-cli2-config-schema.json -r ./markdownlint-cli2/schema/markdownlint-config-schema.json -d "**/.markdownlint-cli2.{jsonc,yaml}" --strict=false
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
A similar process is documented for validating `markdownlint` configuration
|
|
20
|
+
objects: [Validating Configuration][validating-configuration].
|
|
21
|
+
|
|
22
|
+
[json-schema]: https://json-schema.org
|
|
23
|
+
[markdownlint-cli2-config-schema]: markdownlint-cli2-config-schema.json
|
|
24
|
+
[validating-configuration]: https://github.com/DavidAnson/markdownlint/blob/main/schema/ValidatingConfiguration.md
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.1/schema/markdownlint-cli2-config-schema.json",
|
|
3
4
|
"title": "markdownlint-cli2 configuration schema",
|
|
4
5
|
"type": "object",
|
|
5
6
|
"properties": {
|
|
6
7
|
"$schema": {
|
|
7
|
-
"description": "JSON Schema URI (
|
|
8
|
+
"description": "JSON Schema URI (expected by some editors)",
|
|
8
9
|
"type": "string",
|
|
9
|
-
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/
|
|
10
|
+
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.12.1/schema/markdownlint-cli2-config-schema.json"
|
|
10
11
|
},
|
|
11
12
|
"config": {
|
|
12
|
-
"description": "markdownlint
|
|
13
|
-
"$ref": "
|
|
13
|
+
"description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/schema/.markdownlint.jsonc",
|
|
14
|
+
"$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.33.0/schema/markdownlint-config-schema.json",
|
|
14
15
|
"default": {}
|
|
15
16
|
},
|
|
16
17
|
"customRules": {
|
|
17
|
-
"description": "Module names or paths of custom rules to load and use when linting",
|
|
18
|
+
"description": "Module names or paths of custom rules to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
18
19
|
"type": "array",
|
|
19
20
|
"default": [],
|
|
20
21
|
"items": {
|
|
@@ -24,18 +25,18 @@
|
|
|
24
25
|
}
|
|
25
26
|
},
|
|
26
27
|
"fix": {
|
|
27
|
-
"description": "Whether to enable fixing of linting errors reported by rules that emit fix information",
|
|
28
|
+
"description": "Whether to enable fixing of linting errors reported by rules that emit fix information : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
28
29
|
"type": "boolean",
|
|
29
30
|
"default": false
|
|
30
31
|
},
|
|
31
32
|
"frontMatter": {
|
|
32
|
-
"description": "Regular expression used to match and ignore any front matter at the beginning of a document",
|
|
33
|
+
"description": "Regular expression used to match and ignore any front matter at the beginning of a document : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
33
34
|
"type": "string",
|
|
34
35
|
"minLength": 1,
|
|
35
36
|
"default": ""
|
|
36
37
|
},
|
|
37
38
|
"globs": {
|
|
38
|
-
"description": "Glob expressions to include when linting (only valid at the root)",
|
|
39
|
+
"description": "Glob expressions to include when linting (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
39
40
|
"type": "array",
|
|
40
41
|
"default": [],
|
|
41
42
|
"items": {
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
48
|
"ignores": {
|
|
48
|
-
"description": "Glob expressions to ignore when linting",
|
|
49
|
+
"description": "Glob expressions to ignore when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
49
50
|
"type": "array",
|
|
50
51
|
"default": [],
|
|
51
52
|
"items": {
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
}
|
|
56
57
|
},
|
|
57
58
|
"markdownItPlugins": {
|
|
58
|
-
"description": "markdown-it plugins to load and use when linting",
|
|
59
|
+
"description": "markdown-it plugins to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
59
60
|
"type": "array",
|
|
60
61
|
"default": [],
|
|
61
62
|
"items": {
|
|
@@ -75,7 +76,7 @@
|
|
|
75
76
|
}
|
|
76
77
|
},
|
|
77
78
|
"modulePaths": {
|
|
78
|
-
"description": "Additional paths to resolve module locations from",
|
|
79
|
+
"description": "Additional paths to resolve module locations from : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
79
80
|
"type": "array",
|
|
80
81
|
"default": [],
|
|
81
82
|
"items": {
|
|
@@ -85,17 +86,17 @@
|
|
|
85
86
|
}
|
|
86
87
|
},
|
|
87
88
|
"noInlineConfig": {
|
|
88
|
-
"description": "Whether to disable support of HTML comments within Markdown content",
|
|
89
|
+
"description": "Whether to disable support of HTML comments within Markdown content : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
89
90
|
"type": "boolean",
|
|
90
91
|
"default": false
|
|
91
92
|
},
|
|
92
93
|
"noProgress": {
|
|
93
|
-
"description": "Whether to disable the display of progress on stdout (only valid at the root)",
|
|
94
|
+
"description": "Whether to disable the display of progress on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
94
95
|
"type": "boolean",
|
|
95
96
|
"default": false
|
|
96
97
|
},
|
|
97
98
|
"outputFormatters": {
|
|
98
|
-
"description": "Output formatters to load and use to customize markdownlint-cli2 output (only valid at the root)",
|
|
99
|
+
"description": "Output formatters to load and use to customize markdownlint-cli2 output (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
99
100
|
"type": "array",
|
|
100
101
|
"default": [],
|
|
101
102
|
"items": {
|
|
@@ -115,7 +116,7 @@
|
|
|
115
116
|
}
|
|
116
117
|
},
|
|
117
118
|
"showFound": {
|
|
118
|
-
"description": "Whether to show the list of found files on stdout (only valid at the root)",
|
|
119
|
+
"description": "Whether to show the list of found files on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.12.1/README.md#markdownlint-cli2jsonc",
|
|
119
120
|
"type": "boolean",
|
|
120
121
|
"default": false
|
|
121
122
|
}
|