ci: enforce route constants via ESLint and CodeRabbit#2781
ci: enforce route constants via ESLint and CodeRabbit#2781Logvin wants to merge 1 commit intoseerr-team:developfrom
Conversation
Add guardrails to prevent hardcoded /api/v1 paths from being reintroduced after the route constants refactor (seerr-team#2762): - ESLint no-restricted-syntax rule flags hardcoded /api/v1 in src/ and server/ (excluding the constant definition files) - CodeRabbit path instructions for src/, server/index.ts, and server/routes/ to flag hardcoded paths during review Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Ignoring CodeRabbit configuration file changes. For security, only the configuration from the base branch is applied for open source repositories. 📝 WalkthroughWalkthroughThis PR adds configuration-based enforcement for consistent API path handling. It extends code review instructions and ESLint rules to require client code use the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.coderabbit.yaml (1)
3-7: Add an explicit exception instruction forsrc/utils/apiUrl.ts.Line 3’s
src/**guidance will also target the canonical helper file itself, which can create avoidable false-positive review comments.🧭 Suggested adjustment
reviews: path_instructions: + - path: 'src/utils/apiUrl.ts' + instructions: | + '/api/v1' is allowed here as the canonical API base helper definition. - path: 'src/**' instructions: | Flag any hardcoded '/api/v1' string literals in client code.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.coderabbit.yaml around lines 3 - 7, The global rule that flags hardcoded '/api/v1' in 'src/**' is also catching the canonical helper itself; update the config to exempt the helper by excluding or adding an exception for src/utils/apiUrl.ts so the linter/qa rule does not flag that file; specifically adjust the 'src/**' rule to add an exclude pattern or explicit exception for the file path (src/utils/apiUrl.ts) while leaving the rest of the pattern intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.coderabbit.yaml:
- Around line 3-7: The global rule that flags hardcoded '/api/v1' in 'src/**' is
also catching the canonical helper itself; update the config to exempt the
helper by excluding or adding an exception for src/utils/apiUrl.ts so the
linter/qa rule does not flag that file; specifically adjust the 'src/**' rule to
add an exclude pattern or explicit exception for the file path
(src/utils/apiUrl.ts) while leaving the rest of the pattern intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f4a28fdd-ed07-4d72-aa57-e890b6495da1
📒 Files selected for processing (2)
.coderabbit.yamleslint.config.mts
|
CodeRabbit flagged that the |
Summary
no-restricted-syntaxrule that flags hardcoded/api/v1string literals insrc/andserver/(excluding the constant definition files).coderabbit.yamlwith path instructions so CodeRabbit flags hardcoded route paths during reviewThis is a companion to #2762 (route constants refactor). Once that PR lands, these guardrails prevent the hardcoded paths from being reintroduced.
Why
PR #2762 replaces 201 hardcoded
/api/v1occurrences across 73 files with centralized constants. Without enforcement, new code will inevitably reintroduce hardcoded paths. These two lightweight checks catch it at dev time (ESLint, pre-commit hook) and at review time (CodeRabbit).What changed
eslint.config.mts— Two new config blocks withno-restricted-syntax:src/**/*.{ts,tsx}(excludessrc/utils/apiUrl.ts): "Use apiUrl() from @app/utils/apiUrl"server/**/*.ts(excludesserver/constants/routes.ts): "Use API_BASE_PATH from @server/constants/routes".coderabbit.yaml— Path instructions forsrc/,server/index.ts, andserver/routes/Notes
no-restricted-syntaxruledevelop. This is intentional and expected... those are the same paths refactor: extract hardcoded route paths into shared constants #2762 converts. This PR should be merged after refactor: extract hardcoded route paths into shared constants #2762/api/v1literals, does not flag the constant definition filesTest plan
npx eslint src/components/TitleCard/index.tsxflags all 8 hardcoded/api/v1pathssrc/utils/apiUrl.ts,server/constants/routes.ts) are excluded.coderabbit.yamlinstructions on future PRsAI Disclosure: This PR was developed with Claude Code as a pair programming tool. I directed the approach, reviewed the config changes, and verified the ESLint rule behavior. I'm the author, Claude is my editor.
🤖 Generated with Claude Code
Summary by CodeRabbit