From b71e0be7860c426fa3e345afde32aca8e8884e29 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 13 Nov 2026 08:39:03 +0100 Subject: [PATCH] chore(bundler-plugins): Type-check tests via lint:types `check:types` was never run in CI, so the test type errors it would have caught went unnoticed. Extend `lint:types` (which CI runs) to cover `test` and drop `check:types`. Co-Authored-By: Claude Opus 5.5 --- packages/bundler-plugins/package.json | 6 +----- packages/bundler-plugins/test/core/cli-contract.test.ts | 1 + .../test/core/component-annotation-oxc.test.ts | 8 +++++--- packages/bundler-plugins/test/webpack/injection.test.ts | 6 +++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/bundler-plugins/package.json b/packages/bundler-plugins/package.json index 69ac934fb8cf..f5f84428eabd 100644 --- a/packages/bundler-plugins/package.json +++ b/packages/bundler-plugins/package.json @@ -79,18 +79,14 @@ "build:types": "tsc -p tsconfig.types.json", "build:tarball": "pnpm pack", "prebuild": "pnpm run build:version", - "precheck:types": "pnpm run build:version", "prelint:types": "pnpm run build:version", "pretest": "pnpm run build:version", "pretest:unit": "pnpm run build:version", - "check:types": "pnpm run \"/^check:types:(src|test)$/\"", - "check:types:src": "tsc --project ./tsconfig.json --noEmit", - "check:types:test": "tsc --project ./test/tsconfig.json --noEmit", "clean": "node ../../scripts/rm.mjs build dist coverage sentry-bundler-plugins-*.tgz", "clean:all": "pnpm run \"/^(clean|clean:deps)$/\"", "clean:deps": "node ../../scripts/rm.mjs node_modules", "lint": "oxlint . --type-aware", - "lint:types": "oxlint src --type-aware --type-check", + "lint:types": "oxlint src test --type-aware --type-check", "lint:fix": "oxlint . --fix --type-aware", "test": "vitest run", "test:unit": "vitest run" diff --git a/packages/bundler-plugins/test/core/cli-contract.test.ts b/packages/bundler-plugins/test/core/cli-contract.test.ts index dc53bf4427bd..afd7ffaa2383 100644 --- a/packages/bundler-plugins/test/core/cli-contract.test.ts +++ b/packages/bundler-plugins/test/core/cli-contract.test.ts @@ -35,6 +35,7 @@ interface RecordedRequest { method: string; url: string; jsonBody?: unknown; + requestHeaders: Record; } function recordedRequestRecords(): RecordedRequest[] { diff --git a/packages/bundler-plugins/test/core/component-annotation-oxc.test.ts b/packages/bundler-plugins/test/core/component-annotation-oxc.test.ts index c2c57bd07799..bc64b293c4af 100644 --- a/packages/bundler-plugins/test/core/component-annotation-oxc.test.ts +++ b/packages/bundler-plugins/test/core/component-annotation-oxc.test.ts @@ -1,4 +1,4 @@ -import { transformAsync, traverse, types as t } from '@babel/core'; +import { parseSync, transformAsync, traverse, types as t } from '@babel/core'; import { parse } from '@babel/parser'; import MagicString from 'magic-string'; import { describe, expect, it, vi } from 'vitest'; @@ -26,9 +26,11 @@ async function parseAstAsync(code: string, options: { lang: 'jsx' | 'tsx' }): Pr } function collectAnnotations(code: string, id: string): Annotation[] { - const ast = parse(code, { + const ast = parseSync(code, { + babelrc: false, + configFile: false, sourceType: 'module', - plugins: id.endsWith('.tsx') ? ['jsx', 'typescript'] : ['jsx'], + parserOpts: { plugins: id.endsWith('.tsx') ? ['jsx', 'typescript'] : ['jsx'] }, }); const annotations: Annotation[] = []; diff --git a/packages/bundler-plugins/test/webpack/injection.test.ts b/packages/bundler-plugins/test/webpack/injection.test.ts index baf74dc6b7db..b5f2c6783040 100644 --- a/packages/bundler-plugins/test/webpack/injection.test.ts +++ b/packages/bundler-plugins/test/webpack/injection.test.ts @@ -56,7 +56,11 @@ function runWebpackSourceInjection( compilationCallback(compilation); processAssets(assets); - return assets[assetName]; + const result = assets[assetName]; + if (!result) { + throw new Error(`Asset ${assetName} was removed during injection`); + } + return result; } function runWebpackInjection(assetName: string, code: string, chunks?: TestChunk[]): string {