All rules

Code blocks with and without a language

code-fence-language-mixon by default (info)Japanese / English

A code block without a language among blocks that name theirs

Example

Flagged
# Usage Install it. ```bash npm install chaffjs ``` Write the settings. ```yaml genre: technical/readme ``` Check a file. ``` npx chaffjs README.md ```
What chaff prints
17:1 This code block names no language, unlike the others (2 blocks name one)
Fixed
# Usage Install it. ```bash npm install chaffjs ``` Write the settings. ```yaml genre: technical/readme ``` Check a file. ```bash npx chaffjs README.md ```
What chaff prints
no finding
chaff.yaml used for this example
genre: docs/manual

How to fix

Add the language after the opening ```. For output or plain text, write "text".

Why it matters

A language on a code block (```bash, ```json) gives it highlighting on the reader's screen and says at a glance what it is. When most blocks name their language and a few do not, those few show plain and look forgotten. chaff does not decide which way to go; it points at the fewer (markdownlint's MD040 asks for a language on every block).

What it does not flag

Indented code blocks, blocks inside a quotation, and blocks that hold only a format template (<MAJOR>.<MINOR>.<PATCH>) are not read. When more than {limit} blocks lack a language, or they are as many as those with one, it is taken as a choice and not reported.

Turning it off or relaxing it

Silence this one spot (in the document)
<!-- stet: code-fence-language-mix — reason -->
Relax it for the team (the reason is kept as a comment in chaff.yaml)
npx chaffjs relax code-fence-language-mix --why "reason"
Turn it off for the team (chaff.yaml)
rules: code-fence-language-mix: off
Technical details
Layer
L1
Status
stable
Severity
info
Languages
Japanese and English
Suited to
technical, docs, blog, legal, academic, literature, speech
Reads from the document
markdown

Levels

Set a level for this rule under rules in chaff.yaml. With nothing set, it runs at the level its genre gives it (see By genre below).

strictreported when 3 or fewer blocks lack a language and they are fewer than those with one
normalreported when 2 or fewer blocks lack a language and they are fewer than those with one
relaxedreported when 1 or fewer blocks lack a language and they are fewer than those with one

By genre

Runs by default in
technical/spec, technical/readme, blog/tech, blog/essay, blog/owned-media, docs/manual, docs/faq, docs/glossary
Turned off by the genre in
legal/contract, legal/statute, legal/judgment, legal/patent, academic/paper, literature/fiction, literature/essay, literature/poetry, literature/play, speech/address, speech/transcript
Not suited to, and not run in
business/proposal, business/report, business/email, business/press-release, business/meeting-notes

Genres

Message

This code block names no language, unlike the others ({tagged} blocks name one)

Rewrite depth (chaff fix-plan --depth): light — words and sentences; the structure and the voice stay

This page is built from the rule's definition file:packages/chaff/rules/code-fence-language-mix.yaml