markdown-preferences/prefer-autolinks β
enforce the use of autolinks for URLs
- βοΈ This rule is included in
plugin.configs.recommended
. - π§ The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
π Rule Details β
This rule promotes a modern, consistent Markdown style by requiring autolinks wherever possible. Using autolinks (<https://example.com>
) makes your documentation cleaner, easier to read, and simpler to maintain by removing unnecessary or redundant link syntax.
Autolinks should be used in the following situations:
- When a bare URL appears by itself (see GFM autolinks extension)
- When an inline linkβs label and URL are identical (e.g.,
[https://example.com](https://example.com)
)
Converting these patterns to autolinks keeps your Markdown concise and readable.
How is this different from @eslint/markdown
's markdown/no-bare-urls rule?
- markdown/no-bare-urls only reports bare URLs (e.g.,
https://example.com
) and auto-fixes them to autolinks. - This rule also reports and auto-fixes redundant inline links where the label and URL are identicalβcases not handled by markdown/no-bare-urls.
md
<!-- eslint markdown-preferences/prefer-autolinks: 'error' -->
<!-- β GOOD (autolink is preferred) -->
- <https://example.com>
<!-- β BAD (these will be auto-fixed) -->
- [https://example.com](https://example.com) <!-- Redundant inline link -->
- https://example.com <!-- Bare URL -->
π§ Options β
This rule has no options.
π Further Reading β
- GitHub Flavored Markdown: Autolinks
- GitHub Flavored Markdown: Autolinks (extension)
- CommonMark: Autolinks
π« Related Rules β
π Version β
This rule was introduced in eslint-plugin-markdown-preferences v0.11.0