Skip to content

Commit 53d2cee

Browse files
committed
refactor(eslint): share provider identifier rule across packages
1 parent dfed27d commit 53d2cee

70 files changed

Lines changed: 1099 additions & 594 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/cli/eslint.config.mjs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { config } from "@roo-code/config-eslint/base"
2+
import { createProviderIdentifierConfig } from "@roo-code/config-eslint/provider-identifiers"
3+
import { providerIdentifiers, retiredProviderIdentifiers } from "@roo-code/types/provider-identifiers"
24

35
/** @type {import("eslint").Linter.Config} */
4-
export default [...config]
6+
export default [
7+
...config,
8+
createProviderIdentifierConfig({ providerIdentifiers, retiredProviderIdentifiers }),
9+
]

‎apps/cli/src/agent/__tests__/extension-host.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { providerIdentifiers } from "@roo-code/types"
12
// pnpm --filter @roo-code/cli test src/agent/__tests__/extension-host.test.ts
23

34
import { EventEmitter } from "events"
@@ -28,7 +29,7 @@ vi.mock("@/lib/storage/index.js", () => ({
2829
*/
2930
function createTestHost({
3031
mode = "code",
31-
provider = "openrouter",
32+
provider = providerIdentifiers.openrouter,
3233
model = "test-model",
3334
...options
3435
}: Partial<ExtensionHostOptions> = {}): ExtensionHost {
@@ -113,7 +114,7 @@ describe("ExtensionHost", () => {
113114
extensionPath: "/my/extension",
114115
user: null,
115116
apiKey: "test-key",
116-
provider: "openrouter",
117+
provider: providerIdentifiers.openrouter,
117118
model: "test-model",
118119
ephemeral: false,
119120
debug: false,

‎apps/cli/src/lib/storage/__tests__/settings.test.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { providerIdentifiers } from "@roo-code/types"
12
import fs from "fs/promises"
23
import path from "path"
34

@@ -58,7 +59,7 @@ describe("Settings Storage", () => {
5859
const settingsData = {
5960
onboardingProviderChoice: OnboardingProviderChoice.Byok,
6061
mode: "architect",
61-
provider: "anthropic" as const,
62+
provider: providerIdentifiers.anthropic,
6263
model: "claude-sonnet-4-20250514",
6364
reasoningEffort: "high" as const,
6465
}
@@ -95,7 +96,7 @@ describe("Settings Storage", () => {
9596

9697
it("should merge settings with existing ones", async () => {
9798
await saveSettings({ mode: "code" })
98-
await saveSettings({ provider: "openrouter" as const })
99+
await saveSettings({ provider: providerIdentifiers.openrouter })
99100

100101
const savedData = await fs.readFile(expectedSettingsFile, "utf-8")
101102
const settings = JSON.parse(savedData)
@@ -107,7 +108,7 @@ describe("Settings Storage", () => {
107108
it("should save all default settings fields", async () => {
108109
await saveSettings({
109110
mode: "architect",
110-
provider: "anthropic" as const,
111+
provider: providerIdentifiers.anthropic,
111112
model: "claude-opus-4.6",
112113
reasoningEffort: "medium" as const,
113114
consecutiveMistakeLimit: 5,
@@ -155,7 +156,7 @@ describe("Settings Storage", () => {
155156
await saveSettings({
156157
onboardingProviderChoice: OnboardingProviderChoice.Byok,
157158
mode: "architect",
158-
provider: "gemini" as const,
159+
provider: providerIdentifiers.gemini,
159160
})
160161

161162
await resetOnboarding()
@@ -172,7 +173,7 @@ describe("Settings Storage", () => {
172173
// Test that all the settings that can be used as defaults are properly saved and loaded
173174
const defaultSettings = {
174175
mode: "debug",
175-
provider: "openai-native" as const,
176+
provider: providerIdentifiers.openaiNative,
176177
model: "gpt-4o",
177178
reasoningEffort: "low" as const,
178179
consecutiveMistakeLimit: 7,
@@ -205,7 +206,7 @@ describe("Settings Storage", () => {
205206
it("should support all settings together including requireApproval", async () => {
206207
const allSettings = {
207208
mode: "architect",
208-
provider: "anthropic" as const,
209+
provider: providerIdentifiers.anthropic,
209210
model: "claude-sonnet-4-20250514",
210211
reasoningEffort: "high" as const,
211212
requireApproval: true,
@@ -231,7 +232,7 @@ describe("Settings Storage", () => {
231232
it("should support all settings together including oneshot", async () => {
232233
const allSettings = {
233234
mode: "architect",
234-
provider: "anthropic" as const,
235+
provider: providerIdentifiers.anthropic,
235236
model: "claude-sonnet-4-20250514",
236237
reasoningEffort: "high" as const,
237238
consecutiveMistakeLimit: 9,

‎apps/cli/src/types/__tests__/types.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { providerIdentifiers } from "@roo-code/types"
1+
import { providerIdentifiers, retiredProviderIdentifiers } from "@roo-code/types"
22

33
import { isSupportedProvider, supportedProviders } from "../types.js"
44

@@ -20,7 +20,7 @@ describe("isSupportedProvider", () => {
2020
})
2121

2222
it("returns false for 'roo' (retired provider)", () => {
23-
expect(isSupportedProvider("roo")).toBe(false)
23+
expect(isSupportedProvider(retiredProviderIdentifiers.roo)).toBe(false)
2424
})
2525

2626
it("returns false for unknown provider", () => {

‎apps/cli/src/ui/__tests__/store.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { providerIdentifiers } from "@roo-code/types"
12
import { RooCodeSettings } from "@roo-code/types"
23

34
import { useCLIStore } from "../store.js"
@@ -168,7 +169,7 @@ describe("useCLIStore", () => {
168169
})
169170

170171
it("should PRESERVE apiConfiguration", () => {
171-
const config: RooCodeSettings = { apiProvider: "openai", apiModelId: "gpt-4" }
172+
const config: RooCodeSettings = { apiProvider: providerIdentifiers.openai, apiModelId: "gpt-4" }
172173

173174
useCLIStore
174175
.getState()

‎apps/vscode-e2e/eslint.config.mjs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { config } from "@roo-code/config-eslint/base"
2+
import { createProviderIdentifierConfig } from "@roo-code/config-eslint/provider-identifiers"
3+
import { providerIdentifiers, retiredProviderIdentifiers } from "@roo-code/types/provider-identifiers"
24

35
/** @type {import("eslint").Linter.Config} */
46
export default [
@@ -15,4 +17,5 @@ export default [
1517
"@typescript-eslint/no-floating-promises": "error",
1618
},
1719
},
20+
createProviderIdentifierConfig({ providerIdentifiers, retiredProviderIdentifiers }),
1821
]

‎apps/vscode-e2e/src/suite/anthropic-opus-4-7.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { providerIdentifiers } from "@roo-code/types"
12
import * as assert from "assert"
23
import { createServer, type IncomingMessage, type ServerResponse } from "http"
34

@@ -177,7 +178,7 @@ suite("Claude Opus 4.7 (Anthropic)", function () {
177178
const aimockUrl = process.env.AIMOCK_URL
178179
const isRecord = process.env.AIMOCK_RECORD === "true"
179180
await globalThis.api.setConfiguration({
180-
apiProvider: "openrouter" as const,
181+
apiProvider: providerIdentifiers.openrouter,
181182
openRouterApiKey: aimockUrl && !isRecord ? "mock-key" : process.env.OPENROUTER_API_KEY!,
182183
openRouterModelId: "openai/gpt-4.1",
183184
...(aimockUrl && { openRouterBaseUrl: `${aimockUrl}/v1` }),
@@ -203,7 +204,7 @@ suite("Claude Opus 4.7 (Anthropic)", function () {
203204
// aimock handles /v1/messages natively and serves Anthropic-format SSE responses.
204205
// In record mode the real x-api-key is forwarded so aimock can proxy to api.anthropic.com.
205206
await api.setConfiguration({
206-
apiProvider: "anthropic" as const,
207+
apiProvider: providerIdentifiers.anthropic,
207208
apiKey: aimockUrl && !isRecord ? "mock-key" : process.env.ANTHROPIC_API_KEY!,
208209
apiModelId: "claude-opus-4-7",
209210
enableReasoningEffort: reasoningEnabled,

‎apps/vscode-e2e/src/suite/index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { providerIdentifiers } from "@roo-code/types"
12
import * as path from "path"
23
import Mocha from "mocha"
34
import { glob } from "glob"
@@ -20,7 +21,7 @@ export async function run() {
2021
const isRecord = process.env.AIMOCK_RECORD === "true"
2122

2223
await api.setConfiguration({
23-
apiProvider: "openrouter" as const,
24+
apiProvider: providerIdentifiers.openrouter,
2425
// In record mode, forward the real key so aimock can proxy it to OpenRouter.
2526
// In replay mode, "mock-key" is sufficient — aimock never contacts the real API.
2627
openRouterApiKey: aimockUrl && !isRecord ? "mock-key" : process.env.OPENROUTER_API_KEY!,

‎apps/vscode-e2e/src/suite/providers/bedrock.test.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { providerIdentifiers } from "@roo-code/types"
12
import * as assert from "assert"
23

34
import { startBedrockMockServer, type BedrockMockServer } from "../../bedrock-mock-server"
@@ -26,7 +27,7 @@ suite("Bedrock provider", function () {
2627
if (!aimockUrl && BEDROCK_LIVE_E2E && AWS_BEARER_TOKEN_BEDROCK) {
2728
// Live mode — explicitly opted into real AWS credentials, no aimock intercepting traffic.
2829
await globalThis.api.setConfiguration({
29-
apiProvider: "bedrock" as const,
30+
apiProvider: providerIdentifiers.bedrock,
3031
awsUseApiKey: true,
3132
awsApiKey: AWS_BEARER_TOKEN_BEDROCK,
3233
awsRegion: BEDROCK_REGION,
@@ -38,7 +39,7 @@ suite("Bedrock provider", function () {
3839
// deserializer to drop the delta field (take() reads top-level only).
3940
mockServer = await startBedrockMockServer()
4041
await globalThis.api.setConfiguration({
41-
apiProvider: "bedrock" as const,
42+
apiProvider: providerIdentifiers.bedrock,
4243
awsUseApiKey: true,
4344
awsApiKey: "mock-key",
4445
awsRegion: BEDROCK_REGION,
@@ -56,7 +57,7 @@ suite("Bedrock provider", function () {
5657
const aimockUrl = process.env.AIMOCK_URL
5758
const isRecord = process.env.AIMOCK_RECORD === "true"
5859
await globalThis.api.setConfiguration({
59-
apiProvider: "openrouter" as const,
60+
apiProvider: providerIdentifiers.openrouter,
6061
openRouterApiKey: aimockUrl && !isRecord ? "mock-key" : process.env.OPENROUTER_API_KEY!,
6162
openRouterModelId: "openai/gpt-4.1",
6263
...(aimockUrl && { openRouterBaseUrl: `${aimockUrl}/v1` }),
@@ -108,15 +109,15 @@ suite("Bedrock provider", function () {
108109
// formation end-to-end.
109110
if (!process.env.AIMOCK_URL && BEDROCK_LIVE_E2E && AWS_BEARER_TOKEN_BEDROCK) {
110111
await api.setConfiguration({
111-
apiProvider: "bedrock" as const,
112+
apiProvider: providerIdentifiers.bedrock,
112113
awsUseApiKey: true,
113114
awsApiKey: AWS_BEARER_TOKEN_BEDROCK,
114115
awsRegion: BEDROCK_REGION,
115116
apiModelId: BEDROCK_OPUS_48_MODEL_ID,
116117
})
117118
} else {
118119
await api.setConfiguration({
119-
apiProvider: "bedrock" as const,
120+
apiProvider: providerIdentifiers.bedrock,
120121
awsUseApiKey: true,
121122
awsApiKey: "mock-key",
122123
awsRegion: BEDROCK_REGION,

‎apps/vscode-e2e/src/suite/providers/deepseek-v4.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { providerIdentifiers } from "@roo-code/types"
12
import * as assert from "assert"
23
import * as fs from "fs/promises"
34
import * as path from "path"
@@ -211,7 +212,7 @@ async function runDeepSeekToolProbe(
211212

212213
try {
213214
await api.setConfiguration({
214-
apiProvider: "deepseek" as const,
215+
apiProvider: providerIdentifiers.deepseek,
215216
deepSeekApiKey: aimockUrl && !isRecord ? "mock-key" : DEEPSEEK_API_KEY!,
216217
...(aimockUrl && { deepSeekBaseUrl: `${aimockUrl}/v1` }),
217218
apiModelId: modelId,
@@ -336,7 +337,7 @@ suite("DeepSeek V4 provider", function () {
336337
const aimockUrl = process.env.AIMOCK_URL
337338
const isRecord = process.env.AIMOCK_RECORD === "true"
338339
await globalThis.api.setConfiguration({
339-
apiProvider: "openrouter" as const,
340+
apiProvider: providerIdentifiers.openrouter,
340341
openRouterApiKey: aimockUrl
341342
? isRecord
342343
? (process.env.OPENROUTER_API_KEY ?? "mock-key")

0 commit comments

Comments
 (0)