-
Notifications
You must be signed in to change notification settings - Fork 269
refactor(providers): finish canonical identifier audit #1493
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,7 @@ export function createProviderIdentifierConfig({ providerIdentifiers, retiredPro | |
| return undefined | ||
| } | ||
|
|
||
| function getProviderExpressionBranches(node) { | ||
| function getProviderExpressionChildren(node) { | ||
| node = unwrapExpression(node) | ||
|
|
||
| if (node?.type === "LogicalExpression") { | ||
|
|
@@ -95,6 +95,14 @@ export function createProviderIdentifierConfig({ providerIdentifiers, retiredPro | |
| return [node.right] | ||
| } | ||
|
|
||
| if (node?.type === "CallExpression") { | ||
| return node.arguments | ||
| } | ||
|
|
||
| if (node?.type === "ArrayExpression") { | ||
| return node.elements.filter((element) => element !== null) | ||
|
Comment on lines
+102
to
+103
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- repository conventions and learnings ---'
find /tmp/coderabbit-repo-knowledge/zoo-code-org-zoo-code-6665e61c -type f -name '*.md' -maxdepth 3 -print
printf '%s\n' '--- target file outline ---'
ast-grep outline packages/config-eslint/provider-identifiers.js
printf '%s\n' '--- target file relevant sections ---'
sed -n '70,145p' packages/config-eslint/provider-identifiers.js
sed -n '200,235p' packages/config-eslint/provider-identifiers.js
printf '%s\n' '--- related tests and helper references ---'
rg -n -C 3 'getProviderExpressionChildren|SpreadElement|imageGenerationProvider|provider-identifiers' packages test . --glob '!node_modules' --glob '!dist' 2>/dev/null | head -300Repository: Zoo-Code-Org/Zoo-Code Length of output: 27311 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- repository-wide conventions ---'
cat /tmp/coderabbit-repo-knowledge/zoo-code-org-zoo-code-6665e61c/conventions/repo-wide.md
printf '%s\n' '--- provider rule implementation ---'
cat -n packages/config-eslint/provider-identifiers.js | sed -n '1,145p'
cat -n packages/config-eslint/provider-identifiers.js | sed -n '145,230p'
printf '%s\n' '--- provider rule tests around array and call cases ---'
cat -n packages/config-eslint/provider-identifiers.test.js | sed -n '65,225p'Repository: Zoo-Code-Org/Zoo-Code Length of output: 21055 Traverse 🤖 Prompt for AI AgentsSource: MCP tools |
||
| } | ||
|
|
||
| return [] | ||
| } | ||
|
|
||
|
|
@@ -119,8 +127,8 @@ export function createProviderIdentifierConfig({ providerIdentifiers, retiredPro | |
| }, | ||
| create(context) { | ||
| function reportIfRawProvider(node) { | ||
| for (const branch of getProviderExpressionBranches(node)) { | ||
| reportIfRawProvider(branch) | ||
| for (const child of getProviderExpressionChildren(node)) { | ||
| reportIfRawProvider(child) | ||
| } | ||
|
|
||
| const provider = getRawProvider(node) | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 10396
🏁 Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 16341
Prevent duplicate diagnostics for provider-like calls.
When a provider-like
VariableDeclaratorinitializes withgetProvider("openrouter"),reportIfRawProviderreports the argument, then theCallExpressionvisitor reports it again. Deduplicate reports or assignCallExpression.argumentsto one traversal path. Add a RuleTester case that expects one error.🤖 Prompt for AI Agents
Source: MCP tools