markdownlint-cli2 0.19.1 → 0.21.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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.21.0
4
+
5
+ - Refactor options/configuration file loading
6
+ - Update dependencies
7
+
8
+ ## 0.20.0
9
+
10
+ - Update dependencies
11
+
3
12
  ## 0.19.1
4
13
 
5
14
  - Update `--format` to avoid trailing newline
package/README.md CHANGED
@@ -150,7 +150,7 @@ A container image [`davidanson/markdownlint-cli2`][docker-hub-markdownlint-cli2]
150
150
  can also be used (e.g., as part of a CI pipeline):
151
151
 
152
152
  ```bash
153
- docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.19.1 "**/*.md" "#node_modules"
153
+ docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.21.0 "**/*.md" "#node_modules"
154
154
  ```
155
155
 
156
156
  Notes:
@@ -167,7 +167,7 @@ Notes:
167
167
  - A custom working directory can be specified with Docker's `-w` flag:
168
168
 
169
169
  ```bash
170
- docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.19.1 "**/*.md" "#node_modules"
170
+ docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.21.0 "**/*.md" "#node_modules"
171
171
  ```
172
172
 
173
173
  For convenience, the container image
@@ -301,12 +301,13 @@ supported by the `--format` command-line parameter. When `--format` is set:
301
301
  - For example: `(^---\s*$[^]*?^---\s*$)(\r\n|\r|\n|$)`
302
302
  - `gitignore`: `Boolean` or `String` value to automatically ignore files
303
303
  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)
304
+ - When the value `true` is specified, all `.gitignore` files in the tree
305
+ *and up to the repository root* are used (default `git` behavior)
306
306
  - 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;
307
+ the set of ignore files to use
308
+ - The value `**/.gitignore` corresponds to the `Boolean` value `true` *but
309
+ does not use `.gitignore` files up to the repository root*
310
+ - The value `.gitignore` uses only the file in the root of the tree;
310
311
  this is usually equivalent and can be much faster for large trees
311
312
  - This top-level setting is valid **only** in the directory from which
312
313
  `markdownlint-cli2` is run
@@ -452,7 +453,7 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
452
453
 
453
454
  ```yaml
454
455
  - repo: https://github.com/DavidAnson/markdownlint-cli2
455
- rev: v0.19.1
456
+ rev: v0.21.0
456
457
  hooks:
457
458
  - id: markdownlint-cli2
458
459
  ```
@@ -488,12 +489,12 @@ See [CHANGELOG.md][changelog].
488
489
  [markdown-it-plugins]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
489
490
  [markdown-it-syntax-extensions]: https://github.com/markdown-it/markdown-it#syntax-extensions
490
491
  [markdownlint]: https://github.com/DavidAnson/markdownlint
