{"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,"search_vec":"'1.0.2':22 'add':32 'addit':8 'base':58 'beyond':13 'built':17 'built-in':16 'comment':57 'comment-bas':56 'complex':4,10,19,44,53 'complexity-rel':9 'complexity/comment':36 'configur':47 'custom':34 'cyclomat':43 'differenti':49 'eslint':2,5,14 'eslint-plugin-complex':1 'exceed':45 'focus':50 'function':41 'general':63 'general-purpos':62 'javascript':66 'latest':25 'maximum':48 'npm':30 'plugin':3,6,65 'provid':7 'publish':28 'purpos':64 'relat':11 'releas':27 'rule':12,20,35,59 'sole':51 'stabl':26 'version':21 'warn':38","created_at":"2026-04-25T11:19:18.274129+00:00","updated_at":"2026-04-25T11:19:18.274129+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/fengzilong/eslint-plugin-complexity","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/eslint-plugin-complexity","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}