consistent-delete-style
🎨 Stylistic
🔧 Fixable
🌟 GFM
Enforce consistent delete style.
GFM Only
This rule applies only when GFM (GitHub Flavored Markdown) is enabled by setting the language mode to markdown/gfm.
Rule Details
This rule enforces a single, consistent style for delete (strikethrough text) in Markdown files. Consistent formatting makes it easier to understand a document, and mixing different delete styles can reduce readability.
A delete is defined as text wrapped in either ~ (single tilde) or ~~ (double tildes). While Markdown allows any of these styles, this rule ensures that only one is used throughout the document.
Examples
❌ Incorrect
Examples of incorrect code for this rule:
Default
<!-- eslint md/consistent-delete-style: 'error' -->
~foo~
~~bar~~
~baz~
~~_foo_~~
__~bar~__
_~~foo~~_
~__bar__~<!-- eslint md/consistent-delete-style: 'error' -->
~~foo~~
~bar~
~~baz~~
__~foo~__
~~_bar_~~
~__foo__~
_~~bar~~_With { style: '~' } Option
<!-- eslint md/consistent-delete-style: ['error', { style: '~' }] -->
~~foo~~
~~_bar_~~
_~~baz~~_With { style: '~~' } Option
<!-- eslint md/consistent-delete-style: ['error', { style: '~~' }] -->
~foo~
__~bar~__
~__baz__~✅ Correct
Examples of correct code for this rule:
Default
<!-- eslint md/consistent-delete-style: 'error' -->
~foo~
~bar~
__~baz~__
~__qux__~<!-- eslint md/consistent-delete-style: 'error' -->
~~foo~~
~~bar~~
~~_baz_~~
_~~qux~~_With { style: '~' } Option
<!-- eslint md/consistent-delete-style: ['error', { style: '~' }] -->
~foo~
~bar~
__~baz~__
~__qux__~With { style: '~~' } Option
<!-- eslint md/consistent-delete-style: ['error', { style: '~~' }] -->
~~foo~~
~~bar~~
~~_baz_~~
_~~qux~~_Options
'md/consistent-delete-style': ['error', {
style: 'consistent',
}]style
Type:
'consistent' | '~' | '~~'/ Default:'consistent'
When style is set to 'consistent', the rule enforces that all deletes in the document use the same style as the first one encountered.
You can also specify a particular style by setting style to '~' or '~~', which will enforce that all deletes use the specified style.
Fix
This rule fixes the deletes by replacing them with the configured style.