Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix: API guideline violations (boolean naming, displayName) (#135)

Cindy Zhang1e78a8ff7608
diff --git a/apps/storybook/stories/Heading.stories.tsx b/apps/storybook/stories/Heading.stories.tsx
index c1ed730182..f4c5f6ee82 100644
--- a/apps/storybook/stories/Heading.stories.tsx
+++ b/apps/storybook/stories/Heading.stories.tsx
@@ -301,7 +301,7 @@ export const MultiLineTruncation: Story = {
export const TruncationWithoutTooltip: Story = {
render: () => (
<div style={{width: '300px', border: '1px solid #ccc', padding: '12px'}}>
- <XDSHeading level={2} maxLines={1} truncateTooltip={false}>
+ <XDSHeading level={2} maxLines={1} hasTruncateTooltip={false}>
Truncated Heading Without Tooltip On Hover
</XDSHeading>
</div>
diff --git a/apps/storybook/stories/Text.stories.tsx b/apps/storybook/stories/Text.stories.tsx
index d6a9d3edf6..f6c9ede10a 100644
--- a/apps/storybook/stories/Text.stories.tsx
+++ b/apps/storybook/stories/Text.stories.tsx
@@ -242,7 +242,7 @@ export const MultiLineTruncation: Story = {
export const TruncationWithoutTooltip: Story = {
render: () => (
<div style={{width: '300px', border: '1px solid #ccc', padding: '12px'}}>
- <XDSText type="body" maxLines={1} truncateTooltip={false}>
+ <XDSText type="body" maxLines={1} hasTruncateTooltip={false}>
This text is truncated but has no tooltip on hover. Sometimes you don't
want a tooltip.
</XDSText>
diff --git a/packages/core/src/Table/XDSBaseTable.tsx b/packages/core/src/Table/XDSBaseTable.tsx
index 84a7c6c1ca..b31ba8d40b 100644
--- a/packages/core/src/Table/XDSBaseTable.tsx
+++ b/packages/core/src/Table/XDSBaseTable.tsx
@@ -316,3 +316,6 @@ export const XDSBaseTable = forwardRef(XDSBaseTableInner) as <
>(
props: XDSBaseTableProps<T> & {ref?: Ref<HTMLTableElement>},
) => ReactElement;
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+(XDSBaseTable as any).displayName = 'XDSBaseTable';
diff --git a/packages/core/src/Table/XDSTable.tsx b/packages/core/src/Table/XDSTable.tsx
index 565f4630ff..96c6a24b0f 100644
--- a/packages/core/src/Table/XDSTable.tsx
+++ b/packages/core/src/Table/XDSTable.tsx
@@ -235,3 +235,6 @@ export const XDSTable = forwardRef(XDSTableInner) as <
>(
props: XDSTableProps<T> & {ref?: Ref<HTMLTableElement>},
) => ReactElement;
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+(XDSTable as any).displayName = 'XDSTable';
diff --git a/packages/core/src/Text/XDSFontWrapper.tsx b/packages/core/src/Text/XDSFontWrapper.tsx
index b5a2a2dc94..a02bd95642 100644
--- a/packages/core/src/Text/XDSFontWrapper.tsx
+++ b/packages/core/src/Text/XDSFontWrapper.tsx
@@ -97,6 +97,8 @@ export function XDSFontWrapper({
);
}
+XDSFontWrapper.displayName = 'XDSFontWrapper';
+
/**
* Hook to access font wrapper styles from the current theme.
* Use this for applying styles to native HTML elements programmatically.
diff --git a/packages/core/src/Text/XDSHeading.test.tsx b/packages/core/src/Text/XDSHeading.test.tsx
index e5d5bf333d..a73fb1c7ae 100644
--- a/packages/core/src/Text/XDSHeading.test.tsx
+++ b/packages/core/src/Text/XDSHeading.test.tsx
@@ -174,10 +174,10 @@ describe('XDSHeading', () => {
expect(screen.getByText('Heading with word break')).toBeInTheDocument();
});
- it('accepts truncateTooltip=false to disable tooltip', () => {
+ it('accepts hasTruncateTooltip=false to disable tooltip', () => {
render(
<XDSTheme theme={defaultTheme}>
- <XDSHeading level={1} maxLines={1} truncateTooltip={false}>
+ <XDSHeading level={1} maxLines={1} hasTruncateTooltip={false}>
No tooltip
</XDSHeading>
</XDSTheme>,
diff --git a/packages/core/src/Text/XDSHeading.tsx b/packages/core/src/Text/XDSHeading.tsx
index 9ca266b0a4..c6b99a2767 100644
--- a/packages/core/src/Text/XDSHeading.tsx
+++ b/packages/core/src/Text/XDSHeading.tsx
@@ -100,7 +100,7 @@ export interface XDSHeadingProps {
* - Position value: show tooltip at specific position
* @default true
*/
- truncateTooltip?: boolean | LayerPlacement;
+ hasTruncateTooltip?: boolean | LayerPlacement;
/**
* Word break behavior for truncated text.
@@ -188,7 +188,7 @@ export const XDSHeading = forwardRef<HTMLHeadingElement, XDSHeadingProps>(
color = 'primary',
display = 'block',
maxLines = 0,
- truncateTooltip = true,
+ hasTruncateTooltip = true,
wordBreak,
textWrap,
hasCapsize = false,
@@ -228,9 +228,9 @@ export const XDSHeading = forwardRef<HTMLHeadingElement, XDSHeadingProps>(
// Tooltip for truncated text
const tooltipPlacement: LayerPlacement =
- typeof truncateTooltip === 'string' ? truncateTooltip : 'above';
+ typeof hasTruncateTooltip === 'string' ? hasTruncateTooltip : 'above';
const tooltipEnabled =
- maxLines > 0 && truncateTooltip !== false && truncation.isTruncated;
+ maxLines > 0 && hasTruncateTooltip !== false && truncation.isTruncated;
const tooltip = useXDSTooltip({
placement: tooltipPlacement,
@@ -297,3 +297,5 @@ export const XDSHeading = forwardRef<HTMLHeadingElement, XDSHeadingProps>(
);
},
);
+
+XDSHeading.displayName = 'XDSHeading';
diff --git a/packages/core/src/Text/XDSText.test.tsx b/packages/core/src/Text/XDSText.test.tsx
index 58a7649840..6174ab1406 100644
--- a/packages/core/src/Text/XDSText.test.tsx
+++ b/packages/core/src/Text/XDSText.test.tsx
@@ -213,10 +213,10 @@ describe('XDSText', () => {
expect(screen.getByText('Text with word break')).toBeInTheDocument();
});
- it('accepts truncateTooltip=false to disable tooltip', () => {
+ it('accepts hasTruncateTooltip=false to disable tooltip', () => {
render(
<XDSTheme theme={defaultTheme}>
- <XDSText type="body" maxLines={1} truncateTooltip={false}>
+ <XDSText type="body" maxLines={1} hasTruncateTooltip={false}>
No tooltip
</XDSText>
</XDSTheme>,
diff --git a/packages/core/src/Text/XDSText.tsx b/packages/core/src/Text/XDSText.tsx
index 452013a9b3..1ed9c9e891 100644
--- a/packages/core/src/Text/XDSText.tsx
+++ b/packages/core/src/Text/XDSText.tsx
@@ -90,7 +90,7 @@ export interface XDSTextProps {
* - Position value: show tooltip at specific position
* @default true
*/
- truncateTooltip?: boolean | LayerPlacement;
+ hasTruncateTooltip?: boolean | LayerPlacement;
/**
* Word break behavior for truncated text.
@@ -182,7 +182,7 @@ export const XDSText = forwardRef<HTMLElement, XDSTextProps>(function XDSText(
weight,
display = 'inline',
maxLines = 0,
- truncateTooltip = true,
+ hasTruncateTooltip = true,
wordBreak,
textWrap,
hasCapsize = false,
@@ -214,9 +214,9 @@ export const XDSText = forwardRef<HTMLElement, XDSTextProps>(function XDSText(
// Tooltip for truncated text
const tooltipPlacement: LayerPlacement =
- typeof truncateTooltip === 'string' ? truncateTooltip : 'above';
+ typeof hasTruncateTooltip === 'string' ? hasTruncateTooltip : 'above';
const tooltipEnabled =
- maxLines > 0 && truncateTooltip !== false && truncation.isTruncated;
+ maxLines > 0 && hasTruncateTooltip !== false && truncation.isTruncated;
const tooltip = useXDSTooltip({
placement: tooltipPlacement,
@@ -283,3 +283,5 @@ export const XDSText = forwardRef<HTMLElement, XDSTextProps>(function XDSText(
</>
);
});
+
+XDSText.displayName = 'XDSText';
diff --git a/packages/core/src/theme/XDSTheme.tsx b/packages/core/src/theme/XDSTheme.tsx
index 21ab41324a..2479580bf6 100644
--- a/packages/core/src/theme/XDSTheme.tsx
+++ b/packages/core/src/theme/XDSTheme.tsx
@@ -117,5 +117,7 @@ export function XDSTheme({
);
}
+XDSTheme.displayName = 'XDSTheme';
+
/** @deprecated Use XDSTheme instead */
export const Theme = XDSTheme;