Shared markdownlint-cli2 configuration for DNBHQ projects.
npm install --save-dev @dnbhq/markdownlint-configThe package installs everything required to run markdownlint through markdownlint-cli2:
markdownlint-cli2markdownlint@github/markdownlint-githubmarkdownlint-rule-extended-asciimarkdownlint-rule-relative-linksmarkdownlint-rule-search-replacemarkdownlint-rule-title-case-style
Consuming projects do not need to install those packages separately.
This package is designed for markdownlint-cli2, not the older markdownlint CLI.
Run this configuration with the following call:
npx markdownlint-cli2 --config ./node_modules/@dnbhq/markdownlint-config/.markdownlint-cli2.jsonc README.mdAdd scripts to package.json in the consuming project:
{
"scripts": {
"lint:markdown": "markdownlint-cli2 --config ./node_modules/@dnbhq/markdownlint-config/.markdownlint-cli2.jsonc \"**/*.{md,mdx}\"",
"lint:markdown:fix": "markdownlint-cli2 --config ./node_modules/@dnbhq/markdownlint-config/.markdownlint-cli2.jsonc --fix \"**/*.{md,mdx}\""
}
}Do not put a markdownlint-cli2 options object into .markdownlint.jsonc. That file name is treated as a markdownlint rule configuration only. If a project needs CLI2-only fields such as customRules, globs, or ignores, use .markdownlint-cli2.jsonc.
The package also ships .markdownlintignore. Copy it into a consuming project when that project wants to use the same ignore baseline.
The npm package publishes these files:
.markdownlint-cli2.jsonc- the shared markdownlint-cli2 configuration.rules/*.cjs- custom rule loader wrappers used by markdownlint-cli2..markdownlintignore- the shared ignore baseline.README.md- package documentation.CHANGELOG.md- release history generated byrelease-it.LICENSE- MIT licence.
The shared rule config enables markdownlint defaults with default: true and then overrides selected rules for DNBHQ projects.
MD001enforces heading increments and recognises frontmatter titles viatitle:ortitle=.MD003requires ATX headings with#markers.MD020andMD021are disabled because closed ATX headings are not used.MD024disallows duplicate headings among siblings while allowing the same heading text in different nesting branches.MD043is disabled because projects do not share one fixed heading structure.
MD004requires*as the unordered list marker.MD005keeps indentation consistent for list items at the same level.MD007uses two spaces for nested list indentation.
MD013is disabled, so prose line length is unrestricted.MD044is disabled, so markdownlint does not enforce a fixed proper-name spelling list.MD059rejects generic link text:click here,here,link, andmore.GH002adds GitHub-style generic link-text checks withSomethingandClick hereas additional banned text.
MD033rejects inline HTML exceptlite-youtube,color-grid,date-diff, andkbd.- Inside tables,
MD033allows onlykbd. GH001rejects default image alt text.GH003rejects empty image alt text.
MD046requires fenced code blocks.MD048requires backtick fences instead of tilde fences.MD049requires*for emphasis.MD050requires**for strong text.
MD054disallows autolinks.MD055requires leading and trailing pipes for table rows.MD060requires compact table cell spacing.markdownlint-rule-relative-linkschecks relative links. The shared config usesroot_path: "."because consuming repositories can have different folder layouts.
MD035requires---when horizontal rules are used.
This only standardises the marker style. It does not mean horizontal rules should be used as visual separators in documentation.
markdownlint-rule-search-replace adds two checks:
ellipsisflags three literal dots in prose.curly-double-quotesflags curly double quotation marks and suggests straight double quotation marks.
markdownlint-rule-extended-ascii enforces ASCII-only Markdown content.
markdownlint-rule-title-case-style requires sentence case for headings and ignores JavaScript as an allowed spelling.
Dry run:
npm run release:dryRelease:
npm run releaseReleases are handled by release-it and @release-it/conventional-changelog.
Commit messages should follow Conventional Commits.
Publishing is handled by the Publish package GitHub Actions workflow when a v* tag is pushed. The workflow verifies that the tag matches package.json, runs the package tests, and publishes to npm.
- Consumers install only
@dnbhq/markdownlint-config; the package carries markdownlint-cli2, markdownlint, and all custom rules as direct dependencies. config.jsoncis a markdownlint-cli2 configuration file.rules.jsoncis a markdownlint rule configuration file.- Use
.markdownlint-cli2.jsoncin consuming projects whenever CLI2-only options such ascustomRules,globs, orignoresare needed. - The repository test command currently runs markdownlint-cli2 against this README with the shared config.