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
```
const port = 3000;
```
example.mdNo problems
```js
const port = 3000;
```

Options#

OptionDefaultWhat it does
required[]The only languages that are allowed. An empty list allows any language.
example.mdwith { "required": ["js", "sh"] }1 problem
```javascript
const port = 3000;
```
example.mdwith { "required": ["js", "sh"] }No problems
```js
const port = 3000;
```