no-double-space
✅ Recommended
🔧 Fixable
⭐ CommonMark
🌟 GFM
Disallow double or multiple consecutive spaces in text, except for leading and trailing spaces.
Rule Details
Markdown treats double or multiple consecutive spaces within a sentence as a single space.
Double spaces within a sentence are usually typos and can be hard to spot. This rule helps keep your content clean and consistent.
NOTE
It only checks for double or multiple consecutive spaces within sentences. Since leading and trailing spaces have special meanings in Markdown, it does not check those. Leading spaces are used to create code blocks or indentation, while trailing spaces are used to create line breaks.
Examples
❌ Incorrect
Examples of incorrect code for this rule:
Default
<!-- eslint mark/no-double-space: "error" -->
foo bar bazWith { checkMultipleSpace: true } Option
<!-- eslint mark/no-double-space: ["error", { checkMultipleSpace: true }] -->
foo bar baz
foo bar baz
foo bar baz qux✅ Correct
Examples of correct code for this rule:
Default
<!-- eslint mark/no-double-space: "error" -->
foo bar baz qux
foo bar baz qux
foo bar
foo bar
foo bar <!-- trailing double space -->
foo bar <!-- trailing multiple space -->With { checkMultipleSpace: true } Option
<!-- eslint mark/no-double-space: ["error", { checkMultipleSpace: true }] -->
foo bar baz qux
foo bar baz qux
foo bar
foo bar
foo bar <!-- trailing double space -->
foo bar <!-- trailing multiple space -->Options
'mark/no-double-space': ['error', {
checkMultipleSpace: false,
}]checkMultipleSpace
Type:
boolean/ Default:false
When checkMultipleSpace is set to true, this rule will also check for multiple consecutive spaces (more than two) within a sentence.
Fix
This rule fixes the double or multiple consecutive spaces by replacing them with a single space.