Skip to content

chore(lint): Require integrations to be created with defineIntegration - #26937

Open
logaretm wants to merge 1 commit into
developfrom
awad/require-define-integration-lint-rule
Open

logaretm wants to merge 1 commit into
developfrom
awad/require-define-integration-lint-rule

Conversation

@logaretm

@logaretm logaretm commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Following up on ensuring future integrations are created properly using defineIntegration so that their options can be captured, this PR adds a best-effort linting rule that covers most of the integration declaration patterns.

It works by matching the object shape, since we cannot use type information in a lint rule at the moment. It found several cases where we missed calling defineIntegration so I fixed those as well.

Illegal Patterns

// object returned directly
export const fooIntegration = () => ({ name: 'Foo', setup() {} });

// function declaration
export function fooIntegration(): Integration {
  return { name: 'Foo', setupOnce() {} };
}

// built separately, exported without wrapping (alias or cast)
const _fooIntegration = (() => ({ name: 'Foo', processEvent: e => e })) satisfies IntegrationFn;
export const fooIntegration = _fooIntegration as () => Integration;

// another integration in the file is wrapped, this one is not
export const barIntegration = defineIntegration(_barIntegration);
export const fooIntegration = _fooIntegration;

// top-level object
export const foo = { name: 'Foo', afterAllSetup() {} };

Edge cases

// class instance
class Foo { name = 'Foo'; setup() {} }
export const fooIntegration = () => new Foo();

// no literal `name` next to a hook: spread, Object.assign, later assignment, computed key
export const fooIntegration = () => ({ ...base, setup() {} });
export const fooIntegration = () => Object.assign({ name: 'Foo' }, hooks);
export const fooIntegration = () => ({ [NAME_KEY]: 'Foo', setup() {} });

// name only, no hook
export const fooIntegration = () => ({ name: 'Foo' });

// same name appears inside any defineIntegration call, even if not called
defineIntegration(() => { debug.log(_fooIntegration); return other(); });
export const fooIntegration = _fooIntegration;

False Positives

// factory whose result is wrapped in a different file
export function createFooIntegration() {
  return (() => ({ name: 'Foo', setup() {} })) satisfies IntegrationFn;
}

// a new bundler plugin outside the skipped paths
export const plugin = () => ({ name: 'sentry-plugin', setup(build) {} });

Nine integrations returned their object directly, so the options they were
created with were never recorded on `_options`. They are now wrapped, and the
new `sdk/require-define-integration` lint rule flags integration-shaped objects
that do not reach `defineIntegration` within their file.
@logaretm logaretm changed the title ref: Require integrations to be created with defineIntegration chore(lint): Require integrations to be created with defineIntegration Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 3e22ba8 (PR test merge using develop at 901cf40)

Against: 901cf40 (develop) · base run #68191

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.55 kB - -
@sentry/browser - with treeshaking flags 28.74 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.61 kB - -
@sentry/browser (incl. Tracing) 53.68 kB - -
@sentry/browser (incl. Tracing Core) 40.6 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 53.68 kB - -
@sentry/browser (incl. Tracing, Profiling) 56.57 kB - -
@sentry/browser (incl. Tracing, Replay) 93.6 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.4 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 98.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 111.41 kB +0.01% +1 B 🔺
@sentry/browser (incl. Feedback) 48.41 kB - -
@sentry/browser (incl. sendFeedback) 31.12 kB - -
@sentry/browser (incl. FeedbackAsync) 36.18 kB - -
@sentry/browser (incl. Metrics) 31.87 kB - -
@sentry/browser (incl. Logs) 32.15 kB - -
@sentry/browser (incl. Metrics & Logs) 32.81 kB - -
@sentry/react 32.58 kB - -
@sentry/react (incl. Tracing) 56.42 kB - -
@sentry/vue 38.76 kB - -
@sentry/vue (incl. Tracing) 56.69 kB - -
@sentry/svelte 30.58 kB - -
@sentry/effect (client) 42.23 kB - -
@sentry/effect (client, incl. Tracing) 54.97 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 66.32 kB - -
@sentry/remix (Remix 3 client bundle) 59.41 kB - -
CDN Bundle 32.39 kB - -
CDN Bundle (incl. Tracing) 54.05 kB - -
CDN Bundle (incl. Logs, Metrics) 35.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 56.52 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.1 kB - -
CDN Bundle (incl. Tracing, Replay) 91.85 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.8 kB - -
CDN Bundle - uncompressed 94.58 kB - -
CDN Bundle (incl. Tracing) - uncompressed 159.87 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 167.49 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.32 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.3 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 287.93 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.24 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.85 kB - -
@sentry/nextjs (client) 60.09 kB - -
@sentry/sveltekit (client) 55.03 kB - -
@sentry/core/server 45.84 kB - -
@sentry/core/browser 14.48 kB - -
@sentry/node 157.61 kB +0.03% +41 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.45 kB - -
@sentry/node - without tracing 89.88 kB +0.08% +66 B 🔺
@sentry/node - without channel injection 146.59 kB +0.04% +52 B 🔺
@sentry/aws-serverless 100.5 kB +0.07% +63 B 🔺
@sentry/cloudflare (withSentry) - minified 211.97 kB - -
@sentry/cloudflare (withSentry) 491.78 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 214.92 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 237.19 kB -0.01% -20 B 🔽

View base workflow run

@github-actions

Copy link
Copy Markdown
Contributor

Optional E2E tests

All optional checks were successful. 65 successful. See the run.

Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 (MCP SDK OpenTelemetry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hapi-21 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E hono-5 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-4-sourcemaps (Vite server) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps enabled by Sentry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (cloudflare) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details

@logaretm
logaretm marked this pull request as ready for review November 26, 2026 19:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant