{"id":25506,"library":"eslint-plugin-doc-code-blocks","title":"eslint-plugin-doc-code-blocks","description":"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.","status":"maintenance","version":"0.3.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","eslint","eslintplugin","eslint-plugin","jsdoc","yuidoc","comments","code fences","comment code"],"install":[{"cmd":"npm install eslint-plugin-doc-code-blocks","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-doc-code-blocks","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-doc-code-blocks","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required to run the plugin (ESLint >=4.0).","package":"eslint","optional":false}],"imports":[{"note":"ESLint plugin names omit the 'eslint-plugin-' prefix in config files.","wrong":"plugins: ['eslint-plugin-doc-code-blocks']","symbol":"plugin","correct":"plugins: ['doc-code-blocks']"},{"note":"Configs must include 'plugin:' prefix to reference plugin-provided configs.","wrong":"extends: ['doc-code-blocks/recommended']","symbol":"config","correct":"extends: ['plugin:doc-code-blocks/recommended']"},{"note":"Use a separate config file (e.g., .doc.eslintrc.js) to apply rules to code blocks.","wrong":"eslint -c doc-code-blocks your_files","symbol":"CLI","correct":"eslint --config .doc.eslintrc.js your_files"}],"quickstart":{"code":"// .eslintrc.js\nmodule.exports = {\n  plugins: ['doc-code-blocks'],\n};\n\n// .doc.eslintrc.js\nmodule.exports = {\n  extends: ['plugin:doc-code-blocks/recommended'],\n  plugins: ['doc-code-blocks'],\n  rules: {\n    'semi': ['error', 'always'],\n    'no-console': 'off'\n  }\n};\n\n// Run:\n// eslint --config .doc.eslintrc.js --no-eslintrc --ext .js .","lang":"javascript","description":"Configures the plugin and a separate config to lint code blocks with custom rules, then runs eslint with that config."},"warnings":[{"fix":"Consider using '@eslint/plugin-markdown' or 'eslint-plugin-markdown' for similar functionality with better maintenance.","message":"This 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.","severity":"deprecated","affected_versions":">=0.3.1"},{"fix":"Prefer 'plugin:doc-code-blocks/recommended' which uses 'eslint:recommended', or define explicit rules.","message":"ESLint's 'eslint:all' config can break across minor releases; plugin extends 'all' in 'plugin:doc-code-blocks/all'.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Always run eslint with a dedicated config for code blocks (e.g., --config .doc.eslintrc.js).","message":"Rules are applied to code blocks only when using a separate config file; rules in the default .eslintrc do not affect code blocks.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Continue using .eslintrc.* files; plugin will not work with flat config introduced in ESLint 9.","message":"The plugin does not support ESLint flat config (eslint.config.js). Only legacy .eslintrc format is supported.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install the plugin globally: npm i -g eslint-plugin-doc-code-blocks","cause":"Plugin not installed globally when ESLint is global.","error":"Error: Failed to load plugin 'doc-code-blocks' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-doc-code-blocks'"},{"fix":"Ensure rule values are valid ESLint rule severity (e.g., 'error', 2) or an array: 'semi': ['error', 'always']","cause":"Using 'extends' from doc-code-blocks/all without proper rule config format.","error":"Error: Configuration for rule 'semi' is invalid: Value '\"always\"' is the wrong type (expected object or boolean)"},{"fix":"Set parserOptions: { 'sourceType': 'module' } in your .doc.eslintrc.js.","cause":"Source code in the code block uses ES modules, but ESLint parser is not set to 'eslint:recommended' or parserOptions for modules.","error":"Parsing error: The keyword 'import' is reserved"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}