Document and pin no-github-request-interpolated-route boundary behavior#44550
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Hey This PR is currently a draft with no file changes yet, so a few things to land before it's ready for review:
If you'd like a hand, you can assign this prompt to your coding agent:
|
no-github-request-interpolated-route boundary behavior
There was a problem hiding this comment.
Pull request overview
This pull request clarifies and “pins” the intended scope boundaries of the no-github-request-interpolated-route ESLint rule by documenting out-of-scope syntaxes, adding tests to lock in that behavior, and narrowing a false positive so compile-time constant + route expressions are no longer flagged.
Changes:
- Update the rule to stop flagging compile-time-constant
+route concatenations composed only of literals. - Add tests that explicitly assert several intentionally out-of-scope route-building forms are accepted.
- Expand
eslint-factoryREADME rule documentation, including an explicit “Out of scope” section for the route rule.
Show a summary per file
| File | Description |
|---|---|
| eslint-factory/src/rules/no-github-request-interpolated-route.ts | Adds static-expression detection to exclude constant-only + concatenations from being reported. |
| eslint-factory/src/rules/no-github-request-interpolated-route.test.ts | Adds “valid” cases covering explicitly out-of-scope forms and constant-only concatenation acceptance. |
| eslint-factory/README.md | Documents out-of-scope boundaries for the route rule and expands rule documentation coverage. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Low
| function isStaticRouteExpression(node: TSESTree.Node): boolean { | ||
| if (node.type === "Literal") return true; | ||
| if (node.type === "TemplateLiteral") return node.expressions.length === 0; | ||
| if (node.type === "BinaryExpression" && node.operator === "+") { | ||
| return isStaticRouteExpression(node.left) && isStaticRouteExpression(node.right); | ||
| } | ||
| return false; | ||
| } |
|
🎉 This pull request is included in a new release. Release: |
no-github-request-interpolated-routehad several intentional syntactic limits that were neither tested nor documented, making it hard to distinguish deliberate scope from missing coverage. This change pins those boundaries in tests, documents them in the eslint-factory README, and narrows one false positive in constant-only route concatenation.Rule behavior
+route expressions such as"GET /repos" + "/{owner}/{repo}".+concatenation with dynamic values.Boundary coverage
validtests for currently out-of-scope forms:this.github.request(...),context.github.request(...)github.request(route, ...).concat()route building+concatenationREADME coverage
.concat().Example