markdown/no-space-in-emphasis

Disallow spaces around emphasis markers

fixable

** bold ** is not bold. A * or _ only starts emphasis if no space follows it, and only ends emphasis if no space comes before it. Otherwise the markers show up in the text.

--fix removes the space.

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/commonmark",
    rules: { "markdown/no-space-in-emphasis": "error" },
  },
];

It also works with markdown/gfm.

Examples#

example.md3 problems
This is ** important**.

This is _important _.

This is *** very important***.
example.mdNo problems
This is **important** and _this_ too.

2 * 3 is 6.

Options#

OptionDefaultWhat it does
checkStrikethroughfalseAlso check ~ and ~~.
example.mdwith { "checkStrikethrough": true }1 problem
This is ~~ gone~~.
example.mdwith { "checkStrikethrough": true }No problems
This is ~~gone~~.