Skip to content

madr/required-sections

Enforces that an ADR Markdown file contains every heading listed in the sections option.

The rule walks the Markdown AST, collects the text of every heading (any level, with inline markup stripped via mdast-util-to-string, so ## **Status** matches Status), and reports one diagnostic for each required heading that is not present.

  • missingSection — a required heading is not found among the file’s headings. One diagnostic is emitted per missing section. The message is Missing required section: "<section>". The diagnostic carries data.section (the missing heading) and data.found (every heading text seen in the file, for debugging). It is a file-level diagnostic — there is no node to point at.

Heading matching is controlled by matchMode: exact requires the full trimmed heading to equal the required text; startsWith matches any heading that begins with the required text (e.g. Decision Outcome matches Decision Outcome (Architectural)).

A file with the three default required sections:

# ADR-0001: Use mise for runtime management
## Context and Problem Statement
...
## Considered Options
* ...
## Decision Outcome
Adopted: ...
# ADR-0001: Missing context
## Considered Options
* ...
## Decision Outcome
...

Emits 1 diagnostic: Missing required section: "Context and Problem Statement".

OptionTypeDefaultDescription
sectionsstring[]['Context and Problem Statement', 'Considered Options', 'Decision Outcome']Required heading texts. Order does not matter.
matchMode'exact' | 'startsWith''exact'How each required entry is compared against a heading. startsWith lets Decision Outcome (Architectural) satisfy Decision Outcome.
import { defineConfig } from 'madr-lint';
export default defineConfig({
rules: {
'madr/required-sections': ['error', {
sections: ['Context', 'Decision', 'Consequences'],
matchMode: 'startsWith',
}],
},
});
VersionApplies
v2yes
v3yes
v4yes

The default sections are the headings that the MADR templates do not mark as optional: v2 (2.1.2), v3 (3.0.0), v4 (4.0.0). They are the same in all three versions, so the defaults apply to v2/v3/v4 alike.

Consequences is not in the defaults. It is optional in v3/v4, and the v2 template uses Positive Consequences and Negative Consequences (both optional) instead. To require it, add it to sections.

Set madr/required-sections to off only when migrating an ADR collection that uses different section names. Prefer overriding sections (and/or switching to startsWith) to preserve some level of validation.

Like all rules, this rule can be suppressed inline — see Suppressing rules.