markdown-links/no-missing-fragments
disallow missing fragment identifiers in same-file Markdown links
📖 Rule Details
This rule reports fragments (anchors) in same-file links that don't exist as headings or HTML element IDs in the current Markdown file.
Fragment identifiers in Markdown links allow you to navigate to specific sections within the same document. This rule helps ensure that all fragment references are valid.
md
<!-- eslint markdown-links/no-missing-fragments: 'error' -->
<!-- ✓ GOOD -->
# Section One
Link to [Section Two](#section-two).
## Section Two
<div id="custom-section">Custom Section</div>
Link to [custom section](#custom-section).
<!-- ✗ BAD -->
# Section One
Link to [non-existent section](#non-existent).
🔧 Options
json
{
"markdown-links/no-missing-fragments": [
"error",
{
"ignoreCase": true,
"slugify": "github"
}
]
}
ignoreCase
(type:boolean
, default:true
): Whether to ignore case when matching anchor fragments.slugify
(type:"github" | "mdit-vue"
, default:"github"
): Specifies which logic to use for slugifying Markdown anchor fragments."github"
: Uses github-slugger for slugification. This is the same method used by GitHub."mdit-vue"
: Uses the slugification logic provided by mdit-vue. This is the same method used by VitePress and VuePress.
🔄 Differences From Eslint's markdown/no-missing-link-fragments
This rule serves a similar purpose to ESLint's official markdown/no-missing-link-fragments rule but focuses specifically on slugification flexibility:
- Slugification: This rule supports configurable slugification methods (
github
|mdit-vue
), while the official rule uses GitHub's slugger only
When to use which:
- Use
markdown-links/no-missing-fragments
if you need flexible slugification options (e.g., for Vue.js projects usingmdit-vue
) - Use the official @eslint/markdown rule in most cases - it provides comprehensive fragment validation with GitHub's standard slugification, which works well for most projects
👫 Related Rules
🚀 Version
This rule was introduced in eslint-plugin-markdown-links v0.4.0