Registry / testing / eslint-plugin-complexity

eslint-plugin-complexity

JSON →
library1.0.2jsnpmunverified

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.

npm install eslint-plugin-complexity
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-COMP
E
eslint-plugin-complexity
testingjavascriptv1.0.2
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (plugin object)
✓ import complexity from 'eslint-plugin-complexity'
✗ const complexity = require('eslint-plugin-complexity')
ESLint plugins are typically used via plugins array in config, not direct import in code.
Flat config (ESLint 9+)
✓ import complexity from 'eslint-plugin-complexity'; export default [ { plugins: { complexity }, rules: { 'complexity/comment': 'warn' } } ]
✗ module.exports = { plugins: ['complexity'], rules: { 'complexity/comment': 'warn' } }
With flat config, import the plugin object and assign to plugins property.
Legacy .eslintrc config
✓ module.exports = { plugins: ['complexity'], rules: { 'complexity/comment': 'warn' } }
✗ import complexity from 'eslint-plugin-complexity'; export default { plugins: { complexity }, rules: { 'complexity/comment': 'warn' } }
Legacy config uses string in plugins array; flat config uses object.

Configures ESLint to warn when function cyclomatic complexity exceeds 10 using the comment rule.

module.exports = { plugins: ['complexity'], rules: { 'complexity/comment': ['warn', { max: 10 }] } };
Debug
Known issues
gotchaRule 'complexity/comment' only checks functions with a leading comment (e.g., /* complexity: 5 */). Without a comment, no warning is emitted.
fix
Ensure a comment like '/* complexity: N */' is present before the function to be checked.
affects: >=1.0.0
Errors
Common errors & fixes
Configuration for rule "complexity/comment" is invalid: Value "{max:10}" should be object.
Configuration of rule 'complexity/comment' is not an object with max property.
fix
Use { max: 10 } with quotes: 'complexity/comment': ['warn', { max: 10 }]
ESLint couldn't find the plugin "eslint-plugin-complexity".
Plugin not installed or not listed in plugins array correctly.
fix
Run npm i eslint-plugin-complexity -D and add 'complexity' to plugins array in config.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required to use the plugin
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-complexity — npm install eslint-plugin-complexity · libregistry