Configuration
madr-lint is configured with a config file at the root of your project. A
TypeScript config (madr-lint.config.ts) is canonical; JSON is supported as a
fallback.
Config file resolution
Section titled “Config file resolution”The CLI looks for the first file that exists, in this order:
.madrlintrc.json.madrlintrc.ts.madrlintrc.mts.madrlintrc.js.madrlintrc.mjs.madrlintrc.cjsmadr-lint.config.tsmadr-lint.config.mtsmadr-lint.config.jsmadr-lint.config.mjsmadr-lint.config.cjs.json is parsed directly; every other extension is loaded through
jiti, so TypeScript and both module systems
work without a build step.
A TypeScript or JavaScript config provides the config object as its default
export (export default {...} or module.exports = {...}). A module without a
default export has its exports read as the config, so export const rules = {...} sets rules, but export const config = {...} is an unknown key (see
Unknown names).
Config files are code. A TypeScript/JavaScript config is executed when loaded — the same trust model as ESLint configs. Only run lints with
--configpaths or config files from sources you trust.
If you don’t set any rules and don’t pass --config, the CLI falls back to the
rules of the madr-lint:recommended preset so it is useful with zero config.
Other settings in a discovered config file, such as adrDir, still apply.
defineConfig
Section titled “defineConfig”Use the defineConfig helper for type-safe autocompletion. It is the identity
function at runtime.
import { defineConfig } from 'madr-lint';
export default defineConfig({ extends: ['madr-lint:recommended'], madrVersion: 'auto', adrDir: 'docs/adr', ignorePatterns: ['README.md', 'template.md'], rules: { 'madr/required-sections': 'error', 'madr/filename-format': ['error', { pattern: '^[0-9]{4}-.+\\.md$' }], 'madr/no-numbering-gap': 'off', },});The JSON equivalent (.madrlintrc.json):
{ "extends": ["madr-lint:recommended"], "madrVersion": "auto", "adrDir": "docs/adr", "ignorePatterns": ["README.md", "template.md"], "rules": { "madr/required-sections": "error", "madr/filename-format": ["error", { "pattern": "^[0-9]{4}-.+\\.md$" }], "madr/no-numbering-gap": "off" }}Top-level options
Section titled “Top-level options”| Option | Type | Default | Description |
|---|---|---|---|
extends | string[] | [] | Presets to extend. Currently 'madr-lint:recommended'. An unknown name is a config error (see Unknown names). |
madrVersion | 'v2' | 'v3' | 'v4' | 'auto' | 'auto' | Target MADR version. Selects where metadata is read from (see MADR version). auto detects per file. |
adrDir | string | 'docs/adr' | Directory linted when no paths are passed on the CLI. |
rules | Record<string, RuleSeverity> | {} | Per-rule severity and options (see below). |
ignorePatterns | string[] | [] | Paths to skip (see Ignore patterns). |
cache | boolean | true | Enable the per-file content-hash cache. |
cacheLocation | string | '.madr-lint/cache' | Directory for the cache manifest. |
The config must be an object, and any other top-level key is a config error (see Unknown names). Any value other than the ones listed in Invalid values is a config error too.
Configuring rules
Section titled “Configuring rules”Each entry in rules maps a rule name to either a severity string or a
tuple of [severity, options].
rules: { // severity only — uses the rule's default options 'madr/status-enum': 'error',
// turn a rule off 'madr/no-numbering-gap': 'off',
// severity + options 'madr/filename-format': ['error', { pattern: '^ADR-[0-9]+\\.md$' }],}Severities are 'error', 'warn', or 'off':
error— reported and makes the CLI exit with code1.warn— reported but does not fail the run.off— the rule does not run.
Any other severity is a config error (see Invalid values).
Options in the tuple are merged over the rule’s defaultOptions and validated
against the rule’s JSON Schema. Invalid options fail fast with a clear
message and exit code 2:
Invalid rule options in config: Invalid options for rule madr/filename-format: data/pattern must be stringUnknown names
Section titled “Unknown names”A top-level key that is not in the table above, a rule
name in rules that madr-lint does not know, or an extends entry that is not
a preset also fails with exit code 2. This includes a rule set to 'off' and
keys such as $schema. Inherited enumerable keys (Object.create({...}))
count like own keys, except enumerable properties that a dependency added to
Object.prototype. When a known name is close, the message suggests it.
Otherwise it lists the known keys or presets, or links to the
Rules reference. Every problem in the config is listed at once:
Invalid config (2 problems): - Unknown preset "madr-lint:recomended" in extends. Did you mean "madr-lint:recommended"? - Unknown rule "madr/status-enmu" in rules. Did you mean "madr/status-enum"?A misspelled top-level key is reported the same way:
Invalid config (2 problems): - Unknown key "adrdir" in the config. Did you mean "adrDir"? - Unknown key "rule" in the config. Did you mean "rules"?When a TypeScript or JavaScript config has no default export, the message can
end with one more line. If an unknown export looks like a config (its value is
an object with a known config key), the line names it and says to export it as
the default. For export const config = { rules: {...} }:
Unknown key "config" in the config. Known keys: "extends", "madrVersion", "adrDir", "rules", "ignorePatterns", "cache", "cacheLocation".The export "config" looks like a config. Export it as the default: `export default config` (ESM) or `module.exports = config` (CommonJS).If no export looks like a config, a module written in ESM syntax gets this line instead:
The config file has no default export, so its exports were read as the config.A plain CommonJS module.exports = {...} is its default export, so it gets no
extra line unless one of its keys looks like a config, as in
module.exports = { config: { rules: {...} } }. JSON configs and modules with a
default export never get either line.
Two keys that module interop adds are not config keys in a TypeScript or
JavaScript config: __esModule, and a default key that points back at the
config itself (module.exports = config; module.exports.default = config), or
at an object that is its own default, as when such a module is spread into the
config (export default { ...base }). In a JSON config, both are unknown keys.
A config that is not an object also fails with exit code 2. This covers a
function (export default () => ({...})), even one that carries config
properties such as a class with static fields, undefined
(export default undefined), null, an array, and a string or number:
The config must be an object, not a function.An async config (a Promise as the config, such as
export default (async () => ({...}))()) is not supported:
The config must be an object, not a Promise. Async configs are not supported: export the config object itself.With --config, the message starts with Failed to load config "<path>": .
Rule IDs starting with core/, such as core/internal-error, are reserved for
madr-lint’s own diagnostics and cannot be configured.
Invalid values
Section titled “Invalid values”A value that a key does not accept also fails with exit code 2. It is listed
in the same error as unknown names.
| Key | Accepted values |
|---|---|
adrDir, cacheLocation | A non-empty string |
ignorePatterns | A list of at most 10000 non-empty strings, even for one pattern |
cache | true or false |
Each value in rules | 'error', 'warn', 'off', or [severity, options] with an object as options (null, undefined, or false as options means the rule’s default options) |
null and undefined leave a top-level setting at its default. A rule set to
false, null, or undefined is a config error: write 'off' to turn a rule
off, as in ci ? 'error' : 'off'. When a severity is close to a valid one, the
message suggests it. ESLint’s numbers 0, 1, and 2, and false, get the
string to use instead:
Invalid config (3 problems): - Invalid ignorePatterns "0001-*": use a list of glob patterns, such as ["template.md"]. - Invalid severity "eror" for rule "madr/status-enum": use one of "error", "warn", "off". Did you mean "error"? - Invalid severity 2 for rule "madr/no-broken-links": use "error" instead.With --config, this message also starts with Failed to load config "<path>": .
The values are checked even when a command-line flag replaces them for the run,
such as paths given on the command line for adrDir, --cache-dir for
cacheLocation, or --no-cache for cache.
The contents of options are checked when the rule runs, as described in
Configuring rules.
See the Rules reference for the options each rule accepts.
Presets
Section titled “Presets”madr-lint:recommended
Section titled “madr-lint:recommended”Enables the spec-grounded rules at sensible severities. Extend it and override individual rules as needed.
| Rule | Recommended severity |
|---|---|
madr/required-sections | error |
madr/status-enum | error |
madr/date-iso8601 | error |
madr/filename-format | error |
madr/metadata-format | error |
madr/no-broken-links | error |
madr/no-duplicate-numbering | error |
madr/supersedes-bidirectional | error |
madr/no-numbering-gap | off (convention-only — opt in) |
Your rules entries are merged over the preset, so you only list what you
change:
export default defineConfig({ extends: ['madr-lint:recommended'], rules: { // adopt the numbering-gap convention 'madr/no-numbering-gap': 'warn', },});MADR version
Section titled “MADR version”madrVersion selects which MADR spec the rules validate against. It decides
two things: where metadata is read from, and which rules apply.
madrVersion | Metadata is read from | Version of each file |
|---|---|---|
auto (default) | YAML frontmatter and the body list, merged (frontmatter wins on conflict) | Detected: frontmatter with decision-makers ⇒ v4, other frontmatter with MADR fields ⇒ v3, body list ⇒ v2 |
v2 | The body list under the title only (* Status: / - **Status**:) | v2 |
v3 / v4 | YAML frontmatter only | v3 / v4 |
Metadata-reading rules such as madr/status-enum and madr/date-iso8601 read
the selected source. With v3 or v4, a status and date written in a body list
are not read, so madr/status-enum and madr/date-iso8601 report them as
missing. With v2, frontmatter is not
read. madr/metadata-format reports a file whose
metadata is in the format the configured version does not read. One case is
not reported: with v3 or v4, a body list next to MADR frontmatter counts as
body content, so its fields are not read and the rule stays silent.
A rule runs only for the versions it supports. madr/supersedes-bidirectional
supports v3 and v4, so it does not run with madrVersion: 'v2'. Under auto,
per-file rules skip files detected as an unsupported version, and cross-file
rules see every file so that references between files stay complete. A file
with no metadata has no detectable version, and every rule runs on it.
Use auto for a repository that mixes formats. Set a fixed version to hold
every ADR to one format.
JavaScript frontmatter
Section titled “JavaScript frontmatter”---js and ---javascript blocks are read as data and never executed. A block
must be a static object literal of strings, numbers, booleans, null, arrays,
and objects. Comments, unquoted keys, and trailing commas are allowed.
---js{ status: 'accepted', // reviewed in the architecture meeting date: '2026-11-04',}---Calls, variables, expressions, template literals, getters, methods, spread, and computed keys stop the lint with an error. Move those values to YAML frontmatter as plain values.
Ignore patterns
Section titled “Ignore patterns”ignorePatterns skips files by path. Patterns are matched with
picomatch, so common forms all work:
- exact basename —
README.md - full project-relative path —
docs/adr/template.md - path suffix —
adr/template.md - trailing wildcard —
9999-* - full glob —
docs/**/draft-*.md
export default defineConfig({ ignorePatterns: ['README.md', 'template.md', '9999-*', 'docs/**/draft-*.md'],});Write a list even for a single pattern. A bare string such as '0001-*' is a
config error.
A per-file content-hash cache speeds up re-runs. It is keyed by file content and invalidated when the package version or resolved config changes. Cross-file (project) rules always re-run.
export default defineConfig({ cache: true, // default cacheLocation: '.madr-lint/cache',});Disable it from the CLI with --no-cache, or point it elsewhere with
--cache-dir. A cacheLocation outside the working directory is ignored with a
warning; only --cache-dir can choose such a location. See the CLI reference.