madr-lint 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to `madr-lint` are recorded here. Releases are managed via
4
+ [changesets](https://github.com/changesets/changesets); each entry below
5
+ corresponds to a published npm version.
6
+
7
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
8
+ the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
+ Pre-1.0 releases (`0.x`) treat minor bumps as potentially breaking.
10
+
11
+ ## 0.1.0
12
+
13
+ ### Minor Changes
14
+
15
+ - Initial public release of **madr-lint** — the MADR-native linter for the JS/TS ecosystem.
16
+
17
+ - MADR **v2 / v3 / v4** aware: reads YAML frontmatter and v2 body-list metadata (bold `- **Status**:` and canonical `* Status:`), or auto-detects per file.
18
+ - **8 rules** with ESLint-style names, `error`/`warn`/`off` severities, and per-rule options validated by a JSON Schema: `required-sections`, `status-enum`, `date-iso8601`, `filename-format`, `no-broken-links`, `no-duplicate-numbering`, `no-numbering-gap`, `supersedes-bidirectional`.
19
+ - **CLI** with `text` / `json` / `sarif` reporters, multi-path input, TypeScript config, picomatch ignore globs, and a per-file content-hash cache.
20
+ - **Programmatic API** (`runRulesOnFile`, `runRulesOnProject`, `parseFile`, …) and a `recommended` preset.
21
+ - Bilingual documentation site (English / 日本語).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 t.kaneko (knktkc)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ <div align="center">
2
+
3
+ <img src="assets/banner.svg" alt="madr-lint — the MADR-native linter for the JS/TS ecosystem" width="820">
4
+
5
+ <br>
6
+
7
+ [![npm](https://img.shields.io/npm/v/madr-lint?color=4f46e5&label=npm)](https://www.npmjs.com/package/madr-lint)
8
+ [![CI](https://github.com/knktkc/madr-lint/actions/workflows/ci.yml/badge.svg)](https://github.com/knktkc/madr-lint/actions/workflows/ci.yml)
9
+ [![Provenance](https://img.shields.io/badge/npm-provenance-22c55e?logo=npm)](https://docs.npmjs.com/generating-provenance-statements)
10
+ [![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)
11
+ [![Node](https://img.shields.io/node/v/madr-lint.svg)](https://nodejs.org/)
12
+
13
+ **[Documentation](https://knktkc.github.io/madr-lint/)** ·
14
+ **[日本語ドキュメント](https://knktkc.github.io/madr-lint/ja/)** ·
15
+ [Getting started](https://knktkc.github.io/madr-lint/guides/getting-started/) ·
16
+ [Rules](https://knktkc.github.io/madr-lint/rules/)
17
+
18
+ </div>
19
+
20
+ 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**.
21
+
22
+ <div align="center">
23
+
24
+ <img src="assets/demo.svg" alt="madr-lint terminal output: two errors in an ADR, one clean file" width="760">
25
+
26
+ </div>
27
+
28
+ ## Why madr-lint
29
+
30
+ [MADR](https://github.com/adr/madr) ships no official linter, and the general-purpose tools each cover only part of what an ADR collection needs:
31
+
32
+ | Tool | Markdown style | Inter-doc links | ADR numbering | Status enum | Date format | Supersedes graph | v2 bold-list |
33
+ |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
34
+ | [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) | ✅ | — | — | — | — | — | n/a |
35
+ | [lychee](https://github.com/lycheeverse/lychee) | — | ✅ | — | — | — | — | n/a |
36
+ | [adrs (rust)](https://crates.io/crates/adrs) | — | — | ✅&nbsp;(init) | — | — | ~ | — |
37
+ | **madr-lint** | —¹ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
38
+
39
+ ¹ Deliberately *not* Markdown style — pair it with `markdownlint-cli2` if you want both. `madr-lint` owns the ADR-specific semantics.
40
+
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
+ - **ESLint-style rules** — named `madr/*` rules with `error` / `warn` / `off` and per-rule options validated by a JSON Schema.
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.
45
+
46
+ ## Install
47
+
48
+ ```bash
49
+ npm install --save-dev madr-lint # or: pnpm add -D madr-lint / yarn add -D madr-lint
50
+ ```
51
+
52
+ Node.js 22+. ESM-only. Ships TypeScript types.
53
+
54
+ ## Quick start
55
+
56
+ ```bash
57
+ # Lint the configured adrDir (default: docs/adr)
58
+ npx madr-lint
59
+
60
+ # Explicit paths (files or directories; directories are searched recursively)
61
+ npx madr-lint docs/adr libs/x/adr
62
+
63
+ # Machine-readable output for CI
64
+ npx madr-lint --format sarif > madr-lint.sarif
65
+ ```
66
+
67
+ Exit code: `0` clean · `1` on `error`-level diagnostics · `2` on a config problem.
68
+
69
+ ## Configure
70
+
71
+ A `madr-lint.config.ts` (or `.madrlintrc.json`) at your project root:
72
+
73
+ ```typescript
74
+ import { defineConfig } from 'madr-lint';
75
+
76
+ export default defineConfig({
77
+ extends: ['madr-lint:recommended'],
78
+ madrVersion: 'auto',
79
+ adrDir: 'docs/adr',
80
+ ignorePatterns: ['**/template.md', '9999-*'],
81
+ rules: {
82
+ 'madr/filename-format': ['error', { pattern: '^[0-9]{4}-.+\\.md$' }],
83
+ 'madr/no-numbering-gap': 'off',
84
+ },
85
+ });
86
+ ```
87
+
88
+ Rule values are a severity (`'error' | 'warn' | 'off'`) or a `[severity, options]` tuple. Options are validated — an invalid option fails fast with exit code `2`. Full reference: **[Configuration](https://knktkc.github.io/madr-lint/guides/configuration/)**.
89
+
90
+ ## Rules
91
+
92
+ 8 rules — 7 enabled by `recommended`, 1 opt-in. Each page documents its options, examples, and MADR-version compatibility.
93
+
94
+ | Rule | Type | Default | Checks |
95
+ |---|---|:---:|---|
96
+ | [`madr/required-sections`](https://knktkc.github.io/madr-lint/rules/required-sections/) | per-file | `error` | Required heading sections are present |
97
+ | [`madr/status-enum`](https://knktkc.github.io/madr-lint/rules/status-enum/) | per-file | `error` | `status` is one of the allowed values |
98
+ | [`madr/date-iso8601`](https://knktkc.github.io/madr-lint/rules/date-iso8601/) | per-file | `error` | `date` is a valid ISO-8601 calendar date |
99
+ | [`madr/filename-format`](https://knktkc.github.io/madr-lint/rules/filename-format/) | per-file | `error` | Filename matches the ADR convention |
100
+ | [`madr/no-broken-links`](https://knktkc.github.io/madr-lint/rules/no-broken-links/) | project | `error` | Relative links resolve to existing files |
101
+ | [`madr/no-duplicate-numbering`](https://knktkc.github.io/madr-lint/rules/no-duplicate-numbering/) | project | `error` | ADR numbers are unique |
102
+ | [`madr/supersedes-bidirectional`](https://knktkc.github.io/madr-lint/rules/supersedes-bidirectional/) | project | `error` | `supersedes` / `superseded-by` agree |
103
+ | [`madr/no-numbering-gap`](https://knktkc.github.io/madr-lint/rules/no-numbering-gap/) | project | `off` | ADR numbers are contiguous (opt-in) |
104
+
105
+ ## Use in CI
106
+
107
+ ```yaml
108
+ # .github/workflows/adr-lint.yml
109
+ jobs:
110
+ madr-lint:
111
+ runs-on: ubuntu-latest
112
+ steps:
113
+ - uses: actions/checkout@v4
114
+ - uses: actions/setup-node@v4
115
+ with: { node-version: 22 }
116
+ - run: npx madr-lint
117
+ ```
118
+
119
+ The `sarif` reporter integrates with GitHub code scanning — see **[GitHub Action](https://knktkc.github.io/madr-lint/guides/github-action/)**.
120
+
121
+ ## Programmatic API
122
+
123
+ ```typescript
124
+ import { runRulesOnFile, buildProjectFile, rules } from 'madr-lint';
125
+
126
+ const diagnostics = runRulesOnFile(
127
+ [rules.requiredSections, rules.statusEnum],
128
+ { path: '0001-x.md', content },
129
+ { severity: 'error' },
130
+ );
131
+ ```
132
+
133
+ Full surface: **[Programmatic API](https://knktkc.github.io/madr-lint/guides/api/)**.
134
+
135
+ ## Pairs well with
136
+
137
+ `madr-lint` intentionally skips Markdown *style* — compose it:
138
+
139
+ ```bash
140
+ markdownlint-cli2 'docs/adr/**/*.md' # Markdown style
141
+ lychee 'docs/adr/**/*.md' # external link rot
142
+ madr-lint docs/adr # ADR structure + inter-ADR links
143
+ ```
144
+
145
+ ## Status
146
+
147
+ **Alpha.** Self-dogfooded (this repo lints its own ADRs) and validated against an external repository. Until 1.0, treat each minor bump as potentially breaking; the 1.0 gate is adoption feedback.
148
+
149
+ ## Contributing
150
+
151
+ Issues and PRs welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for the dev setup, rule-shape guide, and TDD/changeset workflow. The project dogfoods its own linter against its own ADRs in [`docs/adr/`](docs/adr/).
152
+
153
+ ## License
154
+
155
+ [MIT](LICENSE) © t.kaneko
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }