@jpeakai/mermaidjs-lint 0.6.1 → 0.6.3

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/dist/bin.js CHANGED
@@ -9,7 +9,7 @@ import { parseArgs } from "node:util";
9
9
  // package.json
10
10
  var package_default = {
11
11
  name: "@jpeakai/mermaidjs-lint",
12
- version: "0.6.1",
12
+ version: "0.6.3",
13
13
  type: "module",
14
14
  description: "Deterministic lint gates and verified fixers for Mermaid diagrams in markdown",
15
15
  license: "MIT",
@@ -2828,7 +2828,7 @@ var setUp = async ({
2828
2828
  // src/cli.ts
2829
2829
  var SYNOPSIS = `usage: mermaidjs-lint <path...> [--fix] [--json] [--preset NAME] [--profile NAME] [--config FILE]
2830
2830
  [--canvas-light COLOUR] [--canvas-dark COLOUR] [--no-plugins | --lenient-plugins]
2831
- mermaidjs-lint --list-rules
2831
+ mermaidjs-lint --list-rules [--config FILE] [--no-plugins | --lenient-plugins]
2832
2832
  mermaidjs-lint --validate-plugins [--json] [--config FILE]
2833
2833
  mermaidjs-lint --version | -h, --help`;
2834
2834
  var ruleRow = (r, width) => `${`${r.id}${r.fix ? "*" : ""}`.padEnd(width)} ${r.summary}`;
@@ -2869,7 +2869,7 @@ Plugins load on their own from .mermaidjs-lint/rules, from dependencies named me
2869
2869
  --lenient-plugins skips a plugin that fails to load and says so, instead of stopping the run.
2870
2870
  --validate-plugins imports and checks every plugin, reports every failure, and runs no check or fix.
2871
2871
  --list-rules prints every active rule by category, including plugin rules, and where each plugin came from.
2872
- It imports the plugins to list them.
2872
+ It imports the plugins to list them, and takes no path or other flag.
2873
2873
  --version prints the version, to quote in a bug report.
2874
2874
  Exits 0 when no findings remain, 1 when findings remain, a plugin fails to load or the run fails (a lenient run
2875
2875
  skips a broken plugin, so it alone does not exit 1), and 2 on a usage error.`;
@@ -3004,6 +3004,15 @@ var run = async (argv, cwd) => {
3004
3004
  if (validating && (values["no-plugins"] || values.fix || listing)) {
3005
3005
  throw new FlagError("--validate-plugins", "--validate-plugins takes no --no-plugins, --fix or --list-rules");
3006
3006
  }
3007
+ if (listing && !validating) {
3008
+ const ignored = [
3009
+ ...["fix", "json", "preset", "profile", "canvas-light", "canvas-dark"].filter((name) => values[name] !== undefined && values[name] !== false).map((name) => `--${name}`),
3010
+ ...positionals.length > 0 ? ["a path"] : []
3011
+ ];
3012
+ if (ignored.length > 0) {
3013
+ throw new FlagError("--list-rules", `--list-rules takes only --config and --no-plugins or --lenient-plugins, not ${ignored.join(", ")}`);
3014
+ }
3015
+ }
3007
3016
  if (validating && positionals.length > 0) {
3008
3017
  throw new FlagError("files", "--validate-plugins runs no check, so it takes no files");
3009
3018
  }
@@ -3043,9 +3052,9 @@ var run = async (argv, cwd) => {
3043
3052
  throw new FlagError("files", "no matching files");
3044
3053
  if (values.fix)
3045
3054
  await refuseOutsideLinks(files, root, cwd);
3046
- const setAside = files.filter((file) => canvasSetAside(file, flags, registry));
3055
+ const setAside = files.filter((file) => canvasSetAside(file, flags, registry)).map((f) => display(f, cwd));
3047
3056
  if (setAside.length > 0) {
3048
- console.error(`mermaidjs-lint: config canvas set aside for ${plural(setAside.length, "file")} scored under mkdocs-material: ${setAside.map((f) => display(f, cwd)).join(", ")}`);
3057
+ console.error(`mermaidjs-lint: config canvas set aside for ${plural(setAside.length, "file")} scored under mkdocs-material: ${setAside.join(", ")}`);
3049
3058
  }
3050
3059
  const perFile = await Promise.all(files.map(async (file) => {
3051
3060
  let src = await readFile3(file, "utf8");
@@ -3068,7 +3077,7 @@ var run = async (argv, cwd) => {
3068
3077
  code: f.error.code,
3069
3078
  message: reasonOf(f)
3070
3079
  }));
3071
- console.log(JSON.stringify({ findings: all, files: files.length, plugins: registry.sources, skippedPlugins }, null, 2));
3080
+ console.log(JSON.stringify({ findings: all, files: files.length, plugins: registry.sources, skippedPlugins, canvasSetAside: setAside }, null, 2));
3072
3081
  } else {
3073
3082
  for (const f of all)
3074
3083
  console.log(reportLine(f, f.file));
package/dist/index.js CHANGED
@@ -2023,7 +2023,7 @@ import { parseArgs } from "node:util";
2023
2023
  // package.json
2024
2024
  var package_default = {
2025
2025
  name: "@jpeakai/mermaidjs-lint",
2026
- version: "0.6.1",
2026
+ version: "0.6.3",
2027
2027
  type: "module",
2028
2028
  description: "Deterministic lint gates and verified fixers for Mermaid diagrams in markdown",
2029
2029
  license: "MIT",
@@ -2828,7 +2828,7 @@ var setUp = async ({
2828
2828
  // src/cli.ts
2829
2829
  var SYNOPSIS = `usage: mermaidjs-lint <path...> [--fix] [--json] [--preset NAME] [--profile NAME] [--config FILE]
2830
2830
  [--canvas-light COLOUR] [--canvas-dark COLOUR] [--no-plugins | --lenient-plugins]
2831
- mermaidjs-lint --list-rules
2831
+ mermaidjs-lint --list-rules [--config FILE] [--no-plugins | --lenient-plugins]
2832
2832
  mermaidjs-lint --validate-plugins [--json] [--config FILE]
2833
2833
  mermaidjs-lint --version | -h, --help`;
2834
2834
  var ruleRow = (r, width) => `${`${r.id}${r.fix ? "*" : ""}`.padEnd(width)} ${r.summary}`;
@@ -2869,7 +2869,7 @@ Plugins load on their own from .mermaidjs-lint/rules, from dependencies named me
2869
2869
  --lenient-plugins skips a plugin that fails to load and says so, instead of stopping the run.
2870
2870
  --validate-plugins imports and checks every plugin, reports every failure, and runs no check or fix.
2871
2871
  --list-rules prints every active rule by category, including plugin rules, and where each plugin came from.
2872
- It imports the plugins to list them.
2872
+ It imports the plugins to list them, and takes no path or other flag.
2873
2873
  --version prints the version, to quote in a bug report.
2874
2874
  Exits 0 when no findings remain, 1 when findings remain, a plugin fails to load or the run fails (a lenient run
2875
2875
  skips a broken plugin, so it alone does not exit 1), and 2 on a usage error.`;
@@ -3004,6 +3004,15 @@ var run = async (argv, cwd) => {
3004
3004
  if (validating && (values["no-plugins"] || values.fix || listing)) {
3005
3005
  throw new FlagError("--validate-plugins", "--validate-plugins takes no --no-plugins, --fix or --list-rules");
3006
3006
  }
3007
+ if (listing && !validating) {
3008
+ const ignored = [
3009
+ ...["fix", "json", "preset", "profile", "canvas-light", "canvas-dark"].filter((name) => values[name] !== undefined && values[name] !== false).map((name) => `--${name}`),
3010
+ ...positionals.length > 0 ? ["a path"] : []
3011
+ ];
3012
+ if (ignored.length > 0) {
3013
+ throw new FlagError("--list-rules", `--list-rules takes only --config and --no-plugins or --lenient-plugins, not ${ignored.join(", ")}`);
3014
+ }
3015
+ }
3007
3016
  if (validating && positionals.length > 0) {
3008
3017
  throw new FlagError("files", "--validate-plugins runs no check, so it takes no files");
3009
3018
  }
@@ -3043,9 +3052,9 @@ var run = async (argv, cwd) => {
3043
3052
  throw new FlagError("files", "no matching files");
3044
3053
  if (values.fix)
3045
3054
  await refuseOutsideLinks(files, root, cwd);
3046
- const setAside = files.filter((file) => canvasSetAside(file, flags, registry));
3055
+ const setAside = files.filter((file) => canvasSetAside(file, flags, registry)).map((f) => display(f, cwd));
3047
3056
  if (setAside.length > 0) {
3048
- console.error(`mermaidjs-lint: config canvas set aside for ${plural(setAside.length, "file")} scored under mkdocs-material: ${setAside.map((f) => display(f, cwd)).join(", ")}`);
3057
+ console.error(`mermaidjs-lint: config canvas set aside for ${plural(setAside.length, "file")} scored under mkdocs-material: ${setAside.join(", ")}`);
3049
3058
  }
3050
3059
  const perFile = await Promise.all(files.map(async (file) => {
3051
3060
  let src = await readFile3(file, "utf8");
@@ -3068,7 +3077,7 @@ var run = async (argv, cwd) => {
3068
3077
  code: f.error.code,
3069
3078
  message: reasonOf(f)
3070
3079
  }));
3071
- console.log(JSON.stringify({ findings: all, files: files.length, plugins: registry.sources, skippedPlugins }, null, 2));
3080
+ console.log(JSON.stringify({ findings: all, files: files.length, plugins: registry.sources, skippedPlugins, canvasSetAside: setAside }, null, 2));
3072
3081
  } else {
3073
3082
  for (const f of all)
3074
3083
  console.log(reportLine(f, f.file));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpeakai/mermaidjs-lint",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "description": "Deterministic lint gates and verified fixers for Mermaid diagrams in markdown",
6
6
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -22,7 +22,7 @@ import { CATEGORIES, type Finding, type Rule } from "./rules/types.ts";
22
22
  // buried, and first in --help.
23
23
  const SYNOPSIS = `usage: mermaidjs-lint <path...> [--fix] [--json] [--preset NAME] [--profile NAME] [--config FILE]
24
24
  [--canvas-light COLOUR] [--canvas-dark COLOUR] [--no-plugins | --lenient-plugins]
25
- mermaidjs-lint --list-rules
25
+ mermaidjs-lint --list-rules [--config FILE] [--no-plugins | --lenient-plugins]
26
26
  mermaidjs-lint --validate-plugins [--json] [--config FILE]
27
27
  mermaidjs-lint --version | -h, --help`;
28
28
 
@@ -68,7 +68,7 @@ Plugins load on their own from .mermaidjs-lint/rules, from dependencies named me
68
68
  --lenient-plugins skips a plugin that fails to load and says so, instead of stopping the run.
69
69
  --validate-plugins imports and checks every plugin, reports every failure, and runs no check or fix.
70
70
  --list-rules prints every active rule by category, including plugin rules, and where each plugin came from.
71
- It imports the plugins to list them.
71
+ It imports the plugins to list them, and takes no path or other flag.
72
72
  --version prints the version, to quote in a bug report.
73
73
  Exits 0 when no findings remain, 1 when findings remain, a plugin fails to load or the run fails (a lenient run
74
74
  skips a broken plugin, so it alone does not exit 1), and 2 on a usage error.`;
@@ -246,6 +246,22 @@ const run = async (argv: string[], cwd: string): Promise<number> => {
246
246
  if (validating && (values["no-plugins"] || values.fix || listing)) {
247
247
  throw new FlagError("--validate-plugins", "--validate-plugins takes no --no-plugins, --fix or --list-rules");
248
248
  }
249
+ // --list-rules prints the rules the config and the plugin flags leave
250
+ // active. Any other flag or a path would be silently ignored, so it is refused.
251
+ if (listing && !validating) {
252
+ const ignored = [
253
+ ...(["fix", "json", "preset", "profile", "canvas-light", "canvas-dark"] as const)
254
+ .filter((name) => values[name] !== undefined && values[name] !== false)
255
+ .map((name) => `--${name}`),
256
+ ...(positionals.length > 0 ? ["a path"] : []),
257
+ ];
258
+ if (ignored.length > 0) {
259
+ throw new FlagError(
260
+ "--list-rules",
261
+ `--list-rules takes only --config and --no-plugins or --lenient-plugins, not ${ignored.join(", ")}`,
262
+ );
263
+ }
264
+ }
249
265
  if (validating && positionals.length > 0) {
250
266
  throw new FlagError("files", "--validate-plugins runs no check, so it takes no files");
251
267
  }
@@ -284,11 +300,12 @@ const run = async (argv: string[], cwd: string): Promise<number> => {
284
300
 
285
301
  // A config canvas is set aside for a file the auto profile reads as
286
302
  // mkdocs-material, and one line names every such file, so the run says what
287
- // it scored without the canvas.
288
- const setAside = files.filter((file) => canvasSetAside(file, flags, registry));
303
+ // it scored without the canvas. The --json object carries the same paths, so
304
+ // a job that reads only stdout still learns the canvas was dropped.
305
+ const setAside = files.filter((file) => canvasSetAside(file, flags, registry)).map((f) => display(f, cwd));
289
306
  if (setAside.length > 0) {
290
307
  console.error(
291
- `mermaidjs-lint: config canvas set aside for ${plural(setAside.length, "file")} scored under mkdocs-material: ${setAside.map((f) => display(f, cwd)).join(", ")}`,
308
+ `mermaidjs-lint: config canvas set aside for ${plural(setAside.length, "file")} scored under mkdocs-material: ${setAside.join(", ")}`,
292
309
  );
293
310
  }
294
311
 
@@ -321,7 +338,11 @@ const run = async (argv: string[], cwd: string): Promise<number> => {
321
338
  message: reasonOf(f),
322
339
  }));
323
340
  console.log(
324
- JSON.stringify({ findings: all, files: files.length, plugins: registry.sources, skippedPlugins }, null, 2),
341
+ JSON.stringify(
342
+ { findings: all, files: files.length, plugins: registry.sources, skippedPlugins, canvasSetAside: setAside },
343
+ null,
344
+ 2,
345
+ ),
325
346
  );
326
347
  } else {
327
348
  for (const f of all) console.log(reportLine(f, f.file));