A specialized ESLint plugin that helps enforce consistent writing style and formatting conventions in Markdown files. Perfect for documentation projects, blog posts, and any Markdown content where consistency matters.
- π Comprehensive style enforcement Enforces consistent heading casing, table header casing, inline code/link usage, emoji notation, and more for unified document style.
- π§© Powerful formatting consistency Strongly standardizes Markdown formatting: whitespace, indentation, spacing, line breaks, list markers, code fences, links, references, thematic breaks, tables, and decorative elementsβensuring documents are clean and uniform.
- π Extended Markdown syntax support Supports custom containers, mathematical expressions, and other extended syntax for high compatibility with VitePress.
- π§ Auto-fix support
Most rules support ESLint's
--fixoption for automatic correction. - π Online Demo & Documentation Try it instantly in the Online Demo and see full documentation.
For detailed usage instructions, rule configurations, and examples, visit our comprehensive documentation site.
npm install --save-dev eslint @eslint/markdown eslint-plugin-markdown-preferencesUse eslint.config.js file to configure rules. See also: https://eslint.org/docs/latest/use/configure/configuration-files-new.
Example eslint.config.js:
import { defineConfig } from "eslint/config";
// import markdown from "@eslint/markdown";
import markdownPreferences from "eslint-plugin-markdown-preferences";
export default defineConfig([
// add more generic rule sets here, such as:
// markdown.configs.recommended,
markdownPreferences.configs.recommended,
{
files: ["**/*.md", "*.md"],
rules: {
// override/add rules settings here, such as:
// 'markdown-preferences/prefer-linked-words': 'error'
},
},
]);This plugin provides configs:
*.configs.recommended... Recommended config provided by the plugin.*.configs.standard... Enforces opinionated stylistic conventions. You can extend this to enforce any stylistic conventions you like.
See the rule list to get the rules that this plugin provides.
This plugin experimentally supports some extended Markdown syntax.
To use these extended syntaxes, set the markdown-preferences/extended-syntax language option.
import { defineConfig } from "eslint/config";
import markdownPreferences from "eslint-plugin-markdown-preferences";
export default defineConfig([
{
extends: [markdownPreferences.configs.recommended],
language: "markdown-preferences/extended-syntax",
},
]);The following syntaxes are supported:
-
Custom Containers
Example:::: warning This is a warning box. :::
-
Mathematical Expressions
Example:$$ E = mc^2 $$
-
VitePress-style Import Code Snippets syntax using triple left angle brackets
Example:<<< @/filepath
Is not supported.
The --fix option on the command line automatically fixes problems reported by rules which have a wrench π§ below.
The rules with the following β are included in the recommended config.
The rules with the following π are included in the standard config.
- Rules to unify the expression and description style of documents.
| Rule ID | Description | Fixable | Config |
|---|---|---|---|
| markdown-preferences/canonical-code-block-language | enforce canonical language names in code blocks | π§ | |
| markdown-preferences/emoji-notation | enforce consistent emoji notation style in Markdown files. | π§ | |
| markdown-preferences/heading-casing | enforce consistent casing in headings. | π§ | |
| markdown-preferences/ordered-list-marker-start | enforce that ordered list markers start with 1 or 0 | π§ | π |
| markdown-preferences/prefer-inline-code-words | enforce the use of inline code for specific words. | π§ | |
| markdown-preferences/prefer-linked-words | enforce the specified word to be a link. | π§ | |
| markdown-preferences/table-header-casing | enforce consistent casing in table header cells. | π§ |
- Rules related to notation styles in Markdown.
| Rule ID | Description | Fixable | Config |
|---|---|---|---|
| markdown-preferences/bullet-list-marker-style | enforce consistent bullet list (unordered list) marker style | π§ | π |
| markdown-preferences/code-fence-style | enforce a consistent code fence style (backtick or tilde) in Markdown fenced code blocks. | π§ | π |
| markdown-preferences/definitions-last | require link definitions and footnote definitions to be placed at the end of the document | π§ | |
| markdown-preferences/emphasis-delimiters-style | enforce a consistent delimiter style for emphasis and strong emphasis | π§ | π |
| markdown-preferences/hard-linebreak-style | enforce consistent hard linebreak style. | π§ | βπ |
| markdown-preferences/level1-heading-style | enforce consistent style for level 1 headings | π§ | π |
| markdown-preferences/level2-heading-style | enforce consistent style for level 2 headings | π§ | π |
| markdown-preferences/link-destination-style | enforce a consistent style for link destinations | π§ | π |
| markdown-preferences/link-title-style | enforce a consistent style for link titles | π§ | π |
| markdown-preferences/no-implicit-block-closing | disallow implicit block closing for fenced code blocks, math blocks, and custom containers | π§ | βπ |
| markdown-preferences/no-text-backslash-linebreak | disallow text backslash at the end of a line. | βπ | |
| markdown-preferences/ordered-list-marker-style | enforce consistent ordered list marker style | π§ | π |
| markdown-preferences/prefer-autolinks | enforce the use of autolinks for URLs | π§ | βπ |
| markdown-preferences/prefer-fenced-code-blocks | enforce the use of fenced code blocks over indented code blocks | π§ | βπ |
| markdown-preferences/prefer-link-reference-definitions | enforce using link reference definitions instead of inline links | π§ | |
| markdown-preferences/strikethrough-delimiters-style | enforce a consistent delimiter style for strikethrough | π§ | π |
| markdown-preferences/thematic-break-character-style | enforce consistent character style for thematic breaks (horizontal rules) in Markdown. | π§ | π |
- Rules related to whitespace styles in Markdown.
| Rule ID | Description | Fixable | Config |
|---|---|---|---|
| markdown-preferences/blockquote-marker-alignment | enforce consistent alignment of blockquote markers | π§ | βπ |
| markdown-preferences/code-fence-spacing | require or disallow spacing between opening code fence and language identifier | π§ | π |
| markdown-preferences/custom-container-marker-spacing | require or disallow spacing between opening custom container marker and info | π§ | π |
| markdown-preferences/indent | enforce consistent indentation in Markdown files | π§ | π |
| markdown-preferences/link-bracket-newline | enforce linebreaks after opening and before closing link brackets | π§ | π |
| markdown-preferences/link-bracket-spacing | enforce consistent spacing inside link brackets | π§ | π |
| markdown-preferences/link-paren-newline | enforce linebreaks after opening and before closing link parentheses | π§ | π |
| markdown-preferences/link-paren-spacing | enforce consistent spacing inside link parentheses | π§ | π |
| markdown-preferences/list-marker-alignment | enforce consistent alignment of list markers | π§ | βπ |
| markdown-preferences/no-multi-spaces | disallow multiple spaces | π§ | π |
| markdown-preferences/no-multiple-empty-lines | disallow multiple empty lines in Markdown files. | π§ | π |
| markdown-preferences/no-trailing-spaces | disallow trailing whitespace at the end of lines in Markdown files. | π§ | π |
| markdown-preferences/padded-custom-containers | disallow or require padding inside custom containers | π§ | π |
| markdown-preferences/padding-line-between-blocks | require or disallow padding lines between blocks | π§ | π |
| markdown-preferences/table-pipe-spacing | enforce consistent spacing around table pipes | π§ | π |
- Rules related to visual or stylistic decorations in Markdown.
| Rule ID | Description | Fixable | Config |
|---|---|---|---|
| markdown-preferences/atx-heading-closing-sequence-length | enforce consistent length for the closing sequence (trailing #s) in ATX headings. | π§ | π |
| markdown-preferences/atx-heading-closing-sequence | enforce consistent use of closing sequence in ATX headings. | π§ | π |
| markdown-preferences/code-fence-length | enforce consistent code fence length in fenced code blocks. | π§ | π |
| markdown-preferences/no-laziness-blockquotes | disallow laziness in blockquotes | βπ | |
| markdown-preferences/ordered-list-marker-sequence | enforce that ordered list markers use sequential numbers | π§ | π |
| markdown-preferences/setext-heading-underline-length | enforce setext heading underline length | π§ | π |
| markdown-preferences/sort-definitions | enforce a specific order for link definitions and footnote definitions | π§ | π |
| markdown-preferences/table-leading-trailing-pipes | enforce consistent use of leading and trailing pipes in tables. | π§ | π |
| markdown-preferences/table-pipe-alignment | enforce consistent alignment of table pipes | π§ | π |
| markdown-preferences/thematic-break-length | enforce consistent length for thematic breaks (horizontal rules) in Markdown. | π§ | π |
| markdown-preferences/thematic-break-sequence-pattern | enforce consistent repeating patterns for thematic breaks (horizontal rules) in Markdown. | π§ | π |
- eslint-plugin-markdown-links ... ESLint plugin with powerful checking rules related to Markdown links.
Welcome contributing!
Please use GitHub's Issues/PRs.
npm testruns tests and measures coverage.npm run updateruns in order to update readme and recommended configuration.
See the LICENSE file for license rights and limitations (MIT).