Skip to content

Commit 7f79364

Browse files
antonisclaude
andcommitted
fix: Address CI failures — formatting, lint, and typing
- Run oxfmt to fix formatting in src/index.ts - Add explicit return types to test helper functions - Fix TS18048 (possibly undefined) in truncation test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2e4382c commit 7f79364

2 files changed

Lines changed: 21 additions & 20 deletions

File tree

packages/babel-plugin-component-annotate/src/index.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -717,17 +717,19 @@ function extractStaticTextFromChildren(
717717
texts.push(...innerTexts);
718718
} else {
719719
const result = extractStaticTextFromChildren(
720-
t, child, textComponentNames, depth - 1, false
720+
t,
721+
child,
722+
textComponentNames,
723+
depth - 1,
724+
false
721725
);
722726
if (result === null) {
723727
return null;
724728
}
725729
texts.push(...result);
726730
}
727731
} else if (t.isJSXFragment(child)) {
728-
const result = extractStaticTextFromChildren(
729-
t, child, textComponentNames, depth - 1, false
730-
);
732+
const result = extractStaticTextFromChildren(t, child, textComponentNames, depth - 1, false);
731733
if (result === null) {
732734
return null;
733735
}
@@ -807,10 +809,7 @@ function getElementName(
807809
* target for both text extraction and attribute injection (since fragments
808810
* cannot carry attributes).
809811
*/
810-
function maybeInjectSentryLabel(
811-
context: JSXProcessingContext,
812-
jsxNode: Babel.NodePath
813-
): void {
812+
function maybeInjectSentryLabel(context: JSXProcessingContext, jsxNode: Babel.NodePath): void {
814813
const { t, textComponentNames, ignoredComponents, componentName } = context;
815814
const node = jsxNode.node;
816815

@@ -831,9 +830,7 @@ function maybeInjectSentryLabel(
831830
const targetElementName = getElementName(t, targetElement.openingElement);
832831

833832
if (
834-
ignoredComponents.some(
835-
(ignored) => ignored === componentName || ignored === targetElementName
836-
)
833+
ignoredComponents.some((ignored) => ignored === componentName || ignored === targetElementName)
837834
) {
838835
return;
839836
}
@@ -847,7 +844,11 @@ function maybeInjectSentryLabel(
847844
}
848845

849846
const texts = extractStaticTextFromChildren(
850-
t, targetElement, textComponentNames, MAX_TEXT_SEARCH_DEPTH, true
847+
t,
848+
targetElement,
849+
textComponentNames,
850+
MAX_TEXT_SEARCH_DEPTH,
851+
true
851852
);
852853

853854
if (texts === null) {
@@ -865,10 +866,7 @@ function maybeInjectSentryLabel(
865866
}
866867

867868
targetElement.openingElement.attributes.push(
868-
t.jSXAttribute(
869-
t.jSXIdentifier(SENTRY_LABEL_ATTRIBUTE),
870-
t.stringLiteral(label)
871-
)
869+
t.jSXAttribute(t.jSXIdentifier(SENTRY_LABEL_ATTRIBUTE), t.stringLiteral(label))
872870
);
873871
}
874872

packages/babel-plugin-component-annotate/test/sentry-label.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { describe, it, expect } from "vitest";
2-
import { transform } from "@babel/core";
2+
import { transform, BabelFileResult } from "@babel/core";
33
import plugin from "../src/index";
44

5-
function transformWith(code: string, opts: Record<string, unknown> = {}) {
5+
function transformWith(code: string, opts: Record<string, unknown> = {}): BabelFileResult | null {
66
return transform(code, {
77
filename: "/filename-test.js",
88
configFile: false,
@@ -11,7 +11,10 @@ function transformWith(code: string, opts: Record<string, unknown> = {}) {
1111
});
1212
}
1313

14-
function transformWithout(code: string, opts: Record<string, unknown> = {}) {
14+
function transformWithout(
15+
code: string,
16+
opts: Record<string, unknown> = {}
17+
): BabelFileResult | null {
1518
return transform(code, {
1619
filename: "/filename-test.js",
1720
configFile: false,
@@ -311,7 +314,7 @@ describe("autoInjectSentryLabel", () => {
311314
`);
312315
const match = result?.code?.match(/"sentry-label": "([^"]+)"/);
313316
expect(match).toBeTruthy();
314-
const label = match![1];
317+
const label = match?.[1] ?? "";
315318
expect(label.length).toBe(64);
316319
expect(label.endsWith("...")).toBe(true);
317320
expect(label).toBe("This is an extremely long text that definitely exceeds the si...");

0 commit comments

Comments
 (0)