markdownlint-cli2 0.20.0 → 0.22.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.22.0
4
+
5
+ - Make `--config` parameter more flexible
6
+ - Support TOML with `--config` parameter
7
+ - Add `--configPointer` parameter
8
+ - Update dependencies
9
+
10
+ ## 0.21.0
11
+
12
+ - Refactor options/configuration file loading
13
+ - Update dependencies
14
+
3
15
  ## 0.20.0
4
16
 
5
17
  - Update dependencies
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] [--format] [--help] [--no-globs]
70
+ Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--configPointer pointer] [--fix] [--format] [--help] [--no-globs]
71
71
 
72
72
  Glob expressions (from the globby library):
73
73
  - * matches any number of characters, but not /
@@ -84,11 +84,12 @@ Dot-only glob:
84
84
  - To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
85
85
 
86
86
  Optional parameters:
87
- - --config specifies the path to a configuration file to define the base configuration
88
- - --fix updates files to resolve fixable issues (can be overridden in configuration)
89
- - --format reads standard input (stdin), applies fixes, writes standard output (stdout)
90
- - --help writes this message to the console and exits without doing anything else
91
- - --no-globs ignores the "globs" property if present in the top-level options object
87
+ - --config specifies the path to a configuration file to define the base configuration
88
+ - --configPointer specifies a JSON Pointer to a configuration object within the --config file
89
+ - --fix updates files to resolve fixable issues (can be overridden in configuration)
90
+ - --format reads standard input (stdin), applies fixes, writes standard output (stdout)
91
+ - --help writes this message to the console and exits without doing anything else
92
+ - --no-globs ignores the "globs" property if present in the top-level options object
92
93
 
93
94
  Configuration via:
94
95
  - .markdownlint-cli2.jsonc
@@ -97,7 +98,6 @@ Configuration via:
97
98
  - .markdownlint.jsonc or .markdownlint.json
98
99
  - .markdownlint.yaml or .markdownlint.yml
99
100
  - .markdownlint.cjs or .markdownlint.mjs
100
- - package.json
101
101
 
102
102
  Cross-platform compatibility:
103
103
  - UNIX and Windows shells expand globs according to different rules; quoting arguments is recommended
@@ -133,24 +133,74 @@ markdownlint-cli2 --fix "**/*.md" "#node_modules"
133
133
 
134
134
  In cases where it is not convenient to store a configuration file in the root
135
135
  of a project, the `--config` argument can be used to provide a path to any
136
- supported configuration file (except `package.json`):
136
+ supported configuration file/format:
137
137
 
138
138
  ```bash
139
139
  markdownlint-cli2 --config "config/.markdownlint-cli2.jsonc" "**/*.md" "#node_modules"
140
140
  ```
141
141
 
142
- The configuration file name must be (or end with) one of the supported names
142
+ The configuration file name should be (or end with) one of the supported names
143
143
  above. For example, `.markdownlint.json` or `example.markdownlint-cli2.jsonc`.
144
- The specified configuration file will be loaded, parsed, and applied as a base
144
+ Alternatively, the configuration file name should have a supported extension
145
+ like `.jsonc`, `.yaml`, `.mjs`, or `.toml` and its kind (see below) will be
146
+ inferred. The configuration file will be loaded, parsed, and applied as a base
145
147
  configuration for the current directory - which will then be handled normally.
146
148
 
149
+ The `--configPointer` argument allows the use of [JSON Pointer][json-pointer]
150
+ syntax to identify a sub-object within the configuration file specified by
151
+ `--config` (see above). This argument can be used with any configuration file
152
+ type and makes it possible to nest configuration data within another file like
153
+ `package.json` or `pyproject.toml` (e.g., via `/key` or `/key/subkey`).
154
+
155
+ For example, a `package.json` file like this:
156
+
157
+ ```json
158
+ {
159
+ "...": "...",
160
+ "markdownlint-cli2": {
161
+ "config": {
162
+ "no-multiple-blanks": false
163
+ },
164
+ "noProgress": true
165
+ }
166
+ }
167
+ ```
168
+
169
+ Could be used like this:
170
+
171
+ ```bash
172
+ markdownlint-cli2 --config package.json --configPointer /markdownlint-cli2 "*.md"
173
+ ```
174
+
175
+ And a `pyproject.toml` file like this:
176
+
177
+ ```toml
178
+ [project]
179
+ # ...
180
+
181
+ [tool.markdownlint-cli2]
182
+ noProgress = true
183
+
184
+ [tool.markdownlint-cli2.config]
185
+ no-multiple-blanks = false
186
+ ```
187
+
188
+ Could be used like this:
189
+
190
+ ```bash
191
+ markdownlint-cli2 --config pyproject.toml --configPointer /tool/markdownlint-cli2 "*.md"
192
+ ```
193
+
194
+ **Note**: The [TOML][toml] format is supported by `--config`, `--configPointer`,
195
+ and the `extends` configuration property, but *not* for per-directory overrides.
196
+
147
197
  ### Container Image
