markdownlint-cli2 0.12.0 → 0.13.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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+
5
+ - Add `noBanner` and `gitignore` configuration options
6
+ - Reduce install size by switching to `js-yaml` package
7
+ - Add more detail to some error messages
8
+ - Export JSONC/YAML parsers for reuse
9
+ - Update dependencies (including `markdownlint`)
10
+
11
+ ## 0.12.1
12
+
13
+ - Update JSONC parsing to handle trailing commas
14
+ - Add documentation links to JSON schema
15
+ - Update dependencies
16
+
3
17
  ## 0.12.0
4
18
 
5
19
  - Remove deprecated `markdownlint-cli2-config` entry point
package/README.md CHANGED
@@ -147,7 +147,7 @@ A container image [`davidanson/markdownlint-cli2`][docker-hub-markdownlint-cli2]
147
147
  can also be used (e.g., as part of a CI pipeline):
148
148
 
149
149
  ```bash
150
- docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules"
150
+ docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.13.0 "**/*.md" "#node_modules"
151
151
  ```
152
152
 
153
153
  Notes:
@@ -164,7 +164,7 @@ Notes:
164
164
  - A custom working directory can be specified with Docker's `-w` flag:
165
165
 
166
166
  ```bash
167
- docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.12.0 "**/*.md" "#node_modules"
167
+ docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.13.0 "**/*.md" "#node_modules"
168
168
  ```
169
169
 
170
170
  For convenience, the container image
@@ -256,6 +256,10 @@ of the rules within.
256
256
  - The `String` is passed as the `pattern` parameter to the
257
257
  [`RegExp` constructor][regexp-constructor]
258
258
  - For example: `(^---\s*$[^]*?^---\s*$)(\r\n|\r|\n|$)`
259
+ - `gitignore`: `Boolean` value to ignore files referenced by `.gitignore` when
260
+ linting
261
+ - This top-level setting is valid **only** in the directory from which
262
+ `markdownlint-cli2` is run
259
263
  - `globs`: `Array` of `String`s defining glob expressions to append to the
260
264
  command-line arguments
261
265
  - This setting can be used instead of (or in addition to) passing globs on
@@ -285,6 +289,10 @@ of the rules within.
285
289
  - Search [`markdown-it-plugins` on npm][markdown-it-plugins]
286
290
  - `modulePaths`: `Array` of `String`s providing additional paths to use when
287
291
  resolving module references (e.g., alternate locations for `node_modules`)
292
+ - `noBanner`: `Boolean` value to disable the display of the banner message and
293
+ version numbers on `stdout`
294
+ - This top-level setting is valid **only** in the directory from which
295
+ `markdownlint-cli2` is run
288
296
  - `noInlineConfig`: `Boolean` value to disable the support of
289
297
  [HTML comments][html-comment] within Markdown content
290
298
  - For example: `<!-- markdownlint-disable some-rule -->`
@@ -396,7 +404,7 @@ reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
396
404
 
397
405
  ```yaml
398
406
  - repo: https://github.com/DavidAnson/markdownlint-cli2
399
- rev: v0.12.0
407
+ rev: v0.13.0
400
408
  hooks:
401
409
  - id: markdownlint-cli2
402
410
  ```
@@ -6,9 +6,9 @@ const sliceSize = 1000;
6
6
 
7
7
  /**
8
8
  * Efficiently appends the source array to the destination array.
9
- * @param {Object[]} destination Destination Array.
10
- * @param {Object[]} source Source Array.
11
- * @returns void
9
+ * @param {object[]} destination Destination Array.
10
+ * @param {object[]} source Source Array.
11
+ * @returns {void}
12
12
  */
