markdownlint-rule-extra-fixes
v0.4.2
Published
Custom markdownlint rules that add fixInfo for MD040 and other rules the core does not fix
Maintainers
Readme
markdownlint-rule-extra-fixes
Custom markdownlint rules that provide fixInfo for rules the core does not auto-fix. Use with markdownlint-cli2 --fix to apply fixes.
Install
Install markdownlint-cli2 (if not already in your project) and the plugin using one of the options below.
From npm (when the package is published):
npm install markdownlint-cli2 markdownlint-rule-extra-fixes
# or: yarn add / pnpm addLocally (same repo / monorepo)
No install step: point customRules at the package path. In .markdownlint-cli2.jsonc at the repo root:
"customRules": ["./packages/markdownlint-rule-extra-fixes"]Paths are resolved from the config file’s directory. No npm install of the plugin is required.
From a Git repo (internal or public)
Install directly from the repository URL. Replace with your org/repo and optional branch/tag:
# npm (repo root = this package)
npm install markdownlint-cli2 markdownlint-rule-extra-fixes@git+https://gitlab.cee.redhat.com/your-org/markdownlint-fix.git#main
# npm (monorepo: package in subdirectory — use ?subdir=)
npm install markdownlint-cli2 'markdownlint-rule-extra-fixes@git+https://gitlab.cee.redhat.com/your-org/markdownlint-fix.git#main?subdir=packages/markdownlint-rule-extra-fixes'
# yarn
yarn add markdownlint-cli2 'markdownlint-rule-extra-fixes@git+https://gitlab.cee.redhat.com/your-org/markdownlint-fix.git#main'
# pnpm
pnpm add markdownlint-cli2 'markdownlint-rule-extra-fixes@git+https://gitlab.cee.redhat.com/your-org/markdownlint-fix.git#main'Use #branch, #tag, or #commit in place of #main as needed. For a private repo, ensure your environment has access (e.g. SSH key, token, or .npmrc auth).
Alternative (any package manager): clone the repo and install from the local path:
git clone https://gitlab.cee.redhat.com/your-org/markdownlint-fix.git
cd your-project
npm install markdownlint-cli2 ./markdownlint-fix/packages/markdownlint-rule-extra-fixesThen use the package name markdownlint-rule-extra-fixes in customRules as usual.
Usage
Add the package to customRules in your markdownlint config (e.g. .markdownlint-cli2.jsonc):
{
"config": { ... },
"customRules": [ "markdownlint-rule-extra-fixes" ]
}Then run:
npx markdownlint-cli2 --fix "**/*.md"Fixes from these rules are applied together with markdownlint's built-in fixes. Disable the corresponding built-in rule when using a -fix rule to avoid duplicate violations.
Rules
| Rule | Description | Config |
|------------|-------------|--------|
| MD013-fix | Line length. Wraps paragraphs, list items, blockquotes. | line_length (default: 80) |
| MD033-fix | No inline HTML. Converts common tags to markdown, wraps rest in backticks. | convert_elements, quote_remaining_as_code |
| MD036-fix | Emphasis as heading. Converts a line that is only **Bold** / *Italic* into a heading. | heading_level (default: 2) |
| MD040-fix | Fenced code language. Inserts default or inferred language after opening fence. | default_language, infer_language |
| MD041-fix | First line heading. Prepends a top-level heading when missing. | default_heading (default: "Document") |
| MD042-fix | No empty links. Replaces empty ]( ) / ](#) with a URL. | url_placeholder (default: "fixme_url") |
| MD047-fix | Trailing newline. Ensures file ends with a single newline. | — |
Config example
{
"config": {
"MD040": false,
"MD040-fix": {
"default_language": "text",
"infer_language": true
},
"MD041": false,
"MD041-fix": { "default_heading": "Document" },
"MD042": false,
"MD042-fix": { "url_placeholder": "fixme_url" },
"MD036": false,
"MD036-fix": { "heading_level": 2 },
"MD033": false,
"MD033-fix": { "quote_remaining_as_code": true },
"MD013": false,
"MD013-fix": { "line_length": 80 },
"MD047": false,
"MD047-fix": true
},
"customRules": [ "markdownlint-rule-extra-fixes" ]
}Development
From the package directory:
npm install
npm testRelated
- markdownlint – core linter
- markdownlint-cli2 – CLI with
--fixandcustomRules - markdownlintfix – standalone CLI that applies additional fixers (same logic, different delivery)