148
198
 
149
199
  A container image [`davidanson/markdownlint-cli2`][docker-hub-markdownlint-cli2]
150
200
  can also be used (e.g., as part of a CI pipeline):
151
201
 
152
202
  ```bash
153
- docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.20.0 "**/*.md" "#node_modules"
203
+ docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.22.0 "**/*.md" "#node_modules"
154
204
  ```
155
205
 
156
206
  Notes:
@@ -167,7 +217,7 @@ Notes:
167
217
  - A custom working directory can be specified with Docker's `-w` flag:
168
218
 
169
219
  ```bash
170
- docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.20.0 "**/*.md" "#node_modules"
220
+ docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.22.0 "**/*.md" "#node_modules"
171
221
  ```
172
222
 
173
223
  For convenience, the container image
@@ -256,7 +306,6 @@ supported by the `--format` command-line parameter. When `--format` is set:
256
306
  2. `.markdownlint-cli2.yaml`
257
307
  3. `.markdownlint-cli2.cjs`
258
308
  4. `.markdownlint-cli2.mjs`
259
- 5. `package.json` (only supported in the current directory)
260
309
  - Configuration files like `.markdownlint.*` allow control over only the
261
310
  `markdownlint` `config` object and tend to be supported more broadly (such
262
311
  as by `markdownlint-cli`).
@@ -268,6 +317,8 @@ supported by the `--format` command-line parameter. When `--format` is set:
268
317
  4. `.markdownlint.yml`
269
318
  5. `.markdownlint.cjs`
270
319
  6. `.markdownlint.mjs`
320
+ - Both configuration file types can appear in any directory and will override
321
+ configuration defined in the project root or any directories in between.
271
322
  - The VS Code extension includes a [JSON Schema][json-schema] definition for the
272
323
  `JSON(C)` configuration files described below. This adds auto-complete and can
273
324
  make it easier to define proper structure.
@@ -282,10 +333,10 @@ supported by the `--format` command-line parameter. When `--format` is set:
282
333
  - Valid properties are:
283
334
  - `config`: [`markdownlint` `config` object][markdownlint-config] to configure
284
335
  rules for this part of the directory tree
285
- - If a `.markdownlint.{jsonc,json,yaml,yml,js}` file (see below) is present
286
- in the same directory, it overrides the value of this property
336
+ - If a `.markdownlint.{jsonc,json,yaml,yml,cjs,mjs}` file (see below) is
337
+ present in the same directory, it overrides the value of this property
287
338
  - If the `config` object contains an `extends` property, it will be resolved
288
- the same as `.markdownlint.{jsonc,json,yaml,yml,js}` (see below)
339
+ the same as `.markdownlint.{jsonc,json,yaml,yml,cjs,mjs}` (see below)
289
340
  - `customRules`: `Array` of `String`s (or `Array`s of `String`s) of module
290
341
  names/paths of [custom rules][markdownlint-custom-rules] to load and use
291
342
  when linting
@@ -301,12 +352,13 @@ supported by the `--format` command-line parameter. When `--format` is set:
301
352
  - For example: `(^---\s*$[^]*?^---\s*$)(\r\n|\r|\n|$)`
302
353
  - `gitignore`: `Boolean` or `String` value to automatically ignore files
303
354
  referenced by `.gitignore` (or similar) when linting
304
- - When the value `true` is specified, all `.gitignore` files in the tree are
305
- imported (default `git` behavior)
355
+ - When the value `true` is specified, all `.gitignore` files in the tree
356
+ *and up to the repository root* are used (default `git` behavior)
306
357
  - When a `String` value is specified, that glob pattern is used to identify
307
- the set of ignore files to import
308
- - The value `**/.gitignore` corresponds to the `Boolean` value `true`
309
- - The value `.gitignore` imports only the file in the root of the tree;
358
+ the set of ignore files to use
359
+ - The value `**/.gitignore` corresponds to the `Boolean` value `true` *but
360
+ does not use `.gitignore` files up to the repository root*
361
+ - The value `.gitignore` uses only the file in the root of the tree;
310
362
  this is usually equivalent and can be much faster for large trees
311
363
  - This top-level setting is valid **only** in the directory from which
312
364
  `markdownlint-cli2` is run
@@ -396,15 +448,6 @@ supported by the `--format` command-line parameter. When `--format` is set:
396
448
  - For example: [`.markdownlint-cli2.cjs`][markdownlint-cli2-cjs] or
397
449
  [`.markdownlint-cli2.mjs`][markdownlint-cli2-mjs]
398
450
 
399
- ### `package.json`
400
-
401
- - The format of this file is a standard [npm `package.json`][package-json] file
402
- including a `markdownlint-cli2` property at the root and a value corresponding
403
- to the object described above for `.markdownlint-cli2.jsonc`.
404
- - `package.json` is only supported in the current directory.
405
- - `package.json` is not supported by the `--config` argument.
406
- - For example: [`package-json-sample`][package-json-sample]
407
-
408
451
  ### `.markdownlint.jsonc` or `.markdownlint.json`
409
452
 
410
453
  - The format of this file is a [JSONC][jsonc] or [JSON][json] object matching
@@ -452,7 +495,7 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
452
495
 
453
496
  ```yaml
454
497
  - repo: https://github.com/DavidAnson/markdownlint-cli2
455
- rev: v0.20.0
498
+ rev: v0.22.0
456
499
  hooks:
457
500
  - id: markdownlint-cli2
458
501
  ```
@@ -460,6 +503,11 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
460
503
  > Depending on the environment that workflow runs in, it may be necessary to
461
504
  > [override the version of Node.js used by pre-commit][pre-commit-version].
462
505
 
506
+ Setting the `id` above to `markdownlint-cli2-docker` uses the Docker container
507
+ image instead. That image bundles Node.js and all dependencies and provides the
508
+ most consistent experience because it is not affected by new releases of any
509
+ dependencies.
510
+
463
511
  ## History
464
512
 
465
513
  See [CHANGELOG.md][changelog].
@@ -467,7 +515,7 @@ See [CHANGELOG.md][changelog].
467
515
  [changelog]: CHANGELOG.md
468
516
  [command-line]: #command-line
469
517
  [commonmark]: https://commonmark.org/
470
- [commonjs-module]: https://nodejs.org/api/modules.html#modules_modules_commonjs_modules
518
+ [commonjs-module]: https://nodejs.org/api/modules.html#modules-commonjs-modules
471
519
  [ecmascript-module]: https://nodejs.org/api/esm.html#modules-ecmascript-modules
472
520
  [docker]: https://www.docker.com
473
521
  [docker-bind-mounts]: https://docs.docker.com/storage/bind-mounts/
@@ -479,6 +527,7 @@ See [CHANGELOG.md][changelog].
479
527
  [homebrew]: https://brew.sh
480
528
  [html-comment]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started
481
529
  [json]: https://wikipedia.org/wiki/JSON
530
+ [json-pointer]: https://datatracker.ietf.org/doc/html/rfc6901
482
531
  [json-schema]: https://json-schema.org
483
532
  [jsonc]: https://code.visualstudio.com/Docs/languages/json#_json-with-comments
484
533
  [license-image]: https://img.shields.io/npm/l/markdownlint-cli2.svg
@@ -514,16 +563,15 @@ See [CHANGELOG.md][changelog].
514
563
  [nodejs-docker-non-root]: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
515
564
  [nodejs-import-expression]: https://nodejs.org/api/esm.html#import-expressions
516
565
  [nodejs-import-meta-resolve]: https://nodejs.org/api/esm.html#importmetaresolvespecifier
517
- [nodejs-require]: https://nodejs.org/api/modules.html#modules_require_id
566
+ [nodejs-require]: https://nodejs.org/api/modules.html#requireid
518
567
  [npm-image]: https://img.shields.io/npm/v/markdownlint-cli2.svg
519
568
  [npm-url]: https://www.npmjs.com/package/markdownlint-cli2
520
569
  [output-formatters]: doc/OutputFormatters.md
521
- [package-json]: https://docs.npmjs.com/cli/v9/configuring-npm/package-json
522
- [package-json-sample]: test/package-json/package.json
523
570
  [pre-commit]: https://pre-commit.com/
524
571
  [pre-commit-version]: https://pre-commit.com/#overriding-language-version
525
572
  [regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
526
573
  [regexp-constructor]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp
574
+ [toml]: https://wikipedia.org/wiki/TOML
527
575
  [validating-configuration]: schema/ValidatingConfiguration.md
528
576
  [vscode]: https://code.visualstudio.com/
529
577
  [vscode-markdownlint]: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
package/constants.mjs ADDED
@@ -0,0 +1,30 @@
1
+ // @ts-check
2
+
3
+ const packageName = "markdownlint-cli2";
4
+ const packageVersion = "0.22.0";
5
+
6
+ const libraryName = "markdownlint";
7
+
8
+ const cli2SchemaKeys = new Set([
9
+ "config",
10
+ "customRules",
11
+ "fix",
12
+ "frontMatter",
13
+ "gitignore",
14
+ "globs",
15
+ "ignores",
16
+ "markdownItPlugins",
17
+ "modulePaths",
18
+ "noBanner",
19
+ "noInlineConfig",
20
+ "noProgress",
21
+ "outputFormatters",
22
+ "showFound"
23
+ ]);
24
+
25
+ export {
26
+ cli2SchemaKeys,
27
+ libraryName,
28
+ packageName,
29
+ packageVersion
30
+ };