13
13
  const appendToArray = (destination, source) => {
14
14
  // NOTE: destination.push(...source) throws "RangeError: Maximum call stack
@@ -26,29 +26,37 @@ const resolveAndRequire = require("./resolve-and-require");
26
26
 
27
27
  // Variables
28
28
  const packageName = "markdownlint-cli2";
29
- const packageVersion = "0.12.0";
29
+ const packageVersion = "0.13.0";
30
30
  const libraryName = "markdownlint";
31
31
  const libraryVersion = markdownlintLibrary.getVersion();
32
+ const bannerMessage = `${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`;
32
33
  const dotOnlySubstitute = "*.{md,markdown}";
33
34
  const utf8 = "utf8";
34
35
 
35
36
  // No-op function
36
37
  const noop = () => null;
37
38
 
38
- // Gets a synchronous function to parse JSONC text
39
- const getJsoncParse = async () => {
40
- const { "default": stripJsonComments } =
41
- // eslint-disable-next-line no-inline-comments
42
- await import(/* webpackMode: "eager" */ "strip-json-comments");
43
- return (text) => JSON.parse(stripJsonComments(text));
44
- };
39
+ // Gets a JSONC parser
40
+ const getJsoncParse = () => require("./parsers/jsonc-parse.js");
41
+
42
+ // Gets a YAML parser
43
+ const getYamlParse = () => require("./parsers/yaml-parse.js");
45
44
 
46
- // Synchronous function to parse YAML text
47
- const yamlParse = (text) => require("yaml").parse(text);
45
+ // Gets an ordered array of parsers
46
+ const getParsers = () => require("./parsers/parsers.js");
48
47
 
49
- // Negate a glob
48
+ // Negates a glob
50
49
  const negateGlob = (glob) => `!${glob}`;
51
50
 
51
+ // Throws a meaningful exception for an unusable configuration file
52
+ const throwForConfigurationFile = (file, error) => {
53
+ throw new Error(
54
+ `Unable to use configuration file '${file}'; ${error?.message}`,
55
+ // @ts-ignore
56
+ { "cause": error }
57
+ );
58
+ };
59
+
52
60
  // Return a posix path (even on Windows)
53
61
  const posixPath = (p) => p.split(pathDefault.sep).join(pathPosix.sep);
54
62
 
@@ -63,27 +71,26 @@ const resolveModulePaths = (dir, modulePaths) => (
63
71
  );
64
72
 
65
73
  // Read a JSON(C) or YAML file and return the object
66
- const readConfig = (fs, dir, name, otherwise) => {
74
+ const readConfig = (fs, dir, name, otherwise) => () => {
67
75
  const file = pathPosix.join(dir, name);
68
- return () => fs.promises.access(file).
76
+ return fs.promises.access(file).
69
77
  then(
70
- () => getJsoncParse().then(
71
- (jsoncParse) => markdownlintReadConfig(
72
- file,
73
- [ jsoncParse, yamlParse ],
74
- fs
75
- )
78
+ () => markdownlintReadConfig(
79
+ file,
80
+ getParsers(),
81
+ fs
76
82
  ),
77
83
  otherwise
78
84
  );
79
85
  };
80
86
 
81
87
  // Import or resolve/require a module ID with a custom directory in the path
82
- const importOrRequireResolve = async (dirs, id, noRequire) => {
88
+ const importOrRequireResolve = async (dirOrDirs, id, noRequire) => {
83
89
  if (typeof id === "string") {
84
90
  if (noRequire) {
85
91
  return null;
86
92
  }
93
+ const dirs = Array.isArray(dirOrDirs) ? dirOrDirs : [ dirOrDirs ];
87
94
  const expandId = expandTildePath(id);
88
95
  const errors = [];
89
96
  try {
@@ -92,10 +99,12 @@ const importOrRequireResolve = async (dirs, id, noRequire) => {
92
99
  errors.push(error);
93
100
  }
94
101
  try {
95
- const fileUrlString =
96
- pathToFileURL(pathDefault.resolve(dirs[0], expandId)).toString();
102
+ const isURL = !pathDefault.isAbsolute(expandId) && URL.canParse(expandId);
103
+ const urlString = (
104
+ isURL ? new URL(expandId) : pathToFileURL(pathDefault.resolve(dirs[0], expandId))
105
+ ).toString();
97
106
  // eslint-disable-next-line no-inline-comments
98
- const module = await import(/* webpackIgnore: true */ fileUrlString);
107
+ const module = await import(/* webpackIgnore: true */ urlString);
99
108
  return module.default;
100
109
  } catch (error) {
101
110
  errors.push(error);
@@ -129,28 +138,27 @@ const importOrRequireIdsAndParams = (dirs, idsAndParams, noRequire) => (
129
138
  );
130
139
 
131
140
  // Import or require a JavaScript file and return the exported object
132
- const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => {
133
- const id = pathPosix.join(dir, name);
134
- return () => fs.promises.access(id).
141
+ const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => () => {
142
+ const file = pathPosix.join(dir, name);
143
+ return fs.promises.access(file).
135
144
  then(
136
- () => (noRequire ? {} : importOrRequireResolve([ dir ], id)),
145
+ () => importOrRequireResolve(dir, name, noRequire),
137
146
  otherwise
138
147
  );
139
148
  };
140
149
 
141
150
  // Extend a config object if it has 'extends' property
142
- const getExtendedConfig = async (config, configPath, fs) => {
151
+ const getExtendedConfig = (config, configPath, fs) => {
143
152
  if (config.extends) {
144
- const jsoncParse = await getJsoncParse();
145
153
  return markdownlintExtendConfig(
146
154
  config,
147
155
  configPath,
148
- [ jsoncParse, yamlParse ],
156
+ getParsers(),
149
157
  fs
150
158
  );
151
159
  }
152
160
 
153
- return config;
161
+ return Promise.resolve(config);
154
162
  };
155
163
 
156
164
  // Read an options or config file in any format and return the object
@@ -159,49 +167,43 @@ const readOptionsOrConfig = async (configPath, fs, noRequire) => {
159
167
  const dirname = pathPosix.dirname(configPath);
160
168
  let options = null;
161
169
  let config = null;
162
- if (basename.endsWith(".markdownlint-cli2.jsonc")) {
163
- const jsoncParse = await getJsoncParse();
164
- options = jsoncParse(await fs.promises.readFile(configPath, utf8));
165
- } else if (basename.endsWith(".markdownlint-cli2.yaml")) {
166
- options = yamlParse(await fs.promises.readFile(configPath, utf8));
167
- } else if (
168
- basename.endsWith(".markdownlint-cli2.cjs") ||
169
- basename.endsWith(".markdownlint-cli2.mjs")
170
- ) {
171
- options = await (
172
- importOrRequireConfig(fs, dirname, basename, noRequire, noop)()
173
- );
174
- } else if (
175
- basename.endsWith(".markdownlint.jsonc") ||
176
- basename.endsWith(".markdownlint.json") ||
177
- basename.endsWith(".markdownlint.yaml") ||
178
- basename.endsWith(".markdownlint.yml")
179
- ) {
180
- const jsoncParse = await getJsoncParse();
181
- config =
182
- await markdownlintReadConfig(configPath, [ jsoncParse, yamlParse ], fs);
183
- } else if (
184
- basename.endsWith(".markdownlint.cjs") ||
185
- basename.endsWith(".markdownlint.mjs")
186
- ) {
187
- config = await (
188
- importOrRequireConfig(fs, dirname, basename, noRequire, noop)()
189
- );
190
- } else {
191
- throw new Error(
192
- `Configuration file "${configPath}" is unrecognized; ` +
193
- "its name should be (or end with) one of the supported types " +
194
- "(e.g., \".markdownlint.json\" or \"example.markdownlint-cli2.jsonc\")."
195
- );
170
+ try {
171
+ if (basename.endsWith(".markdownlint-cli2.jsonc")) {
172
+ options = getJsoncParse()(await fs.promises.readFile(configPath, utf8));
173
+ } else if (basename.endsWith(".markdownlint-cli2.yaml")) {
174
+ options = getYamlParse()(await fs.promises.readFile(configPath, utf8));
175
+ } else if (
176
+ basename.endsWith(".markdownlint-cli2.cjs") ||
177
+ basename.endsWith(".markdownlint-cli2.mjs")
178
+ ) {
179
+ options = await importOrRequireResolve(dirname, basename, noRequire);
180
+ } else if (
181
+ basename.endsWith(".markdownlint.jsonc") ||
182
+ basename.endsWith(".markdownlint.json") ||
183
+ basename.endsWith(".markdownlint.yaml") ||
184
+ basename.endsWith(".markdownlint.yml")
185
+ ) {
186
+ config = await markdownlintReadConfig(configPath, getParsers(), fs);
187
+ } else if (
188
+ basename.endsWith(".markdownlint.cjs") ||
189
+ basename.endsWith(".markdownlint.mjs")
190
+ ) {
191
+ config = await importOrRequireResolve(dirname, basename, noRequire);
192
+ } else {
193
+ throw new Error(
194
+ "File name should be (or end with) one of the supported types " +
195
+ "(e.g., '.markdownlint.json' or 'example.markdownlint-cli2.jsonc')."
196
+ );
197
+ }
198
+ } catch (error) {
199
+ throwForConfigurationFile(configPath, error);
196
200
  }
197
-
198
201
  if (options) {
199
202
  if (options.config) {
200
203
  options.config = await getExtendedConfig(options.config, configPath, fs);
201
204
  }
202
205
  return options;
203
206
  }
204
-
205
207
  config = await getExtendedConfig(config, configPath, fs);
206
208
  return { config };
207
209
  };
@@ -240,7 +242,10 @@ const processArgv = (argv) => {
240
242
  };
241
243
 
242
244
  // Show help if missing arguments
243
- const showHelp = (logMessage) => {
245
+ const showHelp = (logMessage, showBanner) => {
246
+ if (showBanner) {
247
+ logMessage(bannerMessage);
248
+ }
244
249
  logMessage(`https://github.com/DavidAnson/markdownlint-cli2
245
250
 
246
251
  Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--fix] [--help]
@@ -296,6 +301,7 @@ const getAndProcessDirInfo = (
296
301
  noRequire,
297
302
  allowPackageJson
298
303
  ) => {
304
+ // Create dirInfo
299
305
  let dirInfo = dirToDirInfo[dir];
300
306
  if (!dirInfo) {
301
307
  dirInfo = {
@@ -309,52 +315,41 @@ const getAndProcessDirInfo = (
309
315
  dirToDirInfo[dir] = dirInfo;
310
316
 
311
317
  // Load markdownlint-cli2 object(s)
312
- const markdownlintCli2Jsonc =
313
- pathPosix.join(dir, ".markdownlint-cli2.jsonc");
314
- const markdownlintCli2Yaml =
315
- pathPosix.join(dir, ".markdownlint-cli2.yaml");
318
+ const markdownlintCli2Jsonc = pathPosix.join(dir, ".markdownlint-cli2.jsonc");
319
+ const markdownlintCli2Yaml = pathPosix.join(dir, ".markdownlint-cli2.yaml");
320
+ const markdownlintCli2Cjs = pathPosix.join(dir, ".markdownlint-cli2.cjs");
321
+ const markdownlintCli2Mjs = pathPosix.join(dir, ".markdownlint-cli2.mjs");
316
322
  const packageJson = pathPosix.join(dir, "package.json");
323
+ let file = "[UNKNOWN]";
324
+ // eslint-disable-next-line no-return-assign
325
+ const captureFile = (f) => file = f;
317
326
  tasks.push(
318
- fs.promises.access(markdownlintCli2Jsonc).
327
+ fs.promises.access(captureFile(markdownlintCli2Jsonc)).
319
328
  then(
320
- () => fs.promises.
321
- readFile(markdownlintCli2Jsonc, utf8).
329
+ () => fs.promises.readFile(file, utf8).then(getJsoncParse()),
330
+ () => fs.promises.access(captureFile(markdownlintCli2Yaml)).
322
331
  then(
323
- (content) => getJsoncParse().
324
- then((jsoncParse) => jsoncParse(content))
325
- ),
326
- () => fs.promises.access(markdownlintCli2Yaml).
327
- then(
328
- () => fs.promises.
329
- readFile(markdownlintCli2Yaml, utf8).
330
- then(yamlParse),
331
- importOrRequireConfig(
332
- fs,
333
- dir,
334
- ".markdownlint-cli2.cjs",
335
- noRequire,
336
- importOrRequireConfig(
337
- fs,
338
- dir,
339
- ".markdownlint-cli2.mjs",
340
- noRequire,
341
- () => (allowPackageJson
342
- ? fs.promises.access(packageJson)
343
- // eslint-disable-next-line prefer-promise-reject-errors
344
- : Promise.reject()
345
- ).
332
+ () => fs.promises.readFile(file, utf8).then(getYamlParse()),
333
+ () => fs.promises.access(captureFile(markdownlintCli2Cjs)).
334
+ then(
335
+ () => importOrRequireResolve(dir, file, noRequire),
336
+ () => fs.promises.access(captureFile(markdownlintCli2Mjs)).
346
337
  then(
347
- () => fs.promises.
348
- readFile(packageJson, utf8).
338
+ () => importOrRequireResolve(dir, file, noRequire),
339
+ () => (allowPackageJson
340
+ ? fs.promises.access(captureFile(packageJson))
341
+ // eslint-disable-next-line prefer-promise-reject-errors
342
+ : Promise.reject()
343
+ ).
349
344
  then(
350
- (content) => getJsoncParse().
351
- then((jsoncParse) => jsoncParse(content)).
352
- then((obj) => obj[packageName])
353
- ),
354
- noop
345
+ () => fs.promises.
346
+ readFile(file, utf8).
347
+ then(getJsoncParse()).
348
+ then((obj) => obj[packageName]),
349
+ noop
350
+ )
355
351
  )
356
352
  )
357
- )
358
353
  )
359
354
  ).
360
355
  then((options) => {
@@ -363,7 +358,7 @@ const getAndProcessDirInfo = (
363
358
  options.config &&
364
359
  getExtendedConfig(
365
360
  options.config,
366
- // Just needs to identify a file in the right directory
361
+ // Just need to identify a file in the right directory
367
362
  markdownlintCli2Jsonc,
368
363
  fs
369
364
  ).
@@ -371,6 +366,9 @@ const getAndProcessDirInfo = (
371
366
  options.config = config;
372
367
  });
373
368
  })
369
+ .catch((error) => {
370
+ throwForConfigurationFile(file, error);
371
+ })
374
372
  );
375
373
 
376
374
  // Load markdownlint object(s)
@@ -415,6 +413,8 @@ const getAndProcessDirInfo = (
415
413
  })
416
414
  );
417
415
  }
416
+
417
+ // Return dirInfo
418
418
  return dirInfo;
419
419
  };
420
420
 
@@ -476,14 +476,17 @@ const enumerateFiles = async (
476
476
  baseDir,
477
477
  globPatterns,
478
478
  dirToDirInfo,
479
+ gitignore,
479
480
  noRequire
480
481
  ) => {
481
482
  const tasks = [];
483
+ /** @type {import("globby").Options} */
482
484
  const globbyOptions = {
483
485
  "absolute": true,
484
486
  "cwd": baseDir,
485
487
  "dot": true,
486
488
  "expandDirectories": false,
489
+ gitignore,
487
490
  "suppressErrors": true,
488
491
  fs
489
492
  };
@@ -608,6 +611,7 @@ const createDirInfos = async (
608
611
  globPatterns,
609
612
  dirToDirInfo,
610
613
  optionsOverride,
614
+ gitignore,
611
615
  noRequire
612
616
  ) => {
613
617
  await enumerateFiles(
@@ -616,6 +620,7 @@ const createDirInfos = async (
616
620
  baseDir,
617
621
  globPatterns,
618
622
  dirToDirInfo,
623
+ gitignore,
619
624
  noRequire
620
625
  );
621
626
  await enumerateParents(
@@ -743,8 +748,7 @@ const createDirInfos = async (
743
748
  };
744
749
 
745
750
  // Lint files in groups by shared configuration
746
- const lintFiles = async (fs, dirInfos, fileContents) => {
747
- const jsoncParse = await getJsoncParse();
751
+ const lintFiles = (fs, dirInfos, fileContents) => {
748
752
  const tasks = [];
749
753
  // For each dirInfo
750
754
  for (const dirInfo of dirInfos) {
@@ -773,7 +777,7 @@ const lintFiles = async (fs, dirInfos, fileContents) => {
773
777
  "files": filteredFiles,
774
778
  "strings": filteredStrings,
775
779
  "config": markdownlintConfig || markdownlintOptions.config,
776
- "configParsers": [ jsoncParse, yamlParse ],
780
+ "configParsers": getParsers(),
777
781
  "customRules": markdownlintOptions.customRules,
778
782
  "frontMatter": markdownlintOptions.frontMatter
779
783
  ? new RegExp(markdownlintOptions.frontMatter, "u")
@@ -908,10 +912,6 @@ const main = async (params) => {
908
912
  (directory && pathDefault.resolve(directory)) ||
909
913
  process.cwd();
910
914
  const baseDir = posixPath(baseDirSystem);
911
- // Output banner
912
- logMessage(
913
- `${packageName} v${packageVersion} (${libraryName} v${libraryVersion})`
914
- );
915
915
  // Merge and process args/argv
916
916
  let fixDefault = false;
917
917
  // eslint-disable-next-line unicorn/no-useless-undefined
@@ -938,22 +938,24 @@ const main = async (params) => {
938
938
  return true;
939
939
  });
940
940
  if (shouldShowHelp) {
941
- return showHelp(logMessage);
941
+ return showHelp(logMessage, true);
942
942
  }
943
943
  // Read argv configuration file (if relevant and present)
944
944
  let optionsArgv = null;
945
945
  let relativeDir = null;
946
- if (configPath) {
947
- const resolvedConfigPath =
948
- posixPath(pathDefault.resolve(baseDirSystem, configPath));
949
- optionsArgv =
950
- await readOptionsOrConfig(resolvedConfigPath, fs, noRequire);
951
- relativeDir = pathPosix.dirname(resolvedConfigPath);
952
- }
953
- // Process arguments and get base options
954
- const globPatterns = processArgv(argvFiltered);
955
- const { baseMarkdownlintOptions, dirToDirInfo } =
956
- await getBaseOptions(
946
+ let globPatterns = null;
947
+ let baseOptions = null;
948
+ try {
949
+ if (configPath) {
950
+ const resolvedConfigPath =
951
+ posixPath(pathDefault.resolve(baseDirSystem, configPath));
952
+ optionsArgv =
953
+ await readOptionsOrConfig(resolvedConfigPath, fs, noRequire);
954
+ relativeDir = pathPosix.dirname(resolvedConfigPath);
955
+ }
956
+ // Process arguments and get base options
957
+ globPatterns = processArgv(argvFiltered);
958
+ baseOptions = await getBaseOptions(
957
959
  fs,
958
960
  baseDir,
959
961
  relativeDir,
@@ -963,13 +965,19 @@ const main = async (params) => {
963
965
  noGlobs,
964
966
  noRequire
965
967
  );
968
+ } finally {
969
+ if (!baseOptions?.baseMarkdownlintOptions.noBanner) {
970
+ logMessage(bannerMessage);
971
+ }
972
+ }
966
973
  if (
967
974
  ((globPatterns.length === 0) && !nonFileContents) ||
968
975
  (configPath === null)
969
976
  ) {
970
- return showHelp(logMessage);
977
+ return showHelp(logMessage, false);
971
978
  }
972
979
  // Include any file overrides or non-file content
980
+ const { baseMarkdownlintOptions, dirToDirInfo } = baseOptions;
973
981
  const resolvedFileContents = {};
974
982
  for (const file in fileContents) {
975
983
  const resolvedFile = posixPath(pathDefault.resolve(baseDirSystem, file));
@@ -997,6 +1005,8 @@ const main = async (params) => {
997
1005
  globPatterns,
998
1006
  dirToDirInfo,
999
1007
  optionsOverride,
1008
+ // https://github.com/sindresorhus/globby/issues/265
1009
+ !params.fs && Boolean(baseMarkdownlintOptions.gitignore),
1000
1010
  noRequire
1001
1011
  );
1002
1012
  // Output linting status
package/merge-options.js CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  /**
6
6
  * Merges two options objects by combining config and replacing properties.
7
- * @param {Object} first First options object.
8
- * @param {Object} second Second options object.
9
- * @returns {Object} Merged options object.
7
+ * @param {object} first First options object.
8
+ * @param {object} second Second options object.
9
+ * @returns {object} Merged options object.
10
10
  */
11
11
  const mergeOptions = (first, second) => {
12
12
  const merged = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint-cli2",
3
- "version": "0.12.0",
3
+ "version": "0.13.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",
@@ -12,7 +12,10 @@
12
12
  "exports": {
13
13
  ".": "./markdownlint-cli2.js",
14
14
  "./markdownlint": "./export-markdownlint.js",
15
- "./markdownlint/helpers": "./export-markdownlint-helpers.js"
15
+ "./markdownlint/helpers": "./export-markdownlint-helpers.js",
16
+ "./parsers": "./parsers/parsers.js",
17
+ "./parsers/jsonc": "./parsers/jsonc-parse.js",
18
+ "./parsers/yaml": "./parsers/yaml-parse.js"
16
19
  },
17
20
  "bin": {
18
21
  "markdownlint-cli2": "markdownlint-cli2.js"
@@ -32,8 +35,8 @@
32
35
  "lint-dockerfile": "docker run --rm -i hadolint/hadolint:latest-alpine < docker/Dockerfile",
33
36
  "lint-watch": "git ls-files | entr npm run lint",
34
37
  "schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat",
35
- "test": "ava --timeout=1m test/append-to-array-test.js test/fs-mock-test.js test/markdownlint-cli2-test.js test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js test/merge-options-test.js test/resolve-and-require-test.js",
36
- "test-cover": "c8 --100 npm test -- --concurrency=1",
38
+ "test": "ava --timeout=1m test/append-to-array-test.js test/fs-mock-test.js test/markdownlint-cli2-test.js test/markdownlint-cli2-test-exec.js test/markdownlint-cli2-test-exports.js test/markdownlint-cli2-test-fs.js test/markdownlint-cli2-test-main.js test/merge-options-test.js test/resolve-and-require-test.js",
39
+ "test-cover": "c8 --100 npm test",
37
40
  "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\"",
38
41
  "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\"",
39
42
  "test-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\"",
@@ -55,6 +58,9 @@
55
58
  "LICENSE",
56
59
  "markdownlint-cli2.js",
57
60
  "merge-options.js",
61
+ "parsers/parsers.js",
62
+ "parsers/jsonc-parse.js",
63
+ "parsers/yaml-parse.js",
58
64
  "README.md",
59
65
  "resolve-and-require.js",
60
66
  "schema/markdownlint-cli2-config-schema.json",
@@ -62,30 +68,31 @@
62
68
  "schema/ValidatingConfiguration.md"
63
69
  ],
64
70
  "dependencies": {
65
- "globby": "14.0.0",
66
- "markdownlint": "0.33.0",
71
+ "globby": "14.0.1",
72
+ "js-yaml": "4.1.0",
73
+ "jsonc-parser": "3.2.1",
74
+ "markdownlint": "0.34.0",
67
75
  "markdownlint-cli2-formatter-default": "0.0.4",
68
- "micromatch": "4.0.5",
69
- "strip-json-comments": "5.0.1",
70
- "yaml": "2.3.4"
76
+ "micromatch": "4.0.5"
71
77
  },
72
78
  "devDependencies": {
73
79
  "@iktakahiro/markdown-it-katex": "4.0.1",
74
80
  "ajv": "8.12.0",
75
- "ava": "6.0.1",
76
- "c8": "9.0.0",
77
- "cpy": "11.0.0",
81
+ "ava": "6.1.2",
82
+ "c8": "9.1.0",
83
+ "cpy": "11.0.1",
78
84
  "cpy-cli": "5.0.0",
79
85
  "del": "7.1.0",
80
- "eslint": "8.56.0",
86
+ "eslint": "8.57.0",
87
+ "eslint-plugin-jsdoc": "48.2.2",
81
88
  "eslint-plugin-n": "16.6.2",
82
- "eslint-plugin-unicorn": "50.0.1",
89
+ "eslint-plugin-unicorn": "51.0.1",
83
90
  "execa": "8.0.1",
84
91
  "markdown-it-emoji": "3.0.0",
85
92
  "markdown-it-for-inline": "2.0.1",
86
93
  "markdownlint-cli2-formatter-codequality": "0.0.4",
87
94
  "markdownlint-cli2-formatter-json": "0.0.7",
88
- "markdownlint-cli2-formatter-junit": "0.0.8",
95
+ "markdownlint-cli2-formatter-junit": "0.0.9",
89
96
  "markdownlint-cli2-formatter-pretty": "0.0.5",
90
97
  "markdownlint-cli2-formatter-sarif": "0.0.1",
91
98
  "markdownlint-cli2-formatter-summarize": "0.0.6",