-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add ESLint complexity and code size rules #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe ESLint configuration was updated to include new rules that enforce code complexity and size limits, such as maximum block depth, file length, nested callbacks, function parameters, statements per function, and cyclomatic complexity. An override was also added to relax the nested callbacks and function length rules specifically for test files. Changes
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (7)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces several ESLint rules to enforce code quality by limiting file complexity and size, while providing a test file override for nested callbacks.
- Adds rules for max-depth, max-lines, max-nested-callbacks, max-params, max-statements, and cyclomatic complexity.
- Implements an override for test files allowing 4 nested callbacks.
🔍 Vulnerabilities of
|
digest | sha256:319c880555dcbe290d681b74673ad693b5fa9a3aae37a8f176fffed20adb5bd8 |
vulnerabilities | |
platform | linux/amd64 |
size | 243 MB |
packages | 1628 |
📦 Base Image node:20-alpine
Description
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
Description
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
workers/main/eslint.config.mjs (2)
65-73
: Pass option objects tomax-lines
&max-statements
to cut down on false-positivesA bare number makes ESLint count every blank line and comment, which will quickly hit the 300 / 50 ceiling on well-commented files. Supplying an object allows you to keep the same hard limit while skipping noise lines:
- 'max-lines': ['error', 300], + 'max-lines': ['error', { max: 300, skipBlankLines: true, skipComments: true }], - 'max-statements': ['error', 50], + 'max-statements': ['error', { max: 50, ignoreTopLevelFunctions: true }],(The
ignoreTopLevelFunctions
flag avoids counting Jest/Jasminedescribe()
wrappers as statements.)Finally, please confirm the ESLint version you ship with actually contains
max-nested-callbacks
—it was added only in very recent releases.
75-80
: Consider loosening further limits for test filesTests often grow large due to fixtures and multiple scenarios. If that happens in this repo, the 300-line & 50-statement caps will still fail even after you bump
max-nested-callbacks
. You may want to disable or raise these limits under the same override:files: ['**/*.test.ts', '**/*.test.js'], rules: { 'max-nested-callbacks': ['error', 4], + 'max-lines': 'off', + 'max-statements': 'off', },Keeps CI green while still enforcing the rule-set on production code.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
workers/main/eslint.config.mjs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Docker Security Scanning (n8n, Dockerfile.n8n, n8n-test:latest)
- GitHub Check: Docker Security Scanning (temporal, Dockerfile.temporal, temporal-test:latest)
- GitHub Check: Service Availability Check
- GitHub Check: SonarQube
- GitHub Check: Analyze (actions)
- GitHub Check: Analyze (javascript-typescript)
- Add max-lines-per-function rule with 50 line limit - Add test file override allowing 150 lines per function - Update test file override comment to reflect additional rule
|
These rules enforce code quality standards by preventing overly complex and hard-to-maintain code structures, while allowing reasonable flexibility for test files where more nested callbacks are sometimes necessary.