{"id":19723,"library":"eslint-plugin-complexity","title":"eslint-plugin-complexity","description":"ESLint plugin providing additional complexity-related rules beyond ESLint's built-in complexity rule. Version 1.0.2 is the latest stable release, published on npm. It adds a custom rule 'complexity/comment' to warn when a function's cyclomatic complexity exceeds a configurable maximum. Differentiator: focused solely on complexity with a comment-based rule, not a general-purpose plugin.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/fengzilong/eslint-plugin-complexity","tags":["javascript"],"install":[{"cmd":"npm install eslint-plugin-complexity","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-complexity","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-complexity","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to use the plugin","package":"eslint","optional":false}],"imports":[{"note":"ESLint plugins are typically used via plugins array in config, not direct import in code.","wrong":"const complexity = require('eslint-plugin-complexity')","symbol":"default export (plugin object)","correct":"import complexity from 'eslint-plugin-complexity'"},{"note":"With flat config, import the plugin object and assign to plugins property.","wrong":"module.exports = { plugins: ['complexity'], rules: { 'complexity/comment': 'warn' } }","symbol":"Flat config (ESLint 9+)","correct":"import complexity from 'eslint-plugin-complexity';\nexport default [ { plugins: { complexity }, rules: { 'complexity/comment': 'warn' } } ]"},{"note":"Legacy config uses string in plugins array; flat config uses object.","wrong":"import complexity from 'eslint-plugin-complexity';\nexport default { plugins: { complexity }, rules: { 'complexity/comment': 'warn' } }","symbol":"Legacy .eslintrc config","correct":"module.exports = { plugins: ['complexity'], rules: { 'complexity/comment': 'warn' } }"}],"quickstart":{"code":"module.exports = {\n  plugins: ['complexity'],\n  rules: {\n    'complexity/comment': ['warn', { max: 10 }]\n  }\n};","lang":"javascript","description":"Configures ESLint to warn when function cyclomatic complexity exceeds 10 using the comment rule."},"warnings":[{"fix":"Ensure a comment like '/* complexity: N */' is present before the function to be checked.","message":"Rule 'complexity/comment' only checks functions with a leading comment (e.g., /* complexity: 5 */). Without a comment, no warning is emitted.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use { max: 10 } with quotes: 'complexity/comment': ['warn', { max: 10 }]","cause":"Configuration of rule 'complexity/comment' is not an object with max property.","error":"Configuration for rule \"complexity/comment\" is invalid: Value \"{max:10}\" should be object."},{"fix":"Run npm i eslint-plugin-complexity -D and add 'complexity' to plugins array in config.","cause":"Plugin not installed or not listed in plugins array correctly.","error":"ESLint couldn't find the plugin \"eslint-plugin-complexity\"."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}