Linter · Rules
markdown/no-bare-urls
Disallow bare URLs
GitHub Flavored Markdown turns a URL or an email address in plain text into a link. CommonMark doesn't, so the same document has a link on GitHub and plain text elsewhere. < and > around the URL make it a link everywhere.
Only markdown/gfm finds links in plain text, so the rule reports nothing in markdown/commonmark.
--fix puts < and > around the URL.
Configure
Off by default. It needs an ESLint config that says which files are in the language:
eslint.config.js
import markdown from "@eslint/markdown";
export default [
{
files: ["**/*.md"],
plugins: { markdown },
language: "markdown/gfm",
rules: { "markdown/no-bare-urls": "error" },
},
];
It also works with markdown/commonmark.
Examples
Reported:
See https://bun.aphrody.app/docs or write to hello@example.com.
Not reported:
See <https://bun.aphrody.app/docs>, the [docs](https://bun.aphrody.app/docs), or `https://bun.aphrody.app/docs`.
A URL between an opening and a closing HTML tag is left alone:
See <a href="https://bun.aphrody.app/docs">https://bun.aphrody.app/docs</a>.