Skip to content

eslint/rules/complexity ​

Complexity: Size and complexity limits: lines, statements, nesting, cognitive complexity. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.

9 rules, 3 on. Source: lint/eslint/rules/complexity.mjs.

RuleSettingFilesWhat it checksWhy
complexityoffJS + TSEnforce a maximum cyclomatic complexity allowed in a programOff: replaced by sonarjs/cognitive-complexity, like SonarQube.
max-depthoffJS + TSEnforce a maximum depth that blocks can be nestedOff: replaced by sonarjs/nested-control-flow, like SonarQube.
max-linesoffJS + TSEnforce a maximum number of lines per fileOff: replaced by sonarjs/max-lines, like SonarQube.
max-statementsoffJS + TSEnforce a maximum number of statements allowed in function blocksOff: no SonarQube equivalent.
sonarjs/max-lineswarn, {"maximum":200}JS + TSFiles should not have too many lines of codeCustom: outside Sonar way; replaces the core max-lines, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass.
sonarjs/nested-control-flowwarnJS + TSControl flow statements "if", "for", "while", "switch" and "try" should not be nested too deeplyCustom: outside Sonar way; replaces the core max-depth, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass.
sonarjs/expression-complexityoffJS + TSExpressions should not be too complexOff: not in the Sonar way profile of SonarQube.
sonarjs/cognitive-complexitywarnJS + TSCognitive Complexity of functions should not be too highSonar way; replaces the core complexity, like SonarQube. Warn: a size limit: a justified exception (a data table, a state machine) may pass.
sonarjs/cyclomatic-complexityoffJS + TSCyclomatic Complexity of functions should not be too highOff: not in the Sonar way profile of SonarQube.

Generated from the JSDoc of the sources.