Skip to content

markdown-preferences/code-fence-spacing

require or disallow spacing between opening code fence and language identifier

  • ⚙️ This rule is included in plugin.configs.standard.
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

📖 Rule Details

This rule enforces consistent spacing between the opening code fence (e.g. ``` or ~~~) and the language identifier in fenced code blocks. You can require a space ("always") or disallow it ("never"). By default, spaces are disallowed.

md
<!-- eslint markdown-preferences/code-fence-spacing: 'error' -->

<!-- ✓ GOOD -->

```js
console.log("hello")
```


<!-- ✗ BAD -->

```
js
console.log("hello") ```

🔧 Options

json
{
  "markdown-preferences/code-fence-spacing": [
    "error",
    {
      "space": "never"
    }
  ]
}
  • space (string, default: "never")
    • "always" requires a space between the opening code fence and the language identifier.
    • "never" disallows spaces between the opening code fence and the language identifier.

📚 Further Reading

🚀 Version

This rule was introduced in eslint-plugin-markdown-preferences v0.30.0

🔍 Implementation