Registry / testing / remark-lint-code-block-syntax

remark-lint-code-block-syntax

JSON →
library0.11.0jsnpmunverified

A remark-lint rule that validates syntax of code blocks in Markdown files. Supports JavaScript, JSON, JSONC, JSON5, YAML, and CSS. Uses SWC for JavaScript parsing (since v0.4.0) and PostCSS for CSS (since v0.5.0). ESM-only since v0.3.0, requires Node.js >=18 (since v0.8.0). Active development, monthly releases. Differentiators: language alias support, broad language coverage, integrates with remark ecosystem.

npm install remark-lint-code-block-syntax
INSTALL
IMPORT
SIG · REMARK-LINT-CODE-B
R
remark-lint-code-block-syntax
testingjavascriptv0.11.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

remarkLintCodeBlockSyntax
import remarkLintCodeBlockSyntax from 'remark-lint-code-block-syntax'
const remarkLintCodeBlockSyntax = require('remark-lint-code-block-syntax')
Package is ESM-only since v0.3.0. Default export.
remarkLintCodeBlockSyntax (with remark)
import remark from 'remark'; import remarkLintCodeBlockSyntax from 'remark-lint-code-block-syntax'; remark().use(remarkLintCodeBlockSyntax)
remark().use('remark-lint-code-block-syntax')
The rule must be used as a function, not a string, in the plugin array.
remarkLintCodeBlockSyntax (type import)
import type { Plugin } from 'unified'; import remarkLintCodeBlockSyntax from 'remark-lint-code-block-syntax'
import { remarkLintCodeBlockSyntax } from 'remark-lint-code-block-syntax'
Export is default, not named. Use default import for value, type import if needed.

Demonstrates linting Markdown with an invalid JavaScript code block and reporting the warning.

import { remark } from 'remark'; import remarkLintCodeBlockSyntax from 'remark-lint-code-block-syntax'; import { reporter } from 'vfile-reporter'; const code = ` \`\`\`js const sum = 1 +; \`\`\` `; async function main() { const file = await remark() .use(remarkLintCodeBlockSyntax) .process(code); console.error(reporter(file)); } main();
Debug
Known issues
breakingNode.js >=18 required since v0.8.0
fix
Upgrade Node.js to version 18 or higher.
affects: >=0.8.0
breakingESM-only since v0.3.0
fix
Use import syntax instead of require().
affects: >=0.3.0
breakingMigrated from Esprima to SWC in v0.4.0
fix
No action needed, but note that parsing is now faster and may catch different errors.
affects: >=0.4.0
deprecatedNode.js 16 support dropped in v0.8.0
fix
Upgrade to Node.js 18 or higher.
affects: >=0.8.0
gotchaCSS support added in v0.5.0; language aliases supported but not all languages
fix
Check if your language is supported. See README for list.
affects: >=0.5.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
Using require() on an ESM-only package (v0.3.0+).
fix
Convert to import statement or use dynamic import().
TypeError: remark().use is not a function
Using a string plugin name instead of importing the function.
fix
Import the rule and pass it as a function: .use(remarkLintCodeBlockSyntax).
Upgrade
Version history
0.11.0latest on npm
Audit
Dependencies
unified-lint-rulerequiredProvides the lint rule base class
vfile-reporteroptionalUsed to report lint results in examples
remarkoptionalCore remark processor used to run the lint rule
Agent activity
4 hits · last 30 days
node
4
Resources
remark-lint-code-block-syntax — npm install remark-lint-code-block-syntax · libregistry