491
- [markdownlint-config]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/README.md#optionsconfig
492
- [markdownlint-configuration]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/README.md#configuration
493
- [markdownlint-custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/doc/CustomRules.md
494
- [markdownlint-options]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/README.md#options
495
- [markdownlint-rules-aliases]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/README.md#rules--aliases
496
- [markdownlint-rules-tags]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/README.md#tags
492
+ [markdownlint-config]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#optionsconfig
493
+ [markdownlint-configuration]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#configuration
494
+ [markdownlint-custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/CustomRules.md
495
+ [markdownlint-options]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#options
496
+ [markdownlint-rules-aliases]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#rules--aliases
497
+ [markdownlint-rules-tags]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#tags
497
498
  [markdownlint-cli]: https://github.com/igorshubovych/markdownlint-cli
498
499
  [markdownlint-cli2]: https://github.com/DavidAnson/markdownlint-cli2
499
500
  [markdownlint-cli2-action]: https://github.com/marketplace/actions/markdownlint-cli2-action
@@ -505,10 +506,10 @@ See [CHANGELOG.md][changelog].
505
506
  [markdownlint-cli2-mjs]: test/markdownlint-cli2-mjs/.markdownlint-cli2.mjs
506
507
  [markdownlint-cli2-yaml]: test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml
507
508
  [markdownlint-cjs]: test/markdownlint-cjs/.markdownlint.cjs
508
- [markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/schema/.markdownlint.jsonc
509
+ [markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/schema/.markdownlint.jsonc
509
510
  [markdownlint-mjs]: test/markdownlint-mjs/.markdownlint.mjs
510
511
  [markdownlint-rule]: https://www.npmjs.com/search?q=keywords:markdownlint-rule
511
- [markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/v0.39.0/schema/.markdownlint.yaml
512
+ [markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/schema/.markdownlint.yaml
512
513
  [nodejs]: https://nodejs.org/
513
514
  [nodejs-docker]: https://github.com/nodejs/docker-node
514
515
  [nodejs-docker-non-root]: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
@@ -21,7 +21,7 @@ import yamlParse from "./parsers/yaml-parse.mjs";
21
21
 
22
22
  // Variables
23
23
  const packageName = "markdownlint-cli2";
24
- const packageVersion = "0.19.1";
24
+ const packageVersion = "0.21.0";
25
25
  const libraryName = "markdownlint";
26
26
  const libraryVersion = getVersion();
27
27
  const bannerMessage = `${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`;
@@ -50,20 +50,6 @@ const resolveModulePaths = (/** @type {string} */ dir, /** @type {string[]} */ m
50
50
  modulePaths.map((path) => pathDefault.resolve(dir, expandTildePath(path, os)))
51
51
  );
52
52
 
53
- // Read a JSON(C) or YAML file and return the object
54
- const readConfigFile = (/** @type {FsLike} */ fs, /** @type {string} */ dir, /** @type {string} */ name, /** @type {() => void} */ otherwise) => () => {
55
- const file = pathPosix.join(dir, name);
56
- return fs.promises.access(file).
57
- then(
58
- () => readConfig(
59
- file,
60
- parsers,
61
- fs
62
- ),
63
- otherwise
64
- );
65
- };
66
-
67
53
  // Import a module ID with a custom directory in the path
68
54
  const importModule = async (/** @type {string[] | string} */ dirOrDirs, /** @type {string} */ id, /** @type {boolean} */ noImport) => {
69
55
  if (typeof id !== "string") {
@@ -118,18 +104,8 @@ const importModuleIdsAndParams = (/** @type {string[]} */ dirs, /** @type {strin
118
104
  ).then((results) => results.filter(Boolean))
119
105
  );
120
106
 
121
- // Import a JavaScript file and return the exported object
122
- const importConfig = (/** @type {FsLike} */ fs, /** @type {string} */ dir, /** @type {string} */ name, /** @type {boolean} */ noImport, /** @type {() => void} */ otherwise) => () => {
123
- const file = pathPosix.join(dir, name);
124
- return fs.promises.access(file).
125
- then(
126
- () => importModule(dir, name, noImport),
127
- otherwise
128
- );
129
- };
130
-
131
107
  // Extend a config object if it has 'extends' property
132
- const getExtendedConfig = (/** @type {import("markdownlint").Configuration} */ config, /** @type {string} */ configPath, /** @type {FsLike} */ fs) => {
108
+ const getExtendedConfig = (/** @type {Configuration} */ config, /** @type {string} */ configPath, /** @type {FsLike} */ fs) => {
133
109
  if (config.extends) {
134
110
  return extendConfig(
135
111
  config,
@@ -275,6 +251,54 @@ $ markdownlint-cli2 "**/*.md" "#node_modules"`
275
251
  return 2;
276
252
  };
277
253
 
254
+ // 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);
258
+ const importModuleWrapper = (/** @type {ConfigurationHandlerParams} */ { dir, file, noImport }) => importModule(dir, file, noImport);
259
+
260
+ /** @type {ConfigurationFileAndHandler[] } */
261
+ const optionsFiles = [
262
+ [ ".markdownlint-cli2.jsonc", readFileParseJson ],
263
+ [ ".markdownlint-cli2.yaml", readFileParseYaml ],
264
+ [ ".markdownlint-cli2.cjs", importModuleWrapper ],
265
+ [ ".markdownlint-cli2.mjs", importModuleWrapper ],
266
+ [ "package.json", (params) => readFileParseJson(params).then((/** @type {any} */ obj) => (obj || {})[packageName]) ]
267
+ ];
268
+
269
+ /** @type {ConfigurationFileAndHandler[] } */
270
+ const configurationFiles = [
271
+ [ ".markdownlint.jsonc", readConfigWrapper ],
272
+ [ ".markdownlint.json", readConfigWrapper ],
273
+ [ ".markdownlint.yaml", readConfigWrapper ],
274
+ [ ".markdownlint.yml", readConfigWrapper ],
275
+ [ ".markdownlint.cjs", importModuleWrapper ],
276
+ [ ".markdownlint.mjs", importModuleWrapper ]
277
+ ];
278
+
279
+ /**
280
+ * Processes the first matching configuration file.
281
+ * @param {ConfigurationFileAndHandler[]} fileAndHandlers List of configuration files and handlers.
282
+ * @param {string} dir Configuration file directory.
283
+ * @param {FsLike} fs File system object.
284
+ * @param {boolean} noImport No import.
285
+ * @param {(file: string) => void} memoizeFile Function to memoize file name.
286
+ * @returns {Promise<any>} Configuration file content.
287
+ */
288
+ const processFirstMatchingConfigurationFile = (fileAndHandlers, dir, fs, noImport, memoizeFile) =>
289
+ Promise.allSettled(
290
+ fileAndHandlers.map(([ name, handler ]) => {
291
+ const file = pathPosix.join(dir, name);
292
+ return fs.promises.access(file).then(() => [ file, handler ]);
293
+ })
294
+ ).
295
+ then((values) => {
296
+ /** @type {ConfigurationFileAndHandler} */
297
+ const [ file, handler ] = values.find((result) => (result.status === "fulfilled"))?.value || [ "[UNUSED]", noop ];
298
+ memoizeFile(file);
299
+ return handler({ dir, file, fs, noImport });
300
+ });
301
+
278
302
  // Get (creating if necessary) and process a directory's info object
279
303
  const getAndProcessDirInfo = (
280
304
  /** @type {FsLike} */ fs,
@@ -293,57 +317,30 @@ const getAndProcessDirInfo = (
293
317
  relativeDir,
294
318
  "parent": null,
295
319
  "files": [],
296
- "markdownlintConfig": {},
297
- "markdownlintOptions": {}
320
+ "markdownlintConfig": null,
321
+ "markdownlintOptions": null
298
322
  };
299
323
  dirToDirInfo[dir] = dirInfo;
300
324
 
301
- // Load markdownlint-cli2 object(s)
302
- const markdownlintCli2Jsonc = pathPosix.join(dir, ".markdownlint-cli2.jsonc");
303
- const markdownlintCli2Yaml = pathPosix.join(dir, ".markdownlint-cli2.yaml");
304
- const markdownlintCli2Cjs = pathPosix.join(dir, ".markdownlint-cli2.cjs");
305
- const markdownlintCli2Mjs = pathPosix.join(dir, ".markdownlint-cli2.mjs");
306
- const packageJson = pathPosix.join(dir, "package.json");
307
- let file = "[UNKNOWN]";
308
- // eslint-disable-next-line no-return-assign
309
- const captureFile = (/** @type {string} */ f) => file = f;
325
+ let cli2File = "[UNKNOWN]";
310
326
  tasks.push(
311
- fs.promises.access(captureFile(markdownlintCli2Jsonc)).
312
- then(
313
- () => fs.promises.readFile(file, utf8).then(jsoncParse),
314
- () => fs.promises.access(captureFile(markdownlintCli2Yaml)).
315
- then(
316
- () => fs.promises.readFile(file, utf8).then(yamlParse),
317
- () => fs.promises.access(captureFile(markdownlintCli2Cjs)).
318
- then(
319
- () => importModule(dir, file, noImport),
320
- () => fs.promises.access(captureFile(markdownlintCli2Mjs)).
321
- then(
322
- () => importModule(dir, file, noImport),
323
- () => (allowPackageJson
324
- ? fs.promises.access(captureFile(packageJson))
325
- // eslint-disable-next-line prefer-promise-reject-errors
326
- : Promise.reject()
327
- ).
328
- then(
329
- () => fs.promises.
330
- readFile(file, utf8).
331
- then(jsoncParse).
332
- then((/** @type {any} */ obj) => obj[packageName]),
333
- noop
334
- )
335
- )
336
- )
337
- )
338
- ).
339
- then((/** @type {Options} */ options) => {
327
+
328
+ // 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
+ ).
336
+ then((/** @type {Options | null} */ options) => {
340
337
  dirInfo.markdownlintOptions = options;
341
338
  return options &&
342
339
  options.config &&
343
340
  getExtendedConfig(
344
341
  options.config,
345
- // Just need to identify a file in the right directory
346
- markdownlintCli2Jsonc,
342
+ // Just need to identify the right directory
343
+ pathPosix.join(dir, utf8),
347
344
  fs
348
345
  ).
349
346
  then((config) => {
@@ -351,48 +348,12 @@ const getAndProcessDirInfo = (
351
348
  });
352
349
  }).
353
350
  catch((/** @type {Error} */ error) => {
354
- throwForConfigurationFile(file, error);
355
- })
356
- );
351
+ throwForConfigurationFile(cli2File, error);
352
+ }),
357
353
 
358
- // Load markdownlint object(s)
359
- const readConfigs =
360
- readConfigFile(
361
- fs,
362
- dir,
363
- ".markdownlint.jsonc",
364
- readConfigFile(
365
- fs,
366
- dir,
367
- ".markdownlint.json",
368
- readConfigFile(
369
- fs,
370
- dir,
371
- ".markdownlint.yaml",
372
- readConfigFile(
373
- fs,
374
- dir,
375
- ".markdownlint.yml",
376
- importConfig(
377
- fs,
378
- dir,
379
- ".markdownlint.cjs",
380
- noImport,
381
- importConfig(
382
- fs,
383
- dir,
384
- ".markdownlint.mjs",
385
- noImport,
386
- noop
387
- )
388
- )
389
- )
390
- )
391
- )
392
- );
393
- tasks.push(
394
- readConfigs().
395
- then((/** @type {import("markdownlint").Configuration} */ config) => {
354
+ // Load markdownlint object(s)
355
+ processFirstMatchingConfigurationFile(configurationFiles, dir, fs, noImport, noop).
356
+ then((/** @type {Configuration | null} */ config) => {
396
357
  dirInfo.markdownlintConfig = config;
397
358
  })
398
359
  );
@@ -473,7 +434,7 @@ const enumerateFiles = async (
473
434
  "absolute": true,
474
435
  "cwd": baseDir,
475
436
  "dot": true,
476
- "expandDirectories": false,
437
+ "expandNegationOnlyPatterns": false,
477
438
  gitignore,
478
439
  ignoreFiles,
479
440
  "suppressErrors": true,
@@ -501,29 +462,9 @@ const enumerateFiles = async (
501
462
  ((literalFiles.length > 0) && (globsForIgnore.length > 0))
502
463
  ? removeIgnoredFiles(baseDir, literalFiles, globsForIgnore)
503
464
  : literalFiles;
504
- // Manually expand directories to avoid globby call to dir-glob.sync
505
- const expandedDirectories = await Promise.all(
506
- filteredGlobPatterns.map((globPattern) => {
507
- const barePattern =
508
- globPattern.startsWith("!")
509
- ? globPattern.slice(1)
510
- : globPattern;
511
- const globPath = (
512
- pathPosix.isAbsolute(barePattern) ||
513
- pathDefault.isAbsolute(barePattern)
514
- )
515
- ? barePattern
516
- : pathPosix.join(baseDir, barePattern);
517
- return fs.promises.stat(globPath).
518
- then((/** @type {import("node:fs").Stats} */ stats) => (stats.isDirectory()
519
- ? pathPosix.join(globPattern, "**")
520
- : globPattern)).
521
- catch(() => globPattern);
522
- })
523
- );
524
465
  // Process glob patterns
525
466
  const files = [
526
- ...await globby(expandedDirectories, globbyOptions),
467
+ ...await globby(filteredGlobPatterns, globbyOptions),
527
468
  ...filteredLiteralFiles
528
469
  ];
529
470
  for (const file of files) {
@@ -704,8 +645,7 @@ const createDirInfos = async (
704
645
 
705
646
  // Merge configuration by inheritance
706
647
  for (const dirInfo of dirInfos) {
707
- let markdownlintOptions = dirInfo.markdownlintOptions || {};
708
- let { markdownlintConfig } = dirInfo;
648
+ let { markdownlintConfig, markdownlintOptions } = dirInfo;
709
649
  /** @type {DirInfo | null} */
710
650
  let parent = dirInfo;
711
651
  // eslint-disable-next-line prefer-destructuring
@@ -719,7 +659,7 @@ const createDirInfos = async (
719
659
  if (
720
660
  !markdownlintConfig &&
721
661
  parent.markdownlintConfig &&
722
- !markdownlintOptions.config
662
+ !markdownlintOptions?.config
723
663
  ) {
724
664
  // eslint-disable-next-line prefer-destructuring
725
665
  markdownlintConfig = parent.markdownlintConfig;
@@ -743,6 +683,7 @@ const lintFiles = (/** @type {FsLike} */ fs, /** @type {DirInfo[]} */ dirInfos,
743
683
  // Filter file/string inputs to only those in the dirInfo
744
684
  let filesAfterIgnores = files;
745
685
  if (
686
+ markdownlintOptions &&
746
687
  markdownlintOptions.ignores &&
747
688
  (markdownlintOptions.ignores.length > 0)
748
689
  ) {
@@ -766,7 +707,7 @@ const lintFiles = (/** @type {FsLike} */ fs, /** @type {DirInfo[]} */ dirInfos,
766
707
  // eslint-disable-next-line no-inline-comments
767
708
  const module = await import(/* webpackMode: "eager" */ "markdown-it");
768
709
  const markdownIt = module.default({ "html": true });
769
- for (const plugin of (markdownlintOptions.markdownItPlugins || [])) {
710
+ for (const plugin of (markdownlintOptions?.markdownItPlugins || [])) {
770
711
  // @ts-ignore
771
712
  markdownIt.use(...plugin);
772
713
  }
@@ -777,16 +718,16 @@ const lintFiles = (/** @type {FsLike} */ fs, /** @type {DirInfo[]} */ dirInfos,
777
718
  const options = {
778
719
  "files": filteredFiles,
779
720
  "strings": filteredStrings,
780
- "config": markdownlintConfig || markdownlintOptions.config,
721
+ "config": markdownlintConfig || markdownlintOptions?.config,
781
722
  "configParsers": parsers,
782
723
  // @ts-ignore
783
724
  "customRules": markdownlintOptions.customRules,
784
- "frontMatter": markdownlintOptions.frontMatter
785
- ? new RegExp(markdownlintOptions.frontMatter, "u")
725
+ "frontMatter": markdownlintOptions?.frontMatter
726
+ ? new RegExp(markdownlintOptions?.frontMatter, "u")
786
727
  : undefined,
787
728
  "handleRuleFailures": true,
788
729
  markdownItFactory,
789
- "noInlineConfig": Boolean(markdownlintOptions.noInlineConfig),
730
+ "noInlineConfig": Boolean(markdownlintOptions?.noInlineConfig),
790
731
  fs
791
732
  };
792
733
  // Invoke markdownlint
@@ -799,7 +740,7 @@ const lintFiles = (/** @type {FsLike} */ fs, /** @type {DirInfo[]} */ dirInfos,
799
740
  formattingContext.formatted = applyFixes(original, errorInfos);
800
741
  return {};
801
742
  });
802
- } else if (markdownlintOptions.fix) {
743
+ } else if (markdownlintOptions?.fix) {
803
744
  // For any fixable errors, read file, apply fixes, write it back, and re-lint
804
745
  task = task.then((results) => {
805
746
  options.files = [];
@@ -836,7 +777,7 @@ const lintFiles = (/** @type {FsLike} */ fs, /** @type {DirInfo[]} */ dirInfos,
836
777
  };
837
778
 
838
779
  // Create list of results
839
- const createResults = (/** @type {string} */ baseDir, /** @type {import("markdownlint").LintResults[]} */ taskResults) => {
780
+ const createResults = (/** @type {string} */ baseDir, /** @type {LintResults[]} */ taskResults) => {
840
781
  /** @type {LintResult[]} */
841
782
  const results = [];
842
783
  /** @type {Map<LintResult, number>} */
@@ -1026,13 +967,10 @@ export const main = async (/** @type {Parameters} */ params) => {
1026
967
  logMessage(`Finding: ${globPatterns.join(" ")}`);
1027
968
  }
1028
969
  // Create linting tasks
1029
- const gitignore =
1030
- // https://github.com/sindresorhus/globby/issues/265
1031
- (!params.fs && (baseMarkdownlintOptions.gitignore === true));
1032
- const ignoreFiles =
1033
- (!params.fs && (typeof baseMarkdownlintOptions.gitignore === "string"))
1034
- ? baseMarkdownlintOptions.gitignore
1035
- : undefined;
970
+ const gitignore = (baseMarkdownlintOptions.gitignore === true);
971
+ const ignoreFiles = (typeof baseMarkdownlintOptions.gitignore === "string")
972
+ ? baseMarkdownlintOptions.gitignore
973
+ : undefined;
1036
974
  const dirInfos =
1037
975
  await createDirInfos(
1038
976
  fs,
@@ -1122,14 +1060,26 @@ export const main = async (/** @type {Parameters} */ params) => {
1122
1060
  * @property {Options} [optionsOverride] Options override.
1123
1061
  */
1124
1062
 
1063
+ /** @typedef {import("markdownlint").Configuration} Configuration */
1064
+
1065
+ /**
1066
+ * @typedef ConfigurationHandlerParams
1067
+ * @property {string} dir Configuration file directory.
1068
+ * @property {string} file Configuration file.
1069
+ * @property {FsLike} fs File system object.
1070
+ * @property {boolean} noImport No import.
1071
+ */
1072
+
1073
+ /** @typedef {[ string, (params: ConfigurationHandlerParams) => Promise<any> ] } ConfigurationFileAndHandler */
1074
+
1125
1075
  /**
1126
1076
  * @typedef DirInfo
1127
1077
  * @property {string} dir Directory.
1128
1078
  * @property {string | null} relativeDir Relative directory.
1129
1079
  * @property {DirInfo | null} parent Parent.
1130
1080
  * @property {string[]} files Files.
1131
- * @property {import("markdownlint").Configuration} markdownlintConfig Configuration.
1132
- * @property {Options} markdownlintOptions Options.
1081
+ * @property {Configuration | null} markdownlintConfig Configuration.
1082
+ * @property {Options | null} markdownlintOptions Options.
1133
1083
  */
1134
1084
 
1135
1085
  /** @typedef {Record<string, DirInfo>} DirToDirInfo */
@@ -1138,10 +1088,12 @@ export const main = async (/** @type {Parameters} */ params) => {
1138
1088
 
1139
1089
  /** @typedef {[string]} OutputFormatterConfiguration */
1140
1090
 
1091
+ /** @typedef {import("markdownlint").Rule} Rule */
1092
+
1141
1093
  /**
1142
1094
  * @typedef Options
1143
- * @property {import("markdownlint").Configuration} [config] Config.
1144
- * @property {import("markdownlint").Rule[] | string[]} [customRules] Custom rules.
1095
+ * @property {Configuration} [config] Config.
1096
+ * @property {Rule[] | string[]} [customRules] Custom rules.
1145
1097
  * @property {boolean} [fix] Fix.
1146
1098
  * @property {string} [frontMatter] Front matter.
1147
1099
  * @property {boolean | string} [gitignore] Git ignore.
@@ -1163,6 +1115,8 @@ export const main = async (/** @type {Parameters} */ params) => {
1163
1115
 
1164
1116
  /** @typedef {import("markdownlint").LintError & LintContext} LintResult */
1165
1117
 
1118
+ /** @typedef {import("markdownlint").LintResults} LintResults */
1119
+
1166
1120
  /**
1167
1121
  * @typedef FormattingContext
1168
1122
  * @property {boolean} [formatting] True iff formatting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint-cli2",
3
- "version": "0.19.1",
3
+ "version": "0.21.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",
@@ -35,11 +35,11 @@
35
35
  "lint-dockerfile": "docker run --rm -i hadolint/hadolint:latest-alpine < docker/Dockerfile",
36
36
  "lint-watch": "git ls-files | entr npm run lint",
37
37
  "playwright-install-bare": "npm run playwright-install-npm && playwright install",
38
- "playwright-install-npm": "npm install --no-save playwright@1.56.1",
38
+ "playwright-install-npm": "npm install --no-save playwright@1.58.2",
39
39
  "playwright-test": "playwright test --config ./webworker/playwright.config.mjs",
40
- "playwright-test-docker": "docker run --rm --volume $PWD:/home/workdir --workdir /home/workdir --ipc=host mcr.microsoft.com/playwright:v1.56.1 npm run playwright-test",
40
+ "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
41
  "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-mock-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",
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
43
  "test-cover": "c8 --100 npm test",
44
44
  "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
45
  "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\"",
@@ -73,29 +73,29 @@
73
73
  "schema/ValidatingConfiguration.md"
74
74
  ],
75
75
  "dependencies": {
76
- "globby": "15.0.0",
76
+ "globby": "16.1.0",
77
77
  "js-yaml": "4.1.1",
78
78
  "jsonc-parser": "3.3.1",
79
- "markdownlint": "0.39.0",
79
+ "markdownlint": "0.40.0",
80
80
  "markdownlint-cli2-formatter-default": "0.0.6",
81
- "markdown-it": "14.1.0",
81
+ "markdown-it": "14.1.1",
82
82
  "micromatch": "4.0.8"
83
83
  },
84
84
  "devDependencies": {
85
- "@eslint/js": "9.39.1",
86
- "@playwright/test": "1.56.1",
87
- "@stylistic/eslint-plugin": "5.6.1",
85
+ "@eslint/js": "9.39.2",
86
+ "@playwright/test": "1.58.2",
87
+ "@stylistic/eslint-plugin": "5.8.0",
88
88
  "ajv": "8.17.1",
89
89
  "ava": "6.4.1",
90
90
  "c8": "10.1.3",
91
91
  "chalk": "5.6.2",
92
- "cpy": "12.1.0",
93
- "cpy-cli": "6.0.0",
94
- "eslint": "9.39.1",
95
- "eslint-plugin-jsdoc": "61.4.0",
96
- "eslint-plugin-n": "17.23.1",
97
- "eslint-plugin-unicorn": "62.0.0",
98
- "execa": "9.6.0",
92
+ "cpy": "13.2.1",
93
+ "cpy-cli": "7.0.0",
94
+ "eslint": "9.39.2",
95
+ "eslint-plugin-jsdoc": "62.5.4",
96
+ "eslint-plugin-n": "17.23.2",
97
+ "eslint-plugin-unicorn": "63.0.0",
98
+ "execa": "9.6.1",
99
99
  "markdown-it-emoji": "3.0.0",
100
100
  "markdown-it-for-inline": "2.0.1",
101
101
  "markdownlint-cli2-formatter-codequality": "0.0.7",