madr-lint 0.1.0 → 0.3.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 +46 -0
- package/README.md +21 -2
- package/dist/cli.js +636 -85
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +122 -10
- package/dist/index.js +373 -43
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#71](https://github.com/knktkc/madr-lint/pull/71) [`55e7b89`](https://github.com/knktkc/madr-lint/commit/55e7b89a5d1dc6c3109e04b02c082aadd713b701) Thanks [@knktkc](https://github.com/knktkc)! - Diagnostics now carry machine-actionable `suggestion` and `docsUrl` in the json/text/github output ([#67](https://github.com/knktkc/madr-lint/issues/67)). Error feedback is self-contained — expected vs actual plus a concrete fix and a docs link — so agents and humans repair violations without a separate doc lookup.
|
|
8
|
+
|
|
9
|
+
- **Rule meta** gains an optional declarative `suggestions` map (messageId → template), interpolated with the diagnostic data exactly like `messages`. Rules stay declarative — no imperative suggestion building. Declare an entry only where a mechanical fix exists; omit where the fix is contextual.
|
|
10
|
+
- **`Diagnostic`** gains `suggestion: string | null` (null when the rule defines none for that message) and `docsUrl: string` (the rule's `docs.url`; the repository for `core/internal-error`), both resolved by the runner at report time.
|
|
11
|
+
- **Reporters**: `text` renders an indented `→ <suggestion>` line under a diagnostic and prints the docs URL once per rule per file group (compact — never per diagnostic); `json` adds `suggestion` and `docsUrl` to every result (keys always present); `github` appends ` — <suggestion>` to the annotation message (escaped). `sarif` is unchanged — its `helpUri` already carries the docs URL.
|
|
12
|
+
- **All 8 rules audited**; suggestions filled where the remediation is mechanical (`required-sections`, `status-enum` missing status, `date-iso8601`, `filename-format`, `no-broken-links`, `no-duplicate-numbering`, `supersedes-bidirectional`) and omitted where contextual (`no-numbering-gap`; `status-enum` invalid status already lists the allowed values).
|
|
13
|
+
- **Fixed** `supersedes-bidirectional`'s `missingBackReference` message, which named the wrong declared field: it now renders the field the source file actually declares (`supersedes:` vs `superseded-by:`) and states the exact `field: value` back-reference to add.
|
|
14
|
+
- **Breaking (pre-1.0)**: `Diagnostic` gains two required fields — external code that **constructs** `Diagnostic` values must now supply `suggestion` (`string | null`) and `docsUrl` (`string`); consumers that only read diagnostics are unaffected (the keys are always present). The on-disk cache manifest also gains a schema version (`schemaVersion: 2`; missing/mismatched ⇒ cold), so the first run after upgrading re-lints once instead of serving stale-shape cached diagnostics.
|
|
15
|
+
|
|
16
|
+
Resolution is report-time only, so it stays zero-cost on clean files and free on the sub-microsecond hot path.
|
|
17
|
+
|
|
18
|
+
## 0.2.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [#54](https://github.com/knktkc/madr-lint/pull/54) [`d91e248`](https://github.com/knktkc/madr-lint/commit/d91e248928b68d5408d38de731986cbfa61174aa) Thanks [@knktkc](https://github.com/knktkc)! - Baseline file for gradual adoption ([#24](https://github.com/knktkc/madr-lint/issues/24)). Adopt `madr-lint` on a repo with existing violations without fixing them all first — `--update-baseline` snapshots today's violations to `.madr-lint/baseline.json`, and subsequent runs subtract them so only **new** violations fail the build.
|
|
23
|
+
|
|
24
|
+
- `madr-lint --update-baseline` writes the baseline (deterministic sorted JSON, POSIX-relative paths, 2-space indent + trailing newline for clean git diffs) and exits 0.
|
|
25
|
+
- Default runs subtract an existing baseline; `--no-baseline` ignores it and shows everything.
|
|
26
|
+
- Fingerprint = `(relative path, ruleName, messageId)` → allowed **count** (a tsc-baseline-style count model), so the baseline survives unrelated edits by construction — no line numbers, no message text. See [ADR-0007](https://github.com/knktkc/madr-lint/blob/main/docs/adr/0007-baseline-fingerprint-design.md).
|
|
27
|
+
- Subtraction runs after inline suppression and is never stored in the cache, so editing or deleting the baseline takes effect without cache invalidation (warm-cache runs still subtract). `core/internal-error` is never baselined.
|
|
28
|
+
- `--format json` gains `summary.baselineHidden` (always present, `0` when no baseline is active); SARIF output is unchanged. A present-but-malformed baseline file is ignored with a one-line stderr warning rather than silently.
|
|
29
|
+
- Programmatic API adds `buildBaseline`, `applyBaseline`, `loadBaseline`, `writeBaseline`, `serializeBaseline`, `baselinePath`, and the `Baseline` type.
|
|
30
|
+
|
|
31
|
+
- [#55](https://github.com/knktkc/madr-lint/pull/55) [`47624ad`](https://github.com/knktkc/madr-lint/commit/47624add4af8c611dd566993905457a27a826231) Thanks [@knktkc](https://github.com/knktkc)! - CLI ergonomics ([#27](https://github.com/knktkc/madr-lint/issues/27)): add `--quiet`, `--max-warnings <n>`, and `--config <path>` flags with ESLint-mirrored semantics.
|
|
32
|
+
|
|
33
|
+
- `--quiet` filters warnings from the **output** of every reporter (text/json/sarif/github); the unfiltered warning count still drives `--max-warnings`.
|
|
34
|
+
- `--max-warnings <n>` exits 1 when warnings exceed n (`0` valid; negative/absent = no limit). When the threshold fails the run, a one-line verdict is printed to **stderr** for every format, and the text reporter never shows "All clear" beside a failing exit code. Baselined warnings do not count toward the threshold.
|
|
35
|
+
- `--config <path>` loads exactly that config file (TS or JSON), bypassing discovery; a missing file, a directory, or an invalid config exits 2 with a clear message.
|
|
36
|
+
|
|
37
|
+
- [#58](https://github.com/knktkc/madr-lint/pull/58) [`e6008a8`](https://github.com/knktkc/madr-lint/commit/e6008a8ec76494aa22364f7d262696d52fd59dad) Thanks [@knktkc](https://github.com/knktkc)! - Add `--format github` reporter that emits GitHub Actions workflow commands (`::error` / `::warning`) for PR diff annotations; add `action.yml` composite action and dogfood smoke workflow.
|
|
38
|
+
|
|
39
|
+
- [#53](https://github.com/knktkc/madr-lint/pull/53) [`be2456e`](https://github.com/knktkc/madr-lint/commit/be2456e6e1fc34c8b295168effe54740210fbcb2) Thanks [@knktkc](https://github.com/knktkc)! - Inline suppression comments ([#23](https://github.com/knktkc/madr-lint/issues/23)). ADR bodies can now silence diagnostics with HTML-comment directives, filtered centrally so rules stay unaware:
|
|
40
|
+
|
|
41
|
+
- `<!-- madr-lint-disable-file -->` — suppress everything in the file
|
|
42
|
+
- `<!-- madr-lint-disable -->` … `<!-- madr-lint-enable -->` — suppress a range (or to EOF when left open)
|
|
43
|
+
- `<!-- madr-lint-disable-next-line -->` — suppress the next non-blank line
|
|
44
|
+
|
|
45
|
+
Each form takes an optional comma-separated rule-id list (no list = all rules). To make line-scoped suppression work against real rules, `madr/no-broken-links` diagnostics now carry the link's position, and `madr/status-enum` / `madr/date-iso8601` carry the metadata list item's position when the value comes from the MADR v2 list (frontmatter-sourced values stay line-less). `ParsedFile`/`RuleContext` gain `metadataLoc`. `core/internal-error` diagnostics are never suppressible.
|
|
46
|
+
|
|
47
|
+
**Breaking (pre-1.0)**: the public `ProjectFile` type gains a required `body` field. Code that constructs `ProjectFile` objects by hand must now populate it — use `buildProjectFile()`, which handles it. Consumers that only read `ProjectFile` values are unaffected.
|
|
48
|
+
|
|
3
49
|
All notable changes to `madr-lint` are recorded here. Releases are managed via
|
|
4
50
|
[changesets](https://github.com/changesets/changesets); each entry below
|
|
5
51
|
corresponds to a published npm version.
|
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
[Getting started](https://knktkc.github.io/madr-lint/guides/getting-started/) ·
|
|
16
16
|
[Rules](https://knktkc.github.io/madr-lint/rules/)
|
|
17
17
|
|
|
18
|
+
<sub>For AI agents: [llms.txt](https://knktkc.github.io/madr-lint/llms.txt) indexes the docs; [llms-full.txt](https://knktkc.github.io/madr-lint/llms-full.txt) has the full text in one fetch; the [AI agents guide](https://knktkc.github.io/madr-lint/guides/ai-agents/) covers the ready-made [`adopt-madr-lint`](https://github.com/knktkc/madr-lint/blob/main/skills/adopt-madr-lint/SKILL.md) / [`new-adr`](https://github.com/knktkc/madr-lint/blob/main/skills/new-adr/SKILL.md) skills.</sub>
|
|
19
|
+
|
|
18
20
|
</div>
|
|
19
21
|
|
|
20
22
|
A fast, configurable linter for [MADR](https://adr.github.io/madr/) (Markdown Architectural Decision Records). It validates the things a plain Markdown linter can't: required sections, a valid status, ISO-8601 dates, filename convention, and cross-file integrity like unique numbering and non-broken links — across MADR **v2, v3, and v4**.
|
|
@@ -41,7 +43,8 @@ A fast, configurable linter for [MADR](https://adr.github.io/madr/) (Markdown Ar
|
|
|
41
43
|
- **MADR v2 / v3 / v4 aware** — reads YAML frontmatter *and* v2 body-list metadata (both `- **Status**:` and canonical `* Status:`), or auto-detects per file.
|
|
42
44
|
- **ESLint-style rules** — named `madr/*` rules with `error` / `warn` / `off` and per-rule options validated by a JSON Schema.
|
|
43
45
|
- **Per-file & cross-file** — fast single-pass checks plus project rules for unique numbering, the supersedes graph, and link rot.
|
|
44
|
-
- **CLI, library & CI** — `text` / `json` / `sarif` reporters, a programmatic API, and a drop-in GitHub Actions step.
|
|
46
|
+
- **CLI, library & CI** — `text` / `json` / `sarif` / `github` reporters, a programmatic API, and a drop-in GitHub Actions step.
|
|
47
|
+
- **Gradual adoption** — [inline suppression comments](https://knktkc.github.io/madr-lint/guides/suppressing-rules/) for one-off exceptions and a [baseline file](https://knktkc.github.io/madr-lint/guides/adopting-existing-repo/) to snapshot legacy debt so only new violations fail the build.
|
|
45
48
|
|
|
46
49
|
## Install
|
|
47
50
|
|
|
@@ -64,7 +67,7 @@ npx madr-lint docs/adr libs/x/adr
|
|
|
64
67
|
npx madr-lint --format sarif > madr-lint.sarif
|
|
65
68
|
```
|
|
66
69
|
|
|
67
|
-
Exit code: `0` clean · `1` on
|
|
70
|
+
Exit code: `0` clean · `1` on error-level diagnostics or an exceeded `--max-warnings` threshold · `2` on a config problem.
|
|
68
71
|
|
|
69
72
|
## Configure
|
|
70
73
|
|
|
@@ -104,13 +107,29 @@ Rule values are a severity (`'error' | 'warn' | 'off'`) or a `[severity, options
|
|
|
104
107
|
|
|
105
108
|
## Use in CI
|
|
106
109
|
|
|
110
|
+
`madr-lint` ships a composite GitHub Action that annotates the PR diff directly:
|
|
111
|
+
|
|
107
112
|
```yaml
|
|
108
113
|
# .github/workflows/adr-lint.yml
|
|
109
114
|
jobs:
|
|
110
115
|
madr-lint:
|
|
111
116
|
runs-on: ubuntu-latest
|
|
117
|
+
permissions:
|
|
118
|
+
contents: read
|
|
112
119
|
steps:
|
|
113
120
|
- uses: actions/checkout@v4
|
|
121
|
+
- uses: actions/setup-node@v4
|
|
122
|
+
with: { node-version: 22 } # madr-lint requires Node ≥22
|
|
123
|
+
- uses: knktkc/madr-lint@v0
|
|
124
|
+
with: { path: docs/adr }
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
> The floating `v0` tag is published alongside the v0.2.0 release. If it isn't
|
|
128
|
+
> available yet, use `@main` (or pin an exact tag like `@v0.2.0`).
|
|
129
|
+
|
|
130
|
+
Or run it via `npx` in any CI provider:
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
114
133
|
- uses: actions/setup-node@v4
|
|
115
134
|
with: { node-version: 22 }
|
|
116
135
|
- run: npx madr-lint
|