Skip to content

Commit 90e2d8a

Browse files
authored
chore: fix unused vars not being flagged by our lint tooling (#14329)
## Summary we have a ton of unused variables in our codebase. For some reason, the lint rules to flag these were disabled. This PR fixes only the violations flagged by `oxlint` - it's already a bunch. We can open another PR for the TypeScript flagged problems. `oxlint` finds many false positives in tests, and since this is less important for tests anyway, we can just disable the rule for test files. To reduce the scope, we still ignore those errors in `examples/` for now - also because some of the unused variables in `examples` are intentionally there. ## Checklist - [ ] Tests have been added / updated (for bug fixes / features) - [ ] Documentation has been added / updated (for bug fixes / features) - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review)
1 parent 6e706db commit 90e2d8a

47 files changed

Lines changed: 89 additions & 114 deletions

Some content is hidden

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

.changeset/twelve-moons-hang.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
"@ai-sdk/openai-compatible": patch
3+
"@ai-sdk/amazon-bedrock": patch
4+
"@ai-sdk/open-responses": patch
5+
"@ai-sdk/provider-utils": patch
6+
"@ai-sdk/google-vertex": patch
7+
"@ai-sdk/moonshotai": patch
8+
"@ai-sdk/togetherai": patch
9+
"@ai-sdk/anthropic": patch
10+
"@ai-sdk/deepinfra": patch
11+
"@ai-sdk/fireworks": patch
12+
"@ai-sdk/cerebras": patch
13+
"@ai-sdk/devtools": patch
14+
"@ai-sdk/alibaba": patch
15+
"@ai-sdk/baseten": patch
16+
"@ai-sdk/codemod": patch
17+
"@ai-sdk/gateway": patch
18+
"@ai-sdk/cohere": patch
19+
"@ai-sdk/google": patch
20+
"@ai-sdk/openai": patch
21+
"@ai-sdk/vercel": patch
22+
"@ai-sdk/react": patch
23+
"@ai-sdk/groq": patch
24+
"@ai-sdk/luma": patch
25+
"@ai-sdk/otel": patch
26+
"@ai-sdk/fal": patch
27+
"@ai-sdk/mcp": patch
28+
"@ai-sdk/xai": patch
29+
"ai": patch
30+
---
31+
32+
chore: fix unused vars not being flagged by our lint tooling

.oxlintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"rules": {
1212
"no-redeclare": "off"
1313
}
14+
},
15+
{
16+
"files": ["examples/**", "**/*.test.ts"],
17+
"rules": {
18+
"no-unused-vars": "off"
19+
}
1420
}
1521
],
1622
"rules": {
@@ -64,7 +70,7 @@
6470
"no-unneeded-ternary": "off",
6571
"no-unsafe-finally": "off",
6672
"no-unused-expressions": "off",
67-
"no-unused-vars": "off",
73+
"no-unused-vars": "error",
6874
"no-use-before-define": "off",
6975
"no-useless-catch": "off",
7076
"no-useless-concat": "off",

packages/ai/src/generate-object/generate-object.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,11 @@ import { standardizePrompt } from '../prompt/standardize-prompt';
1919
import { wrapGatewayError } from '../prompt/wrap-gateway-error';
2020
import { getGlobalTelemetryIntegration } from '../telemetry/get-global-telemetry-integration';
2121
import { TelemetrySettings } from '../telemetry/telemetry-settings';
22-
import {
23-
CallWarning,
24-
FinishReason,
25-
LanguageModel,
26-
} from '../types/language-model';
22+
import { LanguageModel } from '../types/language-model';
2723
import { LanguageModelRequestMetadata } from '../types/language-model-request-metadata';
2824
import { LanguageModelResponseMetadata } from '../types/language-model-response-metadata';
29-
import { ProviderMetadata } from '../types/provider-metadata';
30-
import { asLanguageModelUsage, LanguageModelUsage } from '../types/usage';
25+
26+
import { asLanguageModelUsage } from '../types/usage';
3127
import { DownloadFunction } from '../util/download/download-function';
3228
import { notify } from '../util/notify';
3329
import type { Listener } from '../util/notify';

packages/ai/src/generate-object/output-strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const arrayOutputStrategy = <ELEMENT>(
141141
// possible future optimization: use arrays directly when model supports grammar-guided generation
142142
jsonSchema: async () => {
143143
// remove $schema from schema.jsonSchema:
144-
const { $schema, ...itemSchema } = await schema.jsonSchema;
144+
const { $schema: _$schema, ...itemSchema } = await schema.jsonSchema;
145145

146146
return {
147147
$schema: 'http://json-schema.org/draft-07/schema#',

packages/ai/src/generate-text/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export const array = <ELEMENT>({
218218
// JSON schema that describes an array of elements:
219219
responseFormat: resolve(elementSchema.jsonSchema).then(jsonSchema => {
220220
// remove $schema from schema.jsonSchema:
221-
const { $schema, ...itemSchema } = jsonSchema;
221+
const { $schema: _$schema, ...itemSchema } = jsonSchema;
222222

223223
return {
224224
type: 'json' as const,

packages/ai/src/prompt/convert-to-language-model-prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ async function downloadAssets(
412412
if (typeof data === 'string') {
413413
try {
414414
data = new URL(data);
415-
} catch (ignored) {}
415+
} catch {}
416416
}
417417

418418
return { mediaType, data };

packages/ai/src/prompt/data-content.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function convertToLanguageModelV4DataContent(
4444
if (typeof content === 'string') {
4545
try {
4646
content = new URL(content);
47-
} catch (error) {
47+
} catch {
4848
// ignored
4949
}
5050
}
@@ -128,7 +128,7 @@ export function convertDataContentToUint8Array(
128128
export function convertUint8ArrayToText(uint8Array: Uint8Array): string {
129129
try {
130130
return new TextDecoder().decode(uint8Array);
131-
} catch (error) {
131+
} catch {
132132
throw new Error('Error decoding Uint8Array to text');
133133
}
134134
}

packages/ai/src/prompt/split-data-url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function splitDataUrl(dataUrl: string): {
88
mediaType: header.split(';')[0].split(':')[1],
99
base64Content,
1010
};
11-
} catch (error) {
11+
} catch {
1212
return {
1313
mediaType: undefined,
1414
base64Content: undefined,

packages/ai/src/telemetry/get-global-telemetry-integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export function bindTelemetryIntegration(
3434
}
3535

3636
export function getGlobalTelemetryIntegration<
37-
TOOLS extends ToolSet = ToolSet,
38-
OUTPUT extends Output = Output,
37+
_TOOLS extends ToolSet = ToolSet,
38+
_OUTPUT extends Output = Output,
3939
>(): (args?: {
4040
integrations?: TelemetryIntegration | Array<TelemetryIntegration>;
4141
}) => TelemetryIntegration {

packages/ai/src/ui-message-stream/create-ui-message-stream.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function createUIMessageStream<UI_MESSAGE extends UIMessage>({
6666
function safeEnqueue(data: InferUIMessageChunk<UI_MESSAGE>) {
6767
try {
6868
controller.enqueue(data);
69-
} catch (error) {
69+
} catch {
7070
// suppress errors when the stream has been closed
7171
}
7272
}
@@ -129,7 +129,7 @@ export function createUIMessageStream<UI_MESSAGE extends UIMessage>({
129129
waitForStreams.finally(() => {
130130
try {
131131
controller.close();
132-
} catch (error) {
132+
} catch {
133133
// suppress errors when the stream has been closed
134134
}
135135
});

0 commit comments

Comments
 (0)