madr-lint 0.1.0 → 0.2.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,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
9
+ - `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.
10
+ - Default runs subtract an existing baseline; `--no-baseline` ignores it and shows everything.
11
+ - 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).
12
+ - 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.
13
+ - `--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.
14
+ - Programmatic API adds `buildBaseline`, `applyBaseline`, `loadBaseline`, `writeBaseline`, `serializeBaseline`, `baselinePath`, and the `Baseline` type.
15
+
16
+ - [#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.
17
+
18
+ - `--quiet` filters warnings from the **output** of every reporter (text/json/sarif/github); the unfiltered warning count still drives `--max-warnings`.
19
+ - `--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.
20
+ - `--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.
21
+
22
+ - [#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.
23
+
24
+ - [#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:
25
+
26
+ - `<!-- madr-lint-disable-file -->` — suppress everything in the file
27
+ - `<!-- madr-lint-disable -->` … `<!-- madr-lint-enable -->` — suppress a range (or to EOF when left open)
28
+ - `<!-- madr-lint-disable-next-line -->` — suppress the next non-blank line
29
+
30
+ 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.
31
+
32
+ **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.
33
+
3
34
  All notable changes to `madr-lint` are recorded here. Releases are managed via
4
35
  [changesets](https://github.com/changesets/changesets); each entry below
5
36
  corresponds to a published npm version.
package/README.md CHANGED
@@ -41,7 +41,8 @@ A fast, configurable linter for [MADR](https://adr.github.io/madr/) (Markdown Ar
41
41
  - **MADR v2 / v3 / v4 aware** — reads YAML frontmatter *and* v2 body-list metadata (both `- **Status**:` and canonical `* Status:`), or auto-detects per file.
42
42
  - **ESLint-style rules** — named `madr/*` rules with `error` / `warn` / `off` and per-rule options validated by a JSON Schema.
43
43
  - **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.
44
+ - **CLI, library & CI** — `text` / `json` / `sarif` / `github` reporters, a programmatic API, and a drop-in GitHub Actions step.
45
+ - **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
46
 
46
47
  ## Install
47
48
 
@@ -64,7 +65,7 @@ npx madr-lint docs/adr libs/x/adr
64
65
  npx madr-lint --format sarif > madr-lint.sarif
65
66
  ```
66
67
 
67
- Exit code: `0` clean · `1` on `error`-level diagnostics · `2` on a config problem.
68
+ Exit code: `0` clean · `1` on error-level diagnostics or an exceeded `--max-warnings` threshold · `2` on a config problem.
68
69
 
69
70
  ## Configure
70
71
 
@@ -104,13 +105,29 @@ Rule values are a severity (`'error' | 'warn' | 'off'`) or a `[severity, options
104
105
 
105
106
  ## Use in CI
106
107
 
108
+ `madr-lint` ships a composite GitHub Action that annotates the PR diff directly:
109
+
107
110
  ```yaml
108
111
  # .github/workflows/adr-lint.yml
109
112
  jobs:
110
113
  madr-lint:
111
114
  runs-on: ubuntu-latest
115
+ permissions:
116
+ contents: read
112
117
  steps:
113
118
  - uses: actions/checkout@v4
119
+ - uses: actions/setup-node@v4
120
+ with: { node-version: 22 } # madr-lint requires Node ≥22
121
+ - uses: knktkc/madr-lint@v0
122
+ with: { path: docs/adr }
123
+ ```
124
+
125
+ > The floating `v0` tag is published alongside the v0.2.0 release. If it isn't
126
+ > available yet, use `@main` (or pin an exact tag like `@v0.2.0`).
127
+
128
+ Or run it via `npx` in any CI provider:
129
+
130
+ ```yaml
114
131
  - uses: actions/setup-node@v4
115
132
  with: { node-version: 22 }
116
133
  - run: npx madr-lint