Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint: fix unused vars by prefixing _
  • Loading branch information
logaretm committed Mar 10, 2026
commit d840f01286043ba40084a249aa17c0b2ea2d5852
2 changes: 2 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
],
"categories": {},
"rules": {
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],

// === Base rules from eslint-config-sdk/base.js ===
"no-console": "error",
"no-alert": "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ export function replayEnvelopeIsCompressed(resOrReq: Request | Response): boolea
const lines: boolean[] = envelopeString.split('\n').map(line => {
try {
JSON.parse(line);
} catch (error) {
} catch (_error) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just me being curious and doing user research on lint users, feel free to ignore me 😄. Is there a reason to keep these around?

Suggested change
} catch (_error) {
} {

Per https://docs.sentry.io/platforms/javascript/guides/node/#prerequisites's Node >=18.0.0 support, ES2019's optional catch binding should be supported by all consumers.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You make a good point, I asked the team and we do have errorless catches in the codebase already, so I will do just that. Thanks!

My approach here was change as little as possible, but this is an opportunity for smaller bundle size.

// If we fail to parse a line, we _might_ have found a compressed payload,
// so let's check if this is actually the case.
// This is quite hacky but we can't go through `line` because the prior operations
Expand Down Expand Up @@ -394,7 +394,7 @@ export const replayEnvelopeParser = (request: Request | null): unknown[] => {
const lines = envelopeString.split('\n').map(line => {
try {
return JSON.parse(line);
} catch (error) {
} catch (_error) {
// If we fail to parse a line, we _might_ have found a compressed payload,
// so let's check if this is actually the case.
// This is quite hacky but we can't go through `line` because the prior operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function run() {
},
],
});
} catch (error) {
} catch (_error) {
// Expected error
}
});
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/node-overhead-gh-action/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async function run() {
body,
});
}
} catch (error) {
} catch (_error) {
core.error(
"Error updating comment. This can happen for PR's originating from a fork without write permissions.",
);
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/size-limit-gh-action/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async function run() {
body,
});
}
} catch (error) {
} catch (_error) {
core.error(
"Error updating comment. This can happen for PR's originating from a fork without write permissions.",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function initUnique<T>(identityObj: object, ClassObj: new () => T): T {
instanceMap.set(identityObj, new ClassObj());
}
return instanceMap.get(identityObj)! as T;
} catch (e) {
} catch (_e) {
// --- START Sentry-custom code (try/catch wrapping) ---
// Fix for cases where identityObj is not a valid key for WeakMap (sometimes a problem in Safari)
// Just return a new instance without caching it in instanceMap
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/profiling/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ export function startJSSelfProfile(): JSSelfProfiler | undefined {
// as we risk breaking the user's application, so just disable profiling and log an error.
try {
return new JSProfilerConstructor({ sampleInterval: samplingIntervalMS, maxBufferSize: maxSamples });
} catch (e) {
} catch (_e) {
if (DEBUG_BUILD) {
debug.log(
"[Profiling] Failed to initialize the Profiling constructor, this is likely due to a missing 'Document-Policy': 'js-profiling' header.",
Expand Down
2 changes: 1 addition & 1 deletion packages/bun/scripts/install-bun.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const https = require('https');
const installScriptUrl = 'https://bun.sh/install';

// Check if bun is installed
exec('bun --version', (error, version) => {
exec('bun --version', (error, _version) => {
if (error) {
console.error('bun is not installed. Installing...');
installLatestBun();
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function wrapRequestHandler(
statusText: res.statusText,
headers: res.headers,
});
} catch (e) {
} catch (_e) {
// tee() failed (e.g stream already locked) - fall back to non-streaming handling
span.end();
waitUntil?.(flushAndDispose(client));
Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/test/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const mockStep: WorkflowStep = {
} else {
return await (maybeCallback ? maybeCallback() : Promise.resolve());
}
} catch (error) {
} catch (_error) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/integrations/mcp-server/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function captureHandlerError(error: Error, methodName: keyof MCPServerInstance,
extraData.prompt_name = handlerName;
captureError(error, 'prompt_execution', extraData);
}
} catch (captureErr) {
} catch (_captureErr) {
// noop
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/utils/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function replaceExports(
// Replace the named export - handle read-only properties
try {
exports[exportName] = wrappedConstructor;
} catch (error) {
} catch (_error) {
// If direct assignment fails, override the property descriptor
Object.defineProperty(exports, exportName, {
value: wrappedConstructor,
Expand All @@ -35,7 +35,7 @@ export function replaceExports(
if (exports.default === original) {
try {
exports.default = wrappedConstructor;
} catch (error) {
} catch (_error) {
Object.defineProperty(exports, 'default', {
value: wrappedConstructor,
writable: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/lib/transports/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ describe('createTransport', () => {

try {
await transport.send(CLIENT_REPORT_ENVELOPE);
} catch (e) {
} catch (_e) {
// Expected to throw
}

Expand Down Expand Up @@ -383,7 +383,7 @@ describe('createTransport', () => {

try {
await transport.send(ERROR_ENVELOPE);
} catch (e) {
} catch (_e) {
// Expected to throw
}

Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/utils/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function streamResponse(span: Span, res: Response): Promise<Respons
headers: res.headers,
},
);
} catch (e) {
} catch (_e) {
// tee() failed - handle without streaming
span.end();
return res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('GCPFunction', () => {

try {
fn(req, res);
} catch (error) {
} catch (_error) {
res.end();
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/node-core/src/transports/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function makeNodeTransport(options: NodeTransportOptions): Transport {

try {
urlSegments = new URL(options.url);
} catch (e) {
} catch (_e) {
consoleSandbox(() => {
// eslint-disable-next-line no-console
console.warn(
Expand Down
2 changes: 1 addition & 1 deletion packages/node-core/src/utils/captureRequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function patchRequestToCaptureBody(
`Dropping request body chunk because maximum body length of ${maxBodySize}b is exceeded.`,
);
}
} catch (err) {
} catch (_err) {
DEBUG_BUILD && debug.error(integrationName, 'Encountered error while storing body chunk.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class SentryAnthropicAiInstrumentation extends InstrumentationBase<Anthro
// The Anthropic property might have only a getter, so use defineProperty
try {
exports.Anthropic = WrappedAnthropic;
} catch (error) {
} catch (_error) {
// If direct assignment fails, override the property descriptor
Object.defineProperty(exports, 'Anthropic', {
value: WrappedAnthropic,
Expand All @@ -105,7 +105,7 @@ export class SentryAnthropicAiInstrumentation extends InstrumentationBase<Anthro
if (exports.default === Original) {
try {
exports.default = WrappedAnthropic;
} catch (error) {
} catch (_error) {
// If direct assignment fails, override the property descriptor
Object.defineProperty(exports, 'default', {
value: WrappedAnthropic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class SentryOpenAiInstrumentation extends InstrumentationBase<OpenAiInstr
// The OpenAI property might have only a getter, so use defineProperty
try {
exports[exportKey] = WrappedOpenAI;
} catch (error) {
} catch (_error) {
// If direct assignment fails, override the property descriptor
Object.defineProperty(exports, exportKey, {
value: WrappedOpenAI,
Expand All @@ -119,7 +119,7 @@ export class SentryOpenAiInstrumentation extends InstrumentationBase<OpenAiInstr
if (exports.default === Original) {
try {
exports.default = WrappedOpenAI;
} catch (error) {
} catch (_error) {
// If direct assignment fails, override the property descriptor
Object.defineProperty(exports, 'default', {
value: WrappedOpenAI,
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/runtime/plugins/storage.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function isCacheHit(key: string, value: unknown): boolean {
}

return validateCacheEntry(key, JSON.parse(String(value)) as CacheEntry);
} catch (error) {
} catch (_error) {
// this is a best effort, so we return false if we can't validate the cache entry
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hoist-non-react-statics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function hoistNonReactStatics<
try {
// Avoid failures from read-only properties
defineProperty(targetComponent, key, descriptor);
} catch (e) {
} catch (_e) {
// Silently ignore errors
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/src/client/remixRouteParameterization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function getManifest(): RouteManifest | null {
cachedManifest = manifest;
cachedManifestString = currentManifestString;
return manifest;
} catch (error) {
} catch (_error) {
DEBUG_BUILD && debug.warn('Could not extract route manifest');
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sveltekit/test/server-common/handle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe('sentryHandle', () => {
it('send errors to Sentry', async () => {
try {
await sentryHandle()({ event: mockEvent(), resolve: resolve(type, isError) });
} catch (e) {
} catch (_e) {
expect(mockCaptureException).toBeCalledTimes(1);
expect(mockCaptureException).toBeCalledWith(expect.any(Error), {
mechanism: { handled: false, type: 'auto.function.sveltekit.handle' },
Expand Down