@jpeakai/mermaidjs-lint 0.7.1 → 0.7.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/README.md +24 -21
- package/dist/bin.js +691 -578
- package/dist/index.js +691 -578
- package/dist/testing.js +471 -411
- package/dist/types/parse/contrast.d.ts +6 -1
- package/dist/types/parse/graph.d.ts +16 -0
- package/dist/types/rules/shared.d.ts +5 -1
- package/package.json +1 -1
- package/src/check.ts +13 -11
- package/src/cli.ts +153 -90
- package/src/files.ts +23 -18
- package/src/fix/engine.ts +82 -57
- package/src/fix/verify.ts +13 -8
- package/src/model.ts +1 -1
- package/src/parse/color.ts +1 -1
- package/src/parse/contrast.ts +308 -228
- package/src/parse/graph.ts +98 -0
- package/src/parse/metrics.ts +1 -1
- package/src/parse/stats.ts +111 -82
- package/src/plugins/discover.ts +13 -15
- package/src/plugins/index.ts +66 -37
- package/src/plugins/load.ts +94 -61
- package/src/rules/complexity.ts +1 -1
- package/src/rules/contrast-text-below-aa.ts +34 -21
- package/src/rules/parse-diagram-unparseable.ts +1 -1
- package/src/rules/parse-fence-unterminated.ts +5 -7
- package/src/rules/registry.ts +38 -16
- package/src/rules/shared.ts +8 -3
package/README.md
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
# mermaidjs-lint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
| **[Docs](https://jpeakai.github.io/jpai-mermaidjs-lint/)** | **[Rules](https://jpeakai.github.io/jpai-mermaidjs-lint/reference/rules/)** | **[Changelog](CHANGELOG.md)** | **[npm](https://www.npmjs.com/package/@jpeakai/mermaidjs-lint)** |
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
| Package Index | Published Version | Downloads | Node | CI | Docs | License |
|
|
6
|
+
|---|---|---|---|---|---|---|
|
|
7
|
+
| npm | [](https://www.npmjs.com/package/@jpeakai/mermaidjs-lint) | [](https://www.npmjs.com/package/@jpeakai/mermaidjs-lint) | [](https://github.com/jpeakai/jpai-mermaidjs-lint/blob/main/package.json) | [](https://github.com/jpeakai/jpai-mermaidjs-lint/actions/workflows/ci.yml) | [](https://jpeakai.github.io/jpai-mermaidjs-lint/) | [](https://github.com/jpeakai/jpai-mermaidjs-lint/blob/main/LICENSE) |
|
|
8
|
+
|
|
9
|
+
I hate walls of text. I do _**love**_ a good diagram though. mermaidjs is brilliant for separating the _**semantic structure**_ of a diagram from _**the pixel pushing**_.
|
|
10
|
+
|
|
11
|
+
AI Agents love this separation too. And yet AI Agents kind of suck at diagrams though. So here is a linting and autofixer engine built on top of:
|
|
12
|
+
- [`mermaid`](https://www.npmjs.com/package/mermaid) parsing libraries
|
|
13
|
+
- [`colorjs.io`](https://www.npmjs.com/package/colorjs.io) for official [WCAG 2.1](https://colorjs.io/docs/contrast#wcag-21) colour contrast readability scoring.
|
|
6
14
|
|
|
7
15
|
## Lint your docs with one command
|
|
8
16
|
|
|
9
17
|
```sh
|
|
18
|
+
# bunx
|
|
19
|
+
bunx @jpeakai/mermaidjs-lint docs/
|
|
20
|
+
bunx @jpeakai/mermaidjs-lint --fix docs/
|
|
21
|
+
|
|
22
|
+
# npx
|
|
10
23
|
npx -y @jpeakai/mermaidjs-lint docs/
|
|
24
|
+
npx -y @jpeakai/mermaidjs-lint --fix docs/
|
|
11
25
|
```
|
|
12
26
|
|
|
13
27
|
```text
|
|
@@ -31,30 +45,19 @@ Add `--fix` to apply the fixes that pass verification:
|
|
|
31
45
|
A fix is kept only if the markdown around the diagrams is unchanged and each diagram reparses with the same node ids, subgraphs and counts.
|
|
32
46
|
Edge endpoints, edge labels and node text are not compared, so review the diff.
|
|
33
47
|
|
|
34
|
-
## Four tenets
|
|
48
|
+
## Four tenets
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **Simple enough to follow.** Node count and visual complexity are scored against a density preset, so an oversized diagram is flagged to be split.
|
|
41
|
-
- **Extensible.** A plugin adds rules of your own, which run through the same config, fix engine and verification as the built-ins.
|
|
50
|
+
- **Always readable in light mode or dark mode.** Declared fills, label colours and borders are scored as the host draws them, on nodes, erDiagram rows, edge labels and sequence diagrams, in both themes.
|
|
51
|
+
- **It actually renders a valid diagram.** Every diagram parses with the mermaid parsers this package ships, and every mermaid fence is closed.
|
|
52
|
+
- **Visual Complexity stays readable.** Node count and visual complexity are scored against a density preset, so an oversized diagram is flagged to be split.
|
|
53
|
+
- **Make your own rules.** A plugin adds rules of your own, which run through the same config, fix engine and verification as the built-ins.
|
|
42
54
|
|
|
43
55
|
## Go further in the docs site
|
|
44
56
|
|
|
45
57
|
- [Get started](https://jpeakai.github.io/jpai-mermaidjs-lint/get-started/): run it, fix a diagram, and add the gate to your project.
|
|
46
|
-
- [
|
|
47
|
-
- [Configure the rules](https://jpeakai.github.io/jpai-mermaidjs-lint/guides/configure/)
|
|
48
|
-
|
|
49
|
-
## Use it from an AI agent
|
|
50
|
-
|
|
51
|
-
The agent skill in [`skills/mermaidjs-lint/SKILL.md`](skills/mermaidjs-lint/SKILL.md) runs the tool, applies the safe fixes, and fixes the rest by judgement.
|
|
52
|
-
Copy it into a Claude Code project:
|
|
53
|
-
|
|
54
|
-
```sh
|
|
55
|
-
curl -fsSL --create-dirs -o .claude/skills/mermaidjs-lint/SKILL.md \
|
|
56
|
-
https://raw.githubusercontent.com/jpeakai/jpai-mermaidjs-lint/main/skills/mermaidjs-lint/SKILL.md
|
|
57
|
-
```
|
|
58
|
+
- [Use it in CI](https://jpeakai.github.io/jpai-mermaidjs-lint/guides/ci/) or [before each commit](https://jpeakai.github.io/jpai-mermaidjs-lint/guides/pre-commit/).
|
|
59
|
+
- [Configure the rules](https://jpeakai.github.io/jpai-mermaidjs-lint/guides/configure/)
|
|
60
|
+
- [Write a project local rule](https://jpeakai.github.io/jpai-mermaidjs-lint/guides/local-rule/).
|
|
58
61
|
|
|
59
62
|
## Runs on Bun or Node
|
|
60
63
|
|