markdownlint-cli2 0.21.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,12 @@
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
+
3
10
  ## 0.21.0
4
11
 
5
12
  - Refactor options/configuration file loading
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.21.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.21.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
@@ -397,15 +448,6 @@ supported by the `--format` command-line parameter. When `--format` is set:
397
448
  - For example: [`.markdownlint-cli2.cjs`][markdownlint-cli2-cjs] or
398
449
  [`.markdownlint-cli2.mjs`][markdownlint-cli2-mjs]
399
450
 
400
- ### `package.json`
401
-
402
- - The format of this file is a standard [npm `package.json`][package-json] file
403
- including a `markdownlint-cli2` property at the root and a value corresponding
404
- to the object described above for `.markdownlint-cli2.jsonc`.
405
- - `package.json` is only supported in the current directory.
406
- - `package.json` is not supported by the `--config` argument.
407
- - For example: [`package-json-sample`][package-json-sample]
408
-
409
451
  ### `.markdownlint.jsonc` or `.markdownlint.json`
410
452
 
411
453
  - The format of this file is a [JSONC][jsonc] or [JSON][json] object matching
@@ -453,7 +495,7 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
453
495
 
454
496
  ```yaml
455
497
  - repo: https://github.com/DavidAnson/markdownlint-cli2
456
- rev: v0.21.0
498
+ rev: v0.22.0
457
499
  hooks:
458
500
  - id: markdownlint-cli2
459
501
  ```
@@ -461,6 +503,11 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
461
503
  > Depending on the environment that workflow runs in, it may be necessary to
462
504
  > [override the version of Node.js used by pre-commit][pre-commit-version].
463
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
+
464
511
  ## History
465
512
 
466
513
  See [CHANGELOG.md][changelog].
@@ -468,7 +515,7 @@ See [CHANGELOG.md][changelog].
468
515
  [changelog]: CHANGELOG.md
469
516
  [command-line]: #command-line
470
517
  [commonmark]: https://commonmark.org/
471
- [commonjs-module]: https://nodejs.org/api/modules.html#modules_modules_commonjs_modules
518
+ [commonjs-module]: https://nodejs.org/api/modules.html#modules-commonjs-modules
472
519
  [ecmascript-module]: https://nodejs.org/api/esm.html#modules-ecmascript-modules
473
520
  [docker]: https://www.docker.com
474
521
  [docker-bind-mounts]: https://docs.docker.com/storage/bind-mounts/
@@ -480,6 +527,7 @@ See [CHANGELOG.md][changelog].
480
527
  [homebrew]: https://brew.sh
481
528
  [html-comment]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started
482
529
  [json]: https://wikipedia.org/wiki/JSON
530
+ [json-pointer]: https://datatracker.ietf.org/doc/html/rfc6901
483
531
  [json-schema]: https://json-schema.org
484
532
  [jsonc]: https://code.visualstudio.com/Docs/languages/json#_json-with-comments
485
533
  [license-image]: https://img.shields.io/npm/l/markdownlint-cli2.svg
@@ -515,16 +563,15 @@ See [CHANGELOG.md][changelog].
515
563
  [nodejs-docker-non-root]: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
516
564
  [nodejs-import-expression]: https://nodejs.org/api/esm.html#import-expressions
517
565
  [nodejs-import-meta-resolve]: https://nodejs.org/api/esm.html#importmetaresolvespecifier
518
- [nodejs-require]: https://nodejs.org/api/modules.html#modules_require_id
566
+ [nodejs-require]: https://nodejs.org/api/modules.html#requireid
519
567
  [npm-image]: https://img.shields.io/npm/v/markdownlint-cli2.svg
520
568
  [npm-url]: https://www.npmjs.com/package/markdownlint-cli2
521
569
  [output-formatters]: doc/OutputFormatters.md
522
- [package-json]: https://docs.npmjs.com/cli/v9/configuring-npm/package-json
523
- [package-json-sample]: test/package-json/package.json
524
570
  [pre-commit]: https://pre-commit.com/
525
571
  [pre-commit-version]: https://pre-commit.com/#overriding-language-version
526
572
  [regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
527
573
  [regexp-constructor]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp
574
+ [toml]: https://wikipedia.org/wiki/TOML
528
575
  [validating-configuration]: schema/ValidatingConfiguration.md
529
576
  [vscode]: https://code.visualstudio.com/
530
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
+ };
@@ -7,22 +7,22 @@ import pathDefault from "node:path";
7
7
  const pathPosix = pathDefault.posix;
8
8
  import { pathToFileURL } from "node:url";
9
9
  import { globby } from "globby";
10
+ import jsonpointer from "jsonpointer";
10
11
  import micromatch from "micromatch";
11
12
  import { applyFixes, getVersion, resolveModule } from "markdownlint";
12
13
  import { lint, extendConfig, readConfig } from "markdownlint/promise";
13
14
  import { expandTildePath } from "markdownlint/helpers";
14
15
  import appendToArray from "./append-to-array.mjs";
16
+ import { cli2SchemaKeys, libraryName, packageName, packageVersion } from "./constants.mjs";
15
17
  import mergeOptions from "./merge-options.mjs";
16
- import parsers from "./parsers/parsers.mjs";
18
+ import allParsers from "./parsers/parsers.mjs";
17
19
  import jsoncParse from "./parsers/jsonc-parse.mjs";
20
+ import tomlParse from "./parsers/toml-parse.mjs";
18
21
  import yamlParse from "./parsers/yaml-parse.mjs";
