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 code clean and consistent.
It only checks for double or multiple consecutive spaces within sentences. Since leading and trailing spaces have special meanings in Markdown, this rule does not check for them. Leading spaces are used for creating code blocks or indentation, while trailing spaces are used to create line breaks.
Examples
❌ Incorrect
Examples of incorrect code for this rule:
Default
foo bar baz
export default [
// ...
{
rules: {
'mark/no-double-space': 'error',
},
},
// ...
];
With multipleSpace: true
Option
foo bar baz
foo bar baz
foo bar baz qux
export default [
// ...
{
rules: {
'mark/no-double-space': ['error', {
multipleSpace: true,
}],
},
},
// ...
];
✅ Correct
Examples of correct code for this rule:
Default
foo bar baz qux
foo bar baz qux
foo bar
foo bar
foo bar
export default [
// ...
{
rules: {
'mark/no-double-space': 'error',
},
},
// ...
];
With multipleSpace: true
Option
foo bar baz qux
foo bar
foo bar
foo bar
export default [
// ...
{
rules: {
'mark/no-double-space': ['error', {
multipleSpace: true,
}],
},
},
// ...
];
Options
'mark/no-double-space': ['error', {
multipleSpace: false,
}]
multipleSpace
Default:
false
When multipleSpace
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.
AST
This rule applies only to the Text
node.