markdown/fenced-code-language
Require languages for fenced code blocks
A fenced code block without a language gets no syntax highlighting, and tools that extract code blocks by language skip it. Indented code blocks can't have a language, so they're ignored.
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/fenced-code-language": "error" },
},
];It also works with markdown/gfm.
Examples#
example.md1 problem
```Missing code block language.
const port = 3000;
```example.mdNo problems
```js
const port = 3000;
```Options#
| Option | Default | What it does |
|---|---|---|
required | [] | The only languages that are allowed. An empty list allows any language. |
example.mdwith
{ "required": ["js", "sh"] }1 problem```javascriptCode block language javascript is not allowed.
const port = 3000;
```example.mdwith
{ "required": ["js", "sh"] }No problems```js
const port = 3000;
```