oxlint-complexity-line-rules
Purpose
Does oxlint support cyclomatic/cognitive complexity checks or max line length rules?
Key Findings
max-len(line length): Built into oxlint core — enabled via configmax-linesandmax-lines-per-function: Built into oxlint core- Cyclomatic/Cognitive complexity: NOT in oxlint core — use the community plugin
oxlint-plugin-complexity
Built-in Rules (Oxlint Core)
eslint/max-len — Max Line Length
Enforces a maximum line length. Added to oxlint in April 2024.
Config (oxlintrc.json):
{ "rules": { "max-len": ["error", { "code": 100, "ignoreUrls": true, "ignoreStrings": false, "ignoreTemplateLiterals": false, "ignoreRegExpLiterals": false, "ignoreComments": false, "ignoreTrailingComments": false, "ignorePattern": "" }] }}Note: JSX comment handling has limitations in the current AST.
Docs: https://oxc.rs/docs/guide/usage/linter/rules/eslint/max-len
eslint/max-lines — Max Lines Per File
Enforces a maximum number of lines per file.
eslint/max-lines-per-function — Max Lines Per Function
Enforces a maximum number of lines within a function (default: 50).
Config:
{ "rules": { "max-lines-per-function": ["error", { "max": 50, "skipBlankLines": false, "skipComments": false, "IIFEs": false }] }}Docs: https://oxc.rs/docs/guide/usage/linter/rules/eslint/max-lines-per-function
Community Plugin: oxlint-plugin-complexity
For cyclomatic and cognitive complexity, use the third-party plugin:
Install:
npm install oxlint-plugin-complexity --save-devConfig (oxlintrc.json):
{ "jsPlugins": ["oxlint-plugin-complexity"], "rules": { "complexity/complexity": ["error", { "cyclomatic": 20, "cognitive": 15, "minLines": 10, "enableExtraction": true, "nestingTipThreshold": 3, "elseIfChainThreshold": 4, "logicalOperatorThreshold": 3 }] }}Cyclomatic Complexity
Counts decision points (+1 for each): if, for, for...in, for...of, while, do...while, case, catch, ? :, &&, ||, ??
Cognitive Complexity
Penalizes nesting depth to measure understandability. Excludes React components and default value patterns like a || [].
Plugin Options
| Option | Default | Purpose |
|---|---|---|
cyclomatic | 20 | Max cyclomatic threshold |
cognitive | 15 | Max cognitive threshold |
minLines | 10 | Skip functions shorter than N lines |
enableExtraction | true | Suggest extractable blocks |
nestingTipThreshold | 3 | Nesting depth to trigger tip |
elseIfChainThreshold | 4 | else-if chain length to trigger tip |
logicalOperatorThreshold | 3 | Logical operator count to trigger tip |
Supports: .js, .mjs, .cjs, .ts, .tsx, .jsx, .vue (extracts <script> blocks)
Plugin repo: https://github.com/itaymendel/oxlint-plugin-complexity
Summary Table
| Rule | Built-in? | Notes |
|---|---|---|
max-len | ✅ Yes | Line length limit |
max-lines | ✅ Yes | Lines per file limit |
max-lines-per-function | ✅ Yes | Lines per function limit |
| Cyclomatic complexity | ❌ Plugin only | oxlint-plugin-complexity |
| Cognitive complexity | ❌ Plugin only | oxlint-plugin-complexity |
Sources
- oxlint rules: eslint/max-len
- oxlint rules: eslint/max-lines-per-function
- oxlint rules: eslint/max-lines
- oxlint-plugin-complexity GitHub
- PR #2874: feat(linter): eslint/max-len