markdownlint-cli2 0.20.0 → 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 +5 -0
- package/README.md +9 -8
- package/markdownlint-cli2.mjs +106 -152
- package/package.json +15 -15
- package/schema/markdownlint-cli2-config-schema.json +15 -15
package/CHANGELOG.md
CHANGED
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.
|
|
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.
|
|
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
|
|
305
|
-
|
|
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
|
|
308
|
-
- The value `**/.gitignore` corresponds to the `Boolean` value `true`
|
|
309
|
-
|
|
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.
|
|
456
|
+
rev: v0.21.0
|
|
456
457
|
hooks:
|
|
457
458
|
- id: markdownlint-cli2
|
|
458
459
|
```
|
package/markdownlint-cli2.mjs
CHANGED
|
@@ -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.
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
|
346
|
-
|
|
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(
|
|
355
|
-
})
|
|
356
|
-
);
|
|
351
|
+
throwForConfigurationFile(cli2File, error);
|
|
352
|
+
}),
|
|
357
353
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
"
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
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
|
|
721
|
+
"config": markdownlintConfig || markdownlintOptions?.config,
|
|
781
722
|
"configParsers": parsers,
|
|
782
723
|
// @ts-ignore
|
|
783
724
|
"customRules": markdownlintOptions.customRules,
|
|
784
|
-
"frontMatter": markdownlintOptions
|
|
785
|
-
? new RegExp(markdownlintOptions
|
|
725
|
+
"frontMatter": markdownlintOptions?.frontMatter
|
|
726
|
+
? new RegExp(markdownlintOptions?.frontMatter, "u")
|
|
786
727
|
: undefined,
|
|
787
728
|
"handleRuleFailures": true,
|
|
788
729
|
markdownItFactory,
|
|
789
|
-
"noInlineConfig": Boolean(markdownlintOptions
|
|
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
|
|
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 {
|
|
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
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
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 {
|
|
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 {
|
|
1144
|
-
* @property {
|
|
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.
|
|
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.
|
|
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.
|
|
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-
|
|
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,28 +73,28 @@
|
|
|
73
73
|
"schema/ValidatingConfiguration.md"
|
|
74
74
|
],
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"globby": "
|
|
76
|
+
"globby": "16.1.0",
|
|
77
77
|
"js-yaml": "4.1.1",
|
|
78
78
|
"jsonc-parser": "3.3.1",
|
|
79
79
|
"markdownlint": "0.40.0",
|
|
80
80
|
"markdownlint-cli2-formatter-default": "0.0.6",
|
|
81
|
-
"markdown-it": "14.1.
|
|
81
|
+
"markdown-it": "14.1.1",
|
|
82
82
|
"micromatch": "4.0.8"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@eslint/js": "9.39.
|
|
86
|
-
"@playwright/test": "1.
|
|
87
|
-
"@stylistic/eslint-plugin": "5.
|
|
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": "
|
|
93
|
-
"cpy-cli": "
|
|
94
|
-
"eslint": "9.39.
|
|
95
|
-
"eslint-plugin-jsdoc": "
|
|
96
|
-
"eslint-plugin-n": "17.23.
|
|
97
|
-
"eslint-plugin-unicorn": "
|
|
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
98
|
"execa": "9.6.1",
|
|
99
99
|
"markdown-it-emoji": "3.0.0",
|
|
100
100
|
"markdown-it-for-inline": "2.0.1",
|
|
@@ -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.
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.21.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.
|
|
10
|
+
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.21.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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
57
|
+
"description": "Glob expressions to ignore when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.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.
|
|
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",
|
|
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.
|
|
87
|
+
"description": "Additional paths to resolve module locations from : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.21.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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
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",
|
|
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.
|
|
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",
|
|
133
133
|
"type": "boolean",
|
|
134
134
|
"default": false
|
|
135
135
|
}
|