Registry / testing / eslint-plugin-doc-code-blocks

eslint-plugin-doc-code-blocks

JSON →
library0.3.1jsnpmunverified

Lint JavaScript code embedded in block comments (e.g., JSDoc, YUIDoc code fences) using ESLint. Version 0.3.1 is the latest stable release; the package has low release cadence and is in maintenance mode. It does not provide its own rules but leverages existing ESLint configurations (eslint:recommended or eslint:all) on code blocks within comments. A key differentiator is enabling code quality checks on documentation examples, though it lacks active development and may not support ESLint versions beyond 8.x.

npm install eslint-plugin-doc-code-blocks
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-DOC-
E
eslint-plugin-doc-code-blocks
testingjavascriptv0.3.1
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.

plugin
✓ plugins: ['doc-code-blocks']
✗ plugins: ['eslint-plugin-doc-code-blocks']
ESLint plugin names omit the 'eslint-plugin-' prefix in config files.
config
✓ extends: ['plugin:doc-code-blocks/recommended']
✗ extends: ['doc-code-blocks/recommended']
Configs must include 'plugin:' prefix to reference plugin-provided configs.
CLI
✓ eslint --config .doc.eslintrc.js your_files
✗ eslint -c doc-code-blocks your_files
Use a separate config file (e.g., .doc.eslintrc.js) to apply rules to code blocks.

Configures the plugin and a separate config to lint code blocks with custom rules, then runs eslint with that config.

// .eslintrc.js module.exports = { plugins: ['doc-code-blocks'], }; // .doc.eslintrc.js module.exports = { extends: ['plugin:doc-code-blocks/recommended'], plugins: ['doc-code-blocks'], rules: { 'semi': ['error', 'always'], 'no-console': 'off' } }; // Run: // eslint --config .doc.eslintrc.js --no-eslintrc --ext .js .
Debug
Known issues
deprecatedThis plugin does not provide its own rules and relies on ESLint's built-in configs (eslint:all, eslint:recommended). It may not work with ESLint >=9.x due to flat config migration.
fix
Consider using '@eslint/plugin-markdown' or 'eslint-plugin-markdown' for similar functionality with better maintenance.
affects: >=0.3.1
breakingESLint's 'eslint:all' config can break across minor releases; plugin extends 'all' in 'plugin:doc-code-blocks/all'.
fix
Prefer 'plugin:doc-code-blocks/recommended' which uses 'eslint:recommended', or define explicit rules.
affects: >=0.1.0
gotchaRules are applied to code blocks only when using a separate config file; rules in the default .eslintrc do not affect code blocks.
fix
Always run eslint with a dedicated config for code blocks (e.g., --config .doc.eslintrc.js).
affects: >=0.1.0
gotchaThe plugin does not support ESLint flat config (eslint.config.js). Only legacy .eslintrc format is supported.
fix
Continue using .eslintrc.* files; plugin will not work with flat config introduced in ESLint 9.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Failed to load plugin 'doc-code-blocks' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-doc-code-blocks'
Plugin not installed globally when ESLint is global.
fix
Install the plugin globally: npm i -g eslint-plugin-doc-code-blocks
Error: Configuration for rule 'semi' is invalid: Value '"always"' is the wrong type (expected object or boolean)
Using 'extends' from doc-code-blocks/all without proper rule config format.
fix
Ensure rule values are valid ESLint rule severity (e.g., 'error', 2) or an array: 'semi': ['error', 'always']
Parsing error: The keyword 'import' is reserved
Source code in the code block uses ES modules, but ESLint parser is not set to 'eslint:recommended' or parserOptions for modules.
fix
Set parserOptions: { 'sourceType': 'module' } in your .doc.eslintrc.js.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; required to run the plugin (ESLint >=4.0).
Agent activity
6 hits · last 30 days
node
6
Resources
eslint-plugin-doc-code-blocks — npm install eslint-plugin-doc-code-blocks · libregistry