Registry / testing / remark-lint-fenced-code-flag

remark-lint-fenced-code-flag

JSON →
library4.2.0jsnpmunverified

A remark-lint rule that warns when fenced code blocks lack a language flag (infostring) or use an unrecognized one. Current stable version 4.2.0, released as part of the remark-lint monorepo with regular updates tied to remark ecosystem releases. Differentiates from generic linting by optionally validating against GitHub Linguist flags, ensuring code highlighting compatibility. Ships TypeScript definitions, ESM-only, requires Node.js 16+. Part of the remark-lint preset family.

npm install remark-lint-fenced-code-flag
INSTALL
IMPORT
SIG · REMARK-LINT-FENCED
R
remark-lint-fenced-code-flag
testingjavascriptv4.2.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.

remarkLintFencedCodeFlag
import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag'
const remarkLintFencedCodeFlag = require('remark-lint-fenced-code-flag')
Default export is the plugin function. ESM-only since v4; CommonJS require is not supported.
checkGithubLinguistFlag
import { checkGithubLinguistFlag } from 'remark-lint-fenced-code-flag'
Exported utility function to validate a flag against GitHub Linguist list.
CheckFlag
import type { CheckFlag } from 'remark-lint-fenced-code-flag'
TypeScript only. Available from v4.1.0+.
Options
import type { Options } from 'remark-lint-fenced-code-flag'
TypeScript only. Represents options object type.

Demonstrates how to set up a unified pipeline with remark-lint and the fenced-code-flag rule, reading a markdown file, processing with options, and reporting lint warnings.

import { unified } from 'unified'; import remarkParse from 'remark-parse'; import remarkStringify from 'remark-stringify'; import remarkLint from 'remark-lint'; import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag'; import { read } from 'to-vfile'; import { reporter } from 'vfile-reporter'; const file = await read('example.md'); await unified() .use(remarkParse) .use(remarkLint) .use(remarkLintFencedCodeFlag, { allowEmpty: false }) .use(remarkStringify) .process(file); console.error(reporter(file));
Debug
Known issues
breakingPackage is ESM-only since version 4.0.0.
fix
Use import statements. If required in CommonJS, use dynamic import() or downgrade to version 3.x.
affects: >=4.0.0
breakingNode.js version requirement raised to 16+ in v4.
fix
Update Node.js to version 16 or later.
affects: >=4.0.0
deprecatedThe built-in list of allowed flags may not be updated frequently; consider using the checkGithubLinguistFlag function for accurate validation.
fix
Use the checkGithubLinguistFlag imported utility to validate flags against GitHub Linguist.
affects: all
gotchaOptions can be passed as array, CheckFlag function, or Options object. Passing a string array directly is deprecated in favor of Options array property.
fix
Pass options as { allowEmpty: true, allowed: ['js', 'ts'] } for clarity.
affects: >=4.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/remark-lint-fenced-code-flag/index.js from /path/to/file.js not supported.
Package is ESM-only from v4.
fix
Convert your project to ESM (use import/export) or use dynamic import: const m = await import('remark-lint-fenced-code-flag')
TypeError: Cannot read properties of undefined (reading 'type')
Missing 'remark-lint' in the unified pipeline.
fix
Ensure you have .use(remarkLint) before the rule: unified().use(remarkParse).use(remarkLint).use(remarkLintFencedCodeFlag)
Upgrade
Version history
4.2.0latest on npm
Audit
Dependencies
unifiedrequiredPlugin interface; must be used with unified pipeline.
remark-lintrequiredLint framework integration; required for the rule to function.
remark-parseoptionalMarkdown parser needed for converting source to AST.
remark-stringifyoptionalStringifier needed for output after linting (common in API usage).
Agent activity
4 hits · last 30 days
node
4
Resources
remark-lint-fenced-code-flag — npm install remark-lint-fenced-code-flag · libregistry