fenced-code-language
June 19, 2025 ยท View on GitHub
Require languages for fenced code blocks.
Background
One of the ways that Markdown allows you to embed syntax-highlighted blocks of other languages is using fenced code blocks, such as:
```js
const message = "Hello, world!";
console.log(message);
```
The language name is expected, but not required, after the initial three backticks. In general, it's a good idea to provide a language because that allows editors and converters to properly syntax highlight the embedded code. Even if you're just embedding plain text, it's preferable to use text as the language to indicate your intention.
Rule Details
This rule warns when it finds code blocks without a language specified.
Examples of incorrect code for this rule:
<!-- eslint markdown/fenced-code-language: "error" -->
```
const message = "Hello, world!";
console.log(message);
```
Options
The following options are available on this rule:
required: Array<string>- when specified, fenced code blocks must use one of the languages specified in this array. (default:[])
Examples of incorrect code when configured as "fenced-code-language": ["error", { required: ["js"] }]:
<!-- eslint markdown/fenced-code-language: ["error", { required: ["js"] }] -->
```javascript
const message = "Hello, world!";
console.log(message);
```
When Not to Use It
If you don't mind omitting the language for fenced code blocks, you can safely disable this rule.