19
22
 
20
23
  /* eslint-disable jsdoc/reject-any-type */
21
24
 
22
25
  // Variables
23
- const packageName = "markdownlint-cli2";
24
- const packageVersion = "0.21.0";
25
- const libraryName = "markdownlint";
26
26
  const libraryVersion = getVersion();
27
27
  const bannerMessage = `${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`;
28
28
  const dotOnlySubstitute = "*.{md,markdown}";
@@ -34,6 +34,15 @@ const noop = () => null;
34
34
  // Negates a glob
35
35
  const negateGlob = (/** @type {string} */ glob) => `!${glob}`;
36
36
 
37
+ // Reads and parses a JSONC file
38
+ const readJsonc = (/** @type {string} */ file, /** @type {FsLike} */ fs) => fs.promises.readFile(file, utf8).then(jsoncParse);
39
+
40
+ // Reads and parses a TOML file
41
+ const readToml = (/** @type {string} */ file, /** @type {FsLike} */ fs) => fs.promises.readFile(file, utf8).then(tomlParse);
42
+
43
+ // Reads and parses a YAML file
44
+ const readYaml = (/** @type {string} */ file, /** @type {FsLike} */ fs) => fs.promises.readFile(file, utf8).then(yamlParse);
45
+
37
46
  // Throws a meaningful exception for an unusable configuration file
38
47
  const throwForConfigurationFile = (/** @type {string} */ file, /** @type {Error | any} */ error) => {
39
48
  throw new Error(
@@ -105,8 +114,9 @@ const importModuleIdsAndParams = (/** @type {string[]} */ dirs, /** @type {strin
105
114
  );
106
115
 
107
116
  // Extend a config object if it has 'extends' property
108
- const getExtendedConfig = (/** @type {Configuration} */ config, /** @type {string} */ configPath, /** @type {FsLike} */ fs) => {
117
+ const getExtendedConfig = (/** @type {ExecutionContext} */ context, /** @type {Configuration} */ config, /** @type {string} */ configPath) => {
109
118
  if (config.extends) {
119
+ const { fs, parsers } = context;
110
120
  return extendConfig(
111
121
  config,
112
122
  configPath,
@@ -119,50 +129,64 @@ const getExtendedConfig = (/** @type {Configuration} */ config, /** @type {strin
119
129
  };
120
130
 
121
131
  // Read an options or config file in any format and return the object
122
- const readOptionsOrConfig = async (/** @type {string} */ configPath, /** @type {FsLike} */ fs, /** @type {boolean} */ noImport) => {
132
+ const readOptionsOrConfig = async (/** @type {ExecutionContext} */ context, /** @type {string} */ configPath, /** @type {string | undefined} */ configPointer) => {
133
+ const { fs, noImport } = context;
123
134
  const basename = pathPosix.basename(configPath);
124
135
  const dirname = pathPosix.dirname(configPath);
125
136
  let options = null;
126
137
  let config = null;
138
+ let unknown = null;
127
139
  try {
128
140
  if (basename.endsWith(".markdownlint-cli2.jsonc")) {
129
- options = jsoncParse(await fs.promises.readFile(configPath, utf8));
141
+ options = await readJsonc(configPath, fs);
130
142
  } else if (basename.endsWith(".markdownlint-cli2.yaml")) {
131
- options = yamlParse(await fs.promises.readFile(configPath, utf8));
132
- } else if (
133
- basename.endsWith(".markdownlint-cli2.cjs") ||
134
- basename.endsWith(".markdownlint-cli2.mjs")
135
- ) {
143
+ options = await readYaml(configPath, fs);
144
+ } else if (basename.endsWith(".markdownlint-cli2.cjs") || basename.endsWith(".markdownlint-cli2.mjs")) {
136
145
  options = await importModule(dirname, basename, noImport);
137
- } else if (
138
- basename.endsWith(".markdownlint.jsonc") ||
139
- basename.endsWith(".markdownlint.json") ||
140
- basename.endsWith(".markdownlint.yaml") ||
141
- basename.endsWith(".markdownlint.yml")
142
- ) {
143
- config = await readConfig(configPath, parsers, fs);
144
- } else if (
145
- basename.endsWith(".markdownlint.cjs") ||
146
- basename.endsWith(".markdownlint.mjs")
147
- ) {
146
+ } else if (basename.endsWith(".markdownlint.jsonc") || basename.endsWith(".markdownlint.json")) {
147
+ config = await readJsonc(configPath, fs);
148
+ } else if (basename.endsWith(".markdownlint.yaml") || basename.endsWith(".markdownlint.yml")) {
149
+ config = await readYaml(configPath, fs);
150
+ } else if (basename.endsWith(".markdownlint.cjs") || basename.endsWith(".markdownlint.mjs")) {
148
151
  config = await importModule(dirname, basename, noImport);
152
+ } else if (basename.endsWith(".jsonc") || basename.endsWith(".json")) {
153
+ unknown = await readJsonc(configPath, fs);
154
+ } else if (basename.endsWith(".toml")) {
155
+ unknown = await readToml(configPath, fs);
156
+ } else if (basename.endsWith(".yaml") || basename.endsWith(".yml")) {
157
+ unknown = await readYaml(configPath, fs);
158
+ } else if (basename.endsWith(".cjs") || basename.endsWith(".mjs")) {
159
+ unknown = await importModule(dirname, basename, noImport);
149
160
  } else {
150
161
  throw new Error(
151
162
  "Configuration file should be one of the supported names " +
152
163
  "(e.g., '.markdownlint-cli2.jsonc') or a prefix with a supported name " +
153
- "(e.g., 'example.markdownlint-cli2.jsonc')."
164
+ "(e.g., 'example.markdownlint-cli2.jsonc') or have a supported extension " +
165
+ "(e.g., jsonc, json, yaml, yml, cjs, mjs)."
154
166
  );
155
167
  }
156
168
  } catch (error) {
157
169
  throwForConfigurationFile(configPath, error);
158
170
  }
171
+ if (configPointer) {
172
+ const objects = [ options, config, unknown ];
173
+ [ options, config, unknown ] = objects.map((obj) => obj && (jsonpointer.get(obj, configPointer) || {}));
174
+ }
175
+ if (unknown) {
176
+ const keys = Object.keys(unknown);
177
+ if (keys.some((key) => cli2SchemaKeys.has(key))) {
178
+ options = unknown;
179
+ } else {
180
+ config = unknown;
181
+ }
182
+ }
159
183
  if (options) {
160
184
  if (options.config) {
161
- options.config = await getExtendedConfig(options.config, configPath, fs);
185
+ options.config = await getExtendedConfig(context, options.config, configPath);
162
186
  }
163
187
  return options;
164
188
  }
165
- config = await getExtendedConfig(config, configPath, fs);
189
+ config = await getExtendedConfig(context, config, configPath);
166
190
  return { config };
167
191
  };
168
192
 
@@ -205,7 +229,7 @@ const showHelp = (/** @type {Logger} */ logMessage, /** @type {boolean} */ showB
205
229
  }
206
230
  logMessage(`https://github.com/DavidAnson/markdownlint-cli2
207
231
 
208
- Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix] [--format] [--help] [--no-globs]
232
+ Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--configPointer pointer] [--fix] [--format] [--help] [--no-globs]
209
233
 
210
234
  Glob expressions (from the globby library):
211
235
  - * matches any number of characters, but not /
@@ -222,11 +246,12 @@ Dot-only glob:
222
246
  - To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
223
247
 
224
248
  Optional parameters:
225
- - --config specifies the path to a configuration file to define the base configuration
226
- - --fix updates files to resolve fixable issues (can be overridden in configuration)
227
- - --format reads standard input (stdin), applies fixes, writes standard output (stdout)
228
- - --help writes this message to the console and exits without doing anything else
229
- - --no-globs ignores the "globs" property if present in the top-level options object
249
+ - --config specifies the path to a configuration file to define the base configuration
250
+ - --configPointer specifies a JSON Pointer to a configuration object within the --config file
251
+ - --fix updates files to resolve fixable issues (can be overridden in configuration)
252
+ - --format reads standard input (stdin), applies fixes, writes standard output (stdout)
253
+ - --help writes this message to the console and exits without doing anything else
254
+ - --no-globs ignores the "globs" property if present in the top-level options object
230
255
 
231
256
  Configuration via:
232
257
  - .markdownlint-cli2.jsonc
@@ -235,7 +260,6 @@ Configuration via:
235
260
  - .markdownlint.jsonc or .markdownlint.json
236
261
  - .markdownlint.yaml or .markdownlint.yml
237
262
  - .markdownlint.cjs or .markdownlint.mjs
238
- - package.json
239
263
 
240
264
  Cross-platform compatibility:
241
265
  - UNIX and Windows shells expand globs according to different rules; quoting arguments is recommended
@@ -252,18 +276,17 @@ $ markdownlint-cli2 "**/*.md" "#node_modules"`
252
276
  };
253
277
 
254
278
  // Helpers for getAndProcessDirInfo/handleFirstMatchingConfigurationFile
255
- const readFileParseJson = (/** @type {ConfigurationHandlerParams} */ { file, fs }) => fs.promises.readFile(file, utf8).then(jsoncParse);
256
- const readFileParseYaml = (/** @type {ConfigurationHandlerParams} */ { file, fs }) => fs.promises.readFile(file, utf8).then(yamlParse);
257
- const readConfigWrapper = (/** @type {ConfigurationHandlerParams} */ { file, fs }) => readConfig(file, parsers, fs);
279
+ const readJsoncWrapper = (/** @type {ConfigurationHandlerParams} */ { file, fs }) => readJsonc(file, fs);
280
+ const readYamlWrapper = (/** @type {ConfigurationHandlerParams} */ { file, fs }) => readYaml(file, fs);
281
+ const readConfigWrapper = (/** @type {ConfigurationHandlerParams} */ { file, fs, parsers }) => readConfig(file, parsers, fs);
258
282
  const importModuleWrapper = (/** @type {ConfigurationHandlerParams} */ { dir, file, noImport }) => importModule(dir, file, noImport);
259
283
 
260
284
  /** @type {ConfigurationFileAndHandler[] } */
261
285
  const optionsFiles = [
262
- [ ".markdownlint-cli2.jsonc", readFileParseJson ],
263
- [ ".markdownlint-cli2.yaml", readFileParseYaml ],
286
+ [ ".markdownlint-cli2.jsonc", readJsoncWrapper ],
287
+ [ ".markdownlint-cli2.yaml", readYamlWrapper ],
264
288
  [ ".markdownlint-cli2.cjs", importModuleWrapper ],
265
- [ ".markdownlint-cli2.mjs", importModuleWrapper ],
266
- [ "package.json", (params) => readFileParseJson(params).then((/** @type {any} */ obj) => (obj || {})[packageName]) ]
289
+ [ ".markdownlint-cli2.mjs", importModuleWrapper ]
267
290
  ];
268
291
 
269
292
  /** @type {ConfigurationFileAndHandler[] } */
@@ -278,15 +301,15 @@ const configurationFiles = [
278
301
 
279
302
  /**
280
303
  * Processes the first matching configuration file.
304
+ * @param {ExecutionContext} context Execution context.
281
305
  * @param {ConfigurationFileAndHandler[]} fileAndHandlers List of configuration files and handlers.
282
306
  * @param {string} dir Configuration file directory.
283
- * @param {FsLike} fs File system object.
284
- * @param {boolean} noImport No import.
285
307
  * @param {(file: string) => void} memoizeFile Function to memoize file name.
286
308
  * @returns {Promise<any>} Configuration file content.
287
309
  */
288
- const processFirstMatchingConfigurationFile = (fileAndHandlers, dir, fs, noImport, memoizeFile) =>
289
- Promise.allSettled(
310
+ const processFirstMatchingConfigurationFile = (context, fileAndHandlers, dir, memoizeFile) => {
311
+ const { fs, noImport, parsers } = context;
312
+ return Promise.allSettled(
290
313
  fileAndHandlers.map(([ name, handler ]) => {
291
314
  const file = pathPosix.join(dir, name);
292
315
  return fs.promises.access(file).then(() => [ file, handler ]);
@@ -296,18 +319,17 @@ const processFirstMatchingConfigurationFile = (fileAndHandlers, dir, fs, noImpor
296
319
  /** @type {ConfigurationFileAndHandler} */
297
320
  const [ file, handler ] = values.find((result) => (result.status === "fulfilled"))?.value || [ "[UNUSED]", noop ];
298
321
  memoizeFile(file);
299
- return handler({ dir, file, fs, noImport });
322
+ return handler({ dir, file, fs, noImport, parsers });
300
323
  });
324
+ };
301
325
 
302
326
  // Get (creating if necessary) and process a directory's info object
303
327
  const getAndProcessDirInfo = (
304
- /** @type {FsLike} */ fs,
328
+ /** @type {ExecutionContext} */ context,
305
329
  /** @type {Task[]} */ tasks,
306
330
  /** @type {DirToDirInfo} */ dirToDirInfo,
307
331
  /** @type {string} */ dir,
308
- /** @type {string | null} */ relativeDir,
309
- /** @type {boolean} */ noImport,
310
- /** @type {boolean} */ allowPackageJson
332
+ /** @type {string | null} */ relativeDir
311
333
  ) => {
312
334
  // Create dirInfo
313
335
  let dirInfo = dirToDirInfo[dir];
@@ -326,22 +348,16 @@ const getAndProcessDirInfo = (
326
348
  tasks.push(
327
349
 
328
350
  // Load markdownlint-cli2 object(s)
329
- processFirstMatchingConfigurationFile(
330
- allowPackageJson ? optionsFiles : optionsFiles.slice(0, -1),
331
- dir,
332
- fs,
333
- noImport,
334
- (file) => { cli2File = file; }
335
- ).
351
+ processFirstMatchingConfigurationFile(context, optionsFiles, dir, (file) => { cli2File = file; }).
336
352
  then((/** @type {Options | null} */ options) => {
337
353
  dirInfo.markdownlintOptions = options;
338
354
  return options &&
339
355
  options.config &&
340
356
  getExtendedConfig(
357
+ context,
341
358
  options.config,
342
359
  // Just need to identify the right directory
343
- pathPosix.join(dir, utf8),
344
- fs
360
+ pathPosix.join(dir, utf8)
345
361
  ).
346
362
  then((config) => {
347
363
  options.config = config;
@@ -352,7 +368,7 @@ const getAndProcessDirInfo = (
352
368
  }),
353
369
 
354
370
  // Load markdownlint object(s)
355
- processFirstMatchingConfigurationFile(configurationFiles, dir, fs, noImport, noop).
371
+ processFirstMatchingConfigurationFile(context, configurationFiles, dir, noop).
356
372
  then((/** @type {Configuration | null} */ config) => {
357
373
  dirInfo.markdownlintConfig = config;
358
374
  })
@@ -365,27 +381,24 @@ const getAndProcessDirInfo = (
365
381
 
366
382
  // Get base markdownlint-cli2 options object
367
383
  const getBaseOptions = async (
368
- /** @type {FsLike} */ fs,
369
- /** @type {string} */ baseDir,
384
+ /** @type {ExecutionContext} */ context,
370
385
  /** @type {string | null} */ relativeDir,
371
386
  /** @type {string[]} */ globPatterns,
372
387
  /** @type {Options} */ options,
373
388
  /** @type {boolean} */ fixDefault,
374
- /** @type {boolean} */ noGlobs,
375
- /** @type {boolean} */ noImport
389
+ /** @type {boolean} */ noGlobs
376
390
  ) => {
391
+ const { baseDir } = context;
377
392
  /** @type {Task[]} */
378
393
  const tasks = [];
379
394
  /** @type {DirToDirInfo} */
380
395
  const dirToDirInfo = {};
381
396
  getAndProcessDirInfo(
382
- fs,
397
+ context,
383
398
  tasks,
384
399
  dirToDirInfo,
385
400
  baseDir,
386
- relativeDir,
387
- noImport,
388
- true
401
+ relativeDir
389
402
  );
390
403
  await Promise.all(tasks);
391
404
  // eslint-disable-next-line no-multi-assign
@@ -418,15 +431,13 @@ const getBaseOptions = async (
418
431
 
419
432
  // Enumerate files from globs and build directory infos
420
433
  const enumerateFiles = async (
421
- /** @type {FsLike} */ fs,
422
- /** @type {string} */ baseDirSystem,
423
- /** @type {string} */ baseDir,
434
+ /** @type {ExecutionContext} */ context,
424
435
  /** @type {string[]} */ globPatterns,
425
436
  /** @type {DirToDirInfo} */ dirToDirInfo,
426
437
  /** @type {boolean} */ gitignore,
427
- /** @type {string | undefined} */ ignoreFiles,
428
- /** @type {boolean} */ noImport
438
+ /** @type {string | undefined} */ ignoreFiles
429
439
  ) => {
440
+ const { baseDir, baseDirSystem, fs } = context;
430
441
  /** @type {Task[]} */
431
442
  const tasks = [];
432
443
  /** @type {import("globby").Options} */
@@ -470,13 +481,11 @@ const enumerateFiles = async (
470
481
  for (const file of files) {
471
482
  const dir = pathPosix.dirname(file);
472
483
  const dirInfo = getAndProcessDirInfo(
473
- fs,
484
+ context,
474
485
  tasks,
475
486
  dirToDirInfo,
476
487
  dir,
477
- null,
478
- noImport,
479
- false
488
+ null
480
489
  );
481
490
  dirInfo.files.push(file);
482
491
  }
@@ -485,11 +494,10 @@ const enumerateFiles = async (
485
494
 
486
495
  // Enumerate (possibly missing) parent directories and update directory infos
487
496
  const enumerateParents = async (
488
- /** @type {FsLike} */ fs,
489
- /** @type {string} */ baseDir,
490
- /** @type {DirToDirInfo} */ dirToDirInfo,
491
- /** @type {boolean} */ noImport
497
+ /** @type {ExecutionContext} */ context,
498
+ /** @type {DirToDirInfo} */ dirToDirInfo
492
499
  ) => {
500
+ const { baseDir } = context;
493
501
  /** @type {Task[]} */
494
502
  const tasks = [];
495
503
 
@@ -514,13 +522,11 @@ const enumerateParents = async (
514
522
  lastDir = dir;
515
523
  const dirInfo =
516
524
  getAndProcessDirInfo(
517
- fs,
525
+ context,
518
526
  tasks,
519
527
  dirToDirInfo,
520
528
  dir,
521
- null,
522
- noImport,
523
- false
529
+ null
524
530
  );
525
531
  lastDirInfo.parent = dirInfo;
526
532
  lastDirInfo = dirInfo;
@@ -536,31 +542,23 @@ const enumerateParents = async (
536
542
 
537
543
  // Create directory info objects by enumerating file globs
538
544
  const createDirInfos = async (
539
- /** @type {FsLike} */ fs,
540
- /** @type {string} */ baseDirSystem,
541
- /** @type {string} */ baseDir,
545
+ /** @type {ExecutionContext} */ context,
542
546
  /** @type {string[]} */ globPatterns,
543
547
  /** @type {DirToDirInfo} */ dirToDirInfo,
544
548
  /** @type {Options | undefined} */ optionsOverride,
545
549
  /** @type {boolean} */ gitignore,
546
- /** @type {string | undefined} */ ignoreFiles,
547
- /** @type {boolean} */ noImport
550
+ /** @type {string | undefined} */ ignoreFiles
548
551
  ) => {
549
552
  await enumerateFiles(
550
- fs,
551
- baseDirSystem,
552
- baseDir,
553
+ context,
553
554
  globPatterns,
554
555
  dirToDirInfo,
555
556
  gitignore,
556
- ignoreFiles,
557
- noImport
557
+ ignoreFiles
558
558
  );
559
559
  await enumerateParents(
560
- fs,
561
- baseDir,
562
- dirToDirInfo,
563
- noImport
560
+ context,
561
+ dirToDirInfo
564
562
  );
565
563
 
566
564
  // Merge file lists with identical configuration
@@ -576,6 +574,7 @@ const createDirInfos = async (
576
574
  }
577
575
  delete dirToDirInfo[dir];
578
576
  } else {
577
+ const { noImport } = context;
579
578
  const { markdownlintOptions, relativeDir } = dirInfo;
580
579
  const effectiveDir = relativeDir || dir;
581
580
  const effectiveModulePaths = resolveModulePaths(
@@ -675,7 +674,13 @@ const createDirInfos = async (
675
674
  };
676
675
 
677
676
  // Lint files in groups by shared configuration
678
- const lintFiles = (/** @type {FsLike} */ fs, /** @type {DirInfo[]} */ dirInfos, /** @type {Record<string, string>} */ fileContents, /** @type {FormattingContext} */ formattingContext) => {
677
+ const lintFiles = (
678
+ /** @type {ExecutionContext} */ context,
679
+ /** @type {DirInfo[]} */ dirInfos,
680
+ /** @type {Record<string, string>} */ fileContents,
681
+ /** @type {FormattingContext} */ formattingContext
682
+ ) => {
683
+ const { fs, parsers } = context;
679
684
  const tasks = [];
680
685
  // For each dirInfo
681
686
  for (const dirInfo of dirInfos) {
@@ -848,7 +853,6 @@ export const main = async (/** @type {Parameters} */ params) => {
848
853
  optionsDefault,
849
854
  optionsOverride,
850
855
  fileContents,
851
- noImport,
852
856
  allowStdin
853
857
  } = params;
854
858
  let {
@@ -858,6 +862,7 @@ export const main = async (/** @type {Parameters} */ params) => {
858
862
  const logMessage = params.logMessage || noop;
859
863
  const logError = params.logError || noop;
860
864
  const fs = params.fs || fsNode;
865
+ const noImport = Boolean(params.noImport);
861
866
  const baseDirSystem =
862
867
  (directory && pathDefault.resolve(directory)) ||
863
868
  process.cwd();
@@ -869,6 +874,9 @@ export const main = async (/** @type {Parameters} */ params) => {
869
874
  /** @type {undefined | null | string} */
870
875
  // eslint-disable-next-line unicorn/no-useless-undefined
871
876
  let configPath = undefined;
877
+ /** @type {undefined | null | string} */
878
+ // eslint-disable-next-line unicorn/no-useless-undefined
879
+ let configPointer = undefined;
872
880
  let useStdin = false;
873
881
  let sawDashDash = false;
874
882
  let shouldShowHelp = false;
@@ -877,6 +885,8 @@ export const main = async (/** @type {Parameters} */ params) => {
877
885
  return true;
878
886
  } else if (configPath === null) {
879
887
  configPath = arg;
888
+ } else if (configPointer === null) {
889
+ configPointer = arg;
880
890
  } else if ((arg === "-") && allowStdin) {
881
891
  useStdin = true;
882
892
  // eslint-disable-next-line unicorn/prefer-switch
@@ -884,6 +894,8 @@ export const main = async (/** @type {Parameters} */ params) => {
884
894
  sawDashDash = true;
885
895
  } else if (arg === "--config") {
886
896
  configPath = null;
897
+ } else if (arg === "--configPointer") {
898
+ configPointer = null;
887
899
  } else if (arg === "--fix") {
888
900
  fixDefault = true;
889
901
  } else if (arg === "--format") {
@@ -901,6 +913,8 @@ export const main = async (/** @type {Parameters} */ params) => {
901
913
  if (shouldShowHelp) {
902
914
  return showHelp(logMessage, true);
903
915
  }
916
+ /** @type {ExecutionContext} */
917
+ const context = { baseDir, baseDirSystem, fs, noImport, "parsers": allParsers };
904
918
  // Read argv configuration file (if relevant and present)
905
919
  let optionsArgv = null;
906
920
  let relativeDir = null;
@@ -908,23 +922,19 @@ export const main = async (/** @type {Parameters} */ params) => {
908
922
  let baseOptions = null;
909
923
  try {
910
924
  if (configPath) {
911
- const resolvedConfigPath =
912
- posixPath(pathDefault.resolve(baseDirSystem, configPath));
913
- optionsArgv =
914
- await readOptionsOrConfig(resolvedConfigPath, fs, Boolean(noImport));
925
+ const resolvedConfigPath = posixPath(pathDefault.resolve(baseDirSystem, configPath));
926
+ optionsArgv = await readOptionsOrConfig(context, resolvedConfigPath, configPointer);
915
927
  relativeDir = pathPosix.dirname(resolvedConfigPath);
916
928
  }
917
929
  // Process arguments and get base options
918
930
  globPatterns = processArgv(argvFiltered);
919
931
  baseOptions = await getBaseOptions(
920
- fs,
921
- baseDir,
932
+ context,
922
933
  relativeDir,
923
934
  globPatterns,
924
935
  optionsArgv || optionsDefault,
925
936
  fixDefault,
926
- Boolean(noGlobs),
927
- Boolean(noImport)
937
+ Boolean(noGlobs)
928
938
  );
929
939
  } finally {
930
940
  if (!baseOptions?.baseMarkdownlintOptions.noBanner && !formattingContext.formatting) {
@@ -973,15 +983,12 @@ export const main = async (/** @type {Parameters} */ params) => {
973
983
  : undefined;
974
984
  const dirInfos =
975
985
  await createDirInfos(
976
- fs,
977
- baseDirSystem,
978
- baseDir,
986
+ context,
979
987
  globPatterns,
980
988
  dirToDirInfo,
981
989
  optionsOverride,
982
990
  gitignore,
983
- ignoreFiles,
984
- Boolean(noImport)
991
+ ignoreFiles
985
992
  );
986
993
  // Output linting status
987
994
  if (showProgress) {
@@ -998,7 +1005,7 @@ export const main = async (/** @type {Parameters} */ params) => {
998
1005
  logMessage(`Linting: ${fileCount} file(s)`);
999
1006
  }
1000
1007
  // Lint files
1001
- const lintResults = await lintFiles(fs, dirInfos, resolvedFileContents, formattingContext);
1008
+ const lintResults = await lintFiles(context, dirInfos, resolvedFileContents, formattingContext);
1002
1009
  // Output summary
1003
1010
  const results = createResults(baseDir, lintResults);
1004
1011
  if (showProgress) {
@@ -1044,6 +1051,15 @@ export const main = async (/** @type {Parameters} */ params) => {
1044
1051
 
1045
1052
  /** @typedef {Promise<any>} Task */
1046
1053
 
1054
+ /**
1055
+ * @typedef ExecutionContext
1056
+ * @property {string} baseDir Base directory (POSIX).
1057
+ * @property {string} baseDirSystem Base directory (non-POSIX).
1058
+ * @property {FsLike} fs File system object.
1059
+ * @property {boolean} noImport No import.
1060
+ * @property {ConfigurationParser[]} parsers Configuration file parsers.
1061
+ */
1062
+
1047
1063
  /**
1048
1064
  * @typedef Parameters
1049
1065
  * @property {boolean} [allowStdin] Allow stdin.
@@ -1062,11 +1078,14 @@ export const main = async (/** @type {Parameters} */ params) => {
1062
1078
 
1063
1079
  /** @typedef {import("markdownlint").Configuration} Configuration */
1064
1080
 
1081
+ /** @typedef {import("markdownlint").ConfigurationParser} ConfigurationParser */
1082
+
1065
1083
  /**
1066
1084
  * @typedef ConfigurationHandlerParams
1067
1085
  * @property {string} dir Configuration file directory.
1068
1086
  * @property {string} file Configuration file.
1069
1087
  * @property {FsLike} fs File system object.
1088
+ * @property {ConfigurationParser[]} parsers Configuration file parsers.
1070
1089
  * @property {boolean} noImport No import.
1071
1090
  */
1072
1091
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint-cli2",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
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,6 +15,7 @@
15
15
  "./markdownlint/promise": "./export-markdownlint-promise.mjs",
16
16
  "./parsers": "./parsers/parsers.mjs",
17
17
  "./parsers/jsonc": "./parsers/jsonc-parse.mjs",
18
+ "./parsers/toml": "./parsers/toml-parse.mjs",
18
19
  "./parsers/yaml": "./parsers/yaml-parse.mjs"
19
20
  },
20
21
  "bin": {
@@ -39,7 +40,7 @@
39
40
  "playwright-test": "playwright test --config ./webworker/playwright.config.mjs",
40
41
  "playwright-test-docker": "docker run --rm --volume $PWD:/home/workdir --workdir /home/workdir --ipc=host mcr.microsoft.com/playwright:v1.58.2 npm run playwright-test",
41
42
  "schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat",
42
- "test": "ava --timeout=1m test/append-to-array-test.mjs test/fs-virtual-test.mjs test/markdownlint-cli2-test.mjs test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-exports.mjs test/markdownlint-cli2-test-formatters.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs test/merge-options-test.mjs",
43
+ "test": "ava --timeout=1m test/append-to-array-test.mjs test/constants-test.mjs test/fs-virtual-test.mjs test/markdownlint-cli2-test.mjs test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-exports.mjs test/markdownlint-cli2-test-formatters.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs test/merge-options-test.mjs",
43
44
  "test-cover": "c8 --100 npm test",
44
45
  "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\"",
45
46
  "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\"",
@@ -57,6 +58,7 @@
57
58
  "files": [
58
59
  "append-to-array.mjs",
59
60
  "CHANGELOG.md",
61
+ "constants.mjs",
60
62
  "export-markdownlint.mjs",
61
63
  "export-markdownlint-helpers.mjs",
62
64
  "export-markdownlint-promise.mjs",
@@ -66,6 +68,7 @@
66
68
  "merge-options.mjs",
67
69
  "parsers/parsers.mjs",
68
70
  "parsers/jsonc-parse.mjs",
71
+ "parsers/toml-parse.mjs",
69
72
  "parsers/yaml-parse.mjs",
70
73
  "README.md",
71
74
  "schema/markdownlint-cli2-config-schema.json",
@@ -73,27 +76,28 @@
73
76
  "schema/ValidatingConfiguration.md"
74
77
  ],
75
78
  "dependencies": {
76
- "globby": "16.1.0",
79
+ "globby": "16.1.1",
77
80
  "js-yaml": "4.1.1",
78
81
  "jsonc-parser": "3.3.1",
82
+ "jsonpointer": "5.0.1",
79
83
  "markdownlint": "0.40.0",
80
84
  "markdownlint-cli2-formatter-default": "0.0.6",
81
85
  "markdown-it": "14.1.1",
82
- "micromatch": "4.0.8"
86
+ "micromatch": "4.0.8",
87
+ "smol-toml": "1.6.0"
83
88
  },
84
89
  "devDependencies": {
85
- "@eslint/js": "9.39.2",
90
+ "@eslint/js": "10.0.1",
86
91
  "@playwright/test": "1.58.2",
87
- "@stylistic/eslint-plugin": "5.8.0",
88
- "ajv": "8.17.1",
89
- "ava": "6.4.1",
90
- "c8": "10.1.3",
91
- "chalk": "5.6.2",
92
+ "@stylistic/eslint-plugin": "5.10.0",
93
+ "ajv": "8.18.0",
94
+ "ava": "7.0.0",
95
+ "c8": "11.0.0",
92
96
  "cpy": "13.2.1",
93
97
  "cpy-cli": "7.0.0",
94
- "eslint": "9.39.2",
95
- "eslint-plugin-jsdoc": "62.5.4",
96
- "eslint-plugin-n": "17.23.2",
98
+ "eslint": "10.1.0",
99
+ "eslint-plugin-jsdoc": "62.8.0",
100
+ "eslint-plugin-n": "17.24.0",
97
101
  "eslint-plugin-unicorn": "63.0.0",
98
102
  "execa": "9.6.1",
99
103
  "markdown-it-emoji": "3.0.0",
@@ -101,7 +105,7 @@
101
105
  "markdownlint-cli2-formatter-codequality": "0.0.7",
102
106
  "markdownlint-cli2-formatter-json": "0.0.9",
103
107
  "markdownlint-cli2-formatter-junit": "0.0.14",
104
- "markdownlint-cli2-formatter-pretty": "0.0.9",
108
+ "markdownlint-cli2-formatter-pretty": "0.0.10",
105
109
  "markdownlint-cli2-formatter-sarif": "0.0.4",
106
110
  "markdownlint-cli2-formatter-summarize": "0.0.8",
107
111
  "markdownlint-cli2-formatter-template": "0.0.4",
@@ -1,6 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  import jsoncParse from "./jsonc-parse.mjs";
4
+ import tomlParse from "./toml-parse.mjs";
4
5
  import yamlParse from "./yaml-parse.mjs";
5
6
 
6
7
  /**
@@ -9,6 +10,7 @@ import yamlParse from "./yaml-parse.mjs";
9
10
  */
10
11
  const parsers = [
11
12
  jsoncParse,
13
+ tomlParse,
12
14
  yamlParse
13
15
  ];
14
16
 
@@ -0,0 +1,11 @@
1
+ // @ts-check
2
+
3
+ import { parse } from "smol-toml";
4
+
5
+ /**
6
+ * Parses a TOML string, returning the corresponding object.
7
+ * @type {import("markdownlint").ConfigurationParser}
8
+ */
9
+ const tomlParse = (text) => parse(text);
10
+
11
+ export default tomlParse;
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.21.0/schema/markdownlint-cli2-config-schema.json",
3
+ "$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.22.0/schema/markdownlint-cli2-config-schema.json",
4
4
  "title": "markdownlint-cli2 configuration schema",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "$schema": {
8
8
  "description": "JSON Schema URI (expected by some editors)",
9
9
  "type": "string",
10
- "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.21.0/schema/markdownlint-cli2-config-schema.json"
10
+ "default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.22.0/schema/markdownlint-cli2-config-schema.json"
11
11
  },
12
12
  "config": {
13
13
  "description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.40.0/schema/.markdownlint.jsonc",
@@ -15,7 +15,7 @@
15
15
  "default": {}
16
16
  },
17
17
  "customRules": {
18
- "description": "Module names or paths of custom rules to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
18
+ "description": "Module names or paths of custom rules to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
19
19
  "type": "array",
20
20
  "default": [],
21
21
  "items": {
@@ -25,18 +25,18 @@
25
25
  }
26
26
  },
27
27
  "fix": {
28
- "description": "Whether to enable fixing of linting errors reported by rules that emit fix information : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
28
+ "description": "Whether to enable fixing of linting errors reported by rules that emit fix information : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
29
29
  "type": "boolean",
30
30
  "default": false
31
31
  },
32
32
  "frontMatter": {
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.21.0/README.md#markdownlint-cli2jsonc",
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.22.0/README.md#markdownlint-cli2jsonc",
34
34
  "type": "string",
35
35
  "minLength": 1,
36
36
  "default": ""
37
37
  },
38
38
  "gitignore": {
39
- "description": "Whether to ignore files referenced by .gitignore (or glob expression) (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
39
+ "description": "Whether to ignore files referenced by .gitignore (or glob expression) (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
40
40
  "type": [
41
41
  "boolean",
42
42
  "string"
@@ -44,7 +44,7 @@
44
44
  "default": false
45
45
  },
46
46
  "globs": {
47
- "description": "Glob expressions to include when linting (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
47
+ "description": "Glob expressions to include when linting (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
48
48
  "type": "array",
49
49
  "default": [],
50
50
  "items": {
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "ignores": {
57
- "description": "Glob expressions to ignore when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
57
+ "description": "Glob expressions to ignore when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
58
58
  "type": "array",
59
59
  "default": [],
60
60
  "items": {
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  "markdownItPlugins": {
67
- "description": "markdown-it plugins to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
67
+ "description": "markdown-it plugins to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
68
68
  "type": "array",
69
69
  "default": [],
70
70
  "items": {
@@ -84,7 +84,7 @@
84
84
  }
85
85
  },
86
86
  "modulePaths": {
87
- "description": "Additional paths to resolve module locations from : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
87
+ "description": "Additional paths to resolve module locations from : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
88
88
  "type": "array",
89
89
  "default": [],
90
90
  "items": {
@@ -94,22 +94,22 @@
94
94
  }
95
95
  },
96
96
  "noBanner": {
97
- "description": "Whether to disable the display of the banner message and version numbers on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
97
+ "description": "Whether to disable the display of the banner message and version numbers on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
98
98
  "type": "boolean",
99
99
  "default": false
100
100
  },
101
101
  "noInlineConfig": {
102
- "description": "Whether to disable support of HTML comments within Markdown content : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
102
+ "description": "Whether to disable support of HTML comments within Markdown content : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
103
103
  "type": "boolean",
104
104
  "default": false
105
105
  },
106
106
  "noProgress": {
107
- "description": "Whether to disable the display of progress on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
107
+ "description": "Whether to disable the display of progress on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
108
108
  "type": "boolean",
109
109
  "default": false
110
110
  },
111
111
  "outputFormatters": {
112
- "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.21.0/README.md#markdownlint-cli2jsonc",
112
+ "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.22.0/README.md#markdownlint-cli2jsonc",
113
113
  "type": "array",
114
114
  "default": [],
115
115
  "items": {
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "showFound": {
132
- "description": "Whether to show the list of found files on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.0/README.md#markdownlint-cli2jsonc",
132
+ "description": "Whether to show the list of found files on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.0/README.md#markdownlint-cli2jsonc",
133
133
  "type": "boolean",
134
134
  "default": false
135
135
  }