From 3cd25e13063a4e211a8bf92adbc44c9b6f91c153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Thu, 17 Oct 2024 16:21:42 +0200 Subject: [PATCH 1/7] Migrate to new typography APIs --- .eslintrc.js | 3 +++ package-lock.json | 4 ++-- package.json | 4 ++-- packages/circuit-ui/components/Body/Body.spec.tsx | 3 ++- packages/circuit-ui/components/Body/Body.stories.tsx | 1 + packages/circuit-ui/components/Calendar/Calendar.tsx | 2 +- packages/circuit-ui/components/Card/Card.stories.tsx | 2 +- .../components/Carousel/components/Status/Status.tsx | 6 +----- .../circuit-ui/components/ListItem/ListItem.spec.tsx | 8 ++++---- .../components/ListItem/ListItem.stories.tsx | 12 ++++++------ packages/circuit-ui/components/ListItem/ListItem.tsx | 8 ++++---- .../components/ListItemGroup/ListItemGroup.spec.tsx | 4 ++-- .../ListItemGroup/ListItemGroup.stories.tsx | 11 ++++++----- .../components/ListItemGroup/ListItemGroup.tsx | 4 ++-- .../circuit-ui/components/Modal/Modal.stories.tsx | 6 +++--- .../NotificationFullscreen.tsx | 2 +- .../NotificationInline/NotificationInline.tsx | 7 ++----- .../NotificationModal/NotificationModal.tsx | 2 +- .../NotificationToast/NotificationToast.tsx | 2 +- .../DesktopNavigation/DesktopNavigation.tsx | 2 +- .../components/SecondaryLinks/SecondaryLinks.tsx | 6 +----- .../SidePanel/components/Header/Header.tsx | 2 +- .../components/Step/examples/MultiStepForm.tsx | 2 +- .../circuit-ui/components/Toggletip/Toggletip.tsx | 4 ++-- .../TopNavigation/TopNavigation.stories.tsx | 2 +- .../components/ProfileMenu/ProfileMenu.tsx | 4 ++-- 26 files changed, 54 insertions(+), 59 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 8633d64339..fec365e33b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,6 +18,9 @@ module.exports = require('@sumup-oss/foundry/eslint')({ rules: { '@sumup-oss/circuit-ui/no-invalid-custom-properties': 'error', '@sumup-oss/circuit-ui/no-deprecated-custom-properties': 'error', + '@sumup-oss/circuit-ui/no-deprecated-props': 'error', + '@sumup-oss/circuit-ui/no-deprecated-components': 'error', + '@sumup-oss/circuit-ui/no-renamed-props': 'error', '@sumup-oss/circuit-ui/prefer-custom-properties': 'warn', 'react/no-unknown-property': ['error', { ignore: ['css'] }], }, diff --git a/package-lock.json b/package-lock.json index 10f0381eae..1c4ebac3bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,9 +33,9 @@ "@storybook/source-loader": "^8.2.4", "@storybook/test": "^8.2.4", "@storybook/theming": "^8.2.4", - "@sumup-oss/eslint-plugin-circuit-ui": "^4.0.0", + "@sumup-oss/eslint-plugin-circuit-ui": "^5.0.0-next.1", "@sumup-oss/foundry": "^8.2.0", - "@sumup-oss/stylelint-plugin-circuit-ui": "^2.0.0", + "@sumup-oss/stylelint-plugin-circuit-ui": "^3.0.0-next.1", "@types/node": "^22.7.4", "@vitest/coverage-v8": "^2.0.5", "audit-ci": "^7.1.0", diff --git a/package.json b/package.json index 0d6d8b71c5..d87fea3eaf 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "@storybook/test": "^8.2.4", "@storybook/theming": "^8.2.4", "@sumup-oss/foundry": "^8.2.0", - "@sumup-oss/eslint-plugin-circuit-ui": "^4.0.0", - "@sumup-oss/stylelint-plugin-circuit-ui": "^2.0.0", + "@sumup-oss/eslint-plugin-circuit-ui": "^5.0.0-next.1", + "@sumup-oss/stylelint-plugin-circuit-ui": "^3.0.0-next.1", "@types/node": "^22.7.4", "@vitest/coverage-v8": "^2.0.5", "audit-ci": "^7.1.0", diff --git a/packages/circuit-ui/components/Body/Body.spec.tsx b/packages/circuit-ui/components/Body/Body.spec.tsx index 6997981609..fd6a471bcb 100644 --- a/packages/circuit-ui/components/Body/Body.spec.tsx +++ b/packages/circuit-ui/components/Body/Body.spec.tsx @@ -43,12 +43,13 @@ describe('Body', () => { }); it('should render the "highlight" variant as a "strong" element', () => { - const { container } = render(Highlight); + const { container } = render(Highlight); const actual = container.querySelector('strong'); expect(actual).toBeVisible(); }); it('should render the "quote" variant as a "blockquote" element', () => { + // eslint-disable-next-line @sumup-oss/circuit-ui/no-deprecated-props const { container } = render(Quote); const actual = container.querySelector('blockquote'); expect(actual).toBeVisible(); diff --git a/packages/circuit-ui/components/Body/Body.stories.tsx b/packages/circuit-ui/components/Body/Body.stories.tsx index b993f03868..78f597818b 100644 --- a/packages/circuit-ui/components/Body/Body.stories.tsx +++ b/packages/circuit-ui/components/Body/Body.stories.tsx @@ -93,6 +93,7 @@ const variants = ['highlight', 'quote', 'confirm', 'alert', 'subtle'] as const; export const Variants = (args: BodyProps) => variants.map((variant) => ( + // eslint-disable-next-line @sumup-oss/circuit-ui/no-deprecated-props This is a {variant} body diff --git a/packages/circuit-ui/components/Calendar/Calendar.tsx b/packages/circuit-ui/components/Calendar/Calendar.tsx index 18c3a6facd..e9d56c4489 100644 --- a/packages/circuit-ui/components/Calendar/Calendar.tsx +++ b/packages/circuit-ui/components/Calendar/Calendar.tsx @@ -396,7 +396,7 @@ function Month({ > ( - + Card heading ); diff --git a/packages/circuit-ui/components/Carousel/components/Status/Status.tsx b/packages/circuit-ui/components/Carousel/components/Status/Status.tsx index 8642491973..d24a288ac8 100644 --- a/packages/circuit-ui/components/Carousel/components/Status/Status.tsx +++ b/packages/circuit-ui/components/Carousel/components/Status/Status.tsx @@ -36,11 +36,7 @@ export function Status({ ...props }: StatusProps) { return ( - + {step + 1} / {total} ); diff --git a/packages/circuit-ui/components/ListItem/ListItem.spec.tsx b/packages/circuit-ui/components/ListItem/ListItem.spec.tsx index 3d664ba9b3..1f61514426 100644 --- a/packages/circuit-ui/components/ListItem/ListItem.spec.tsx +++ b/packages/circuit-ui/components/ListItem/ListItem.spec.tsx @@ -61,7 +61,7 @@ describe('ListItem', () => { it('should render a ListItem with a custom label', () => { renderListItem(render, { ...baseProps, - label: Label, + label: Label, }); expect(screen.getByText('Label')).toBeVisible(); }); @@ -77,7 +77,7 @@ describe('ListItem', () => { it('should render a ListItem with a custom details line', () => { renderListItem(render, { ...baseProps, - details: Details, + details: Details, }); expect(screen.getByText('Details')).toBeVisible(); }); @@ -94,7 +94,7 @@ describe('ListItem', () => { renderListItem(render, { ...baseProps, trailingLabel: ( - + Trailing label ), @@ -117,7 +117,7 @@ describe('ListItem', () => { ...baseProps, trailingLabel: 'Trailing label', trailingDetails: ( - + Trailing details ), diff --git a/packages/circuit-ui/components/ListItem/ListItem.stories.tsx b/packages/circuit-ui/components/ListItem/ListItem.stories.tsx index 4c31994afc..a600c5e95b 100644 --- a/packages/circuit-ui/components/ListItem/ListItem.stories.tsx +++ b/packages/circuit-ui/components/ListItem/ListItem.stories.tsx @@ -66,13 +66,13 @@ const Details = ( aria-hidden="true" /> {item.status} - + · {item.timestamp} @@ -83,13 +83,13 @@ const lineThrough = { }; const TrailingLabel = ( - + {item.amount} ); const TrailingDetails = ( - + {item.fee} fee ); @@ -147,7 +147,7 @@ export const WithCustomLabel = (args: ListItemProps) => ( Custom multiline label: {args.label}} + label={Custom multiline label: {args.label}} /> ); diff --git a/packages/circuit-ui/components/ListItem/ListItem.tsx b/packages/circuit-ui/components/ListItem/ListItem.tsx index 893ce5dc25..d41b869f51 100644 --- a/packages/circuit-ui/components/ListItem/ListItem.tsx +++ b/packages/circuit-ui/components/ListItem/ListItem.tsx @@ -172,7 +172,7 @@ export const ListItem = forwardRef<
{isString(label) ? ( - + {label} ) : ( @@ -181,7 +181,7 @@ export const ListItem = forwardRef< {details && (
{isString(details) ? ( - + {details} ) : ( @@ -199,7 +199,7 @@ export const ListItem = forwardRef< >
{isString(trailingLabel) ? ( - + {trailingLabel} ) : ( @@ -211,7 +211,7 @@ export const ListItem = forwardRef< {trailingDetails && (
{isString(trailingDetails) ? ( - + {trailingDetails} ) : ( diff --git a/packages/circuit-ui/components/ListItemGroup/ListItemGroup.spec.tsx b/packages/circuit-ui/components/ListItemGroup/ListItemGroup.spec.tsx index cdbdab9587..3d6331f302 100644 --- a/packages/circuit-ui/components/ListItemGroup/ListItemGroup.spec.tsx +++ b/packages/circuit-ui/components/ListItemGroup/ListItemGroup.spec.tsx @@ -47,7 +47,7 @@ describe('ListItemGroup', () => { renderListItemGroup(render, { ...baseProps, label: ( - + Group label ), @@ -66,7 +66,7 @@ describe('ListItemGroup', () => { it('should render a ListItemGroup with a custom details line', () => { renderListItemGroup(render, { ...baseProps, - details: Group details, + details: Group details, }); expect(screen.getByText('Group details')).toBeVisible(); }); diff --git a/packages/circuit-ui/components/ListItemGroup/ListItemGroup.stories.tsx b/packages/circuit-ui/components/ListItemGroup/ListItemGroup.stories.tsx index 9db829a8f3..d9fafa10c7 100644 --- a/packages/circuit-ui/components/ListItemGroup/ListItemGroup.stories.tsx +++ b/packages/circuit-ui/components/ListItemGroup/ListItemGroup.stories.tsx @@ -84,13 +84,13 @@ const Details = ({ item }: { item: Item }) => ( /> )} {item.status} - + · {item.timestamp}
@@ -98,8 +98,9 @@ const Details = ({ item }: { item: Item }) => ( const TrailingLabel = ({ item }: { item: Item }) => ( ( )} > {isString(label) ? ( - + {label} ) : ( @@ -119,7 +119,7 @@ export const ListItemGroup = forwardRef(
{details && (
- {isString(details) ? {details} : details} + {isString(details) ? {details} : details}
)}
diff --git a/packages/circuit-ui/components/Modal/Modal.stories.tsx b/packages/circuit-ui/components/Modal/Modal.stories.tsx index 0ec1d35099..f82d9a6892 100644 --- a/packages/circuit-ui/components/Modal/Modal.stories.tsx +++ b/packages/circuit-ui/components/Modal/Modal.stories.tsx @@ -53,7 +53,7 @@ export default { const defaultModalChildren = () => ( - + Hello World! I am a modal. @@ -146,7 +146,7 @@ export const PreventClose = (modal: ModalProps) => { PreventClose.args = { children: ({ onClose }: { onClose: ModalProps['onClose'] }) => ( - + Complete the action @@ -207,7 +207,7 @@ CustomStyles.args = { borderTopRightRadius: 'var(--cui-border-radius-mega)', }} /> - + Custom styles diff --git a/packages/circuit-ui/components/NotificationFullscreen/NotificationFullscreen.tsx b/packages/circuit-ui/components/NotificationFullscreen/NotificationFullscreen.tsx index 9401109ac2..36387603b2 100644 --- a/packages/circuit-ui/components/NotificationFullscreen/NotificationFullscreen.tsx +++ b/packages/circuit-ui/components/NotificationFullscreen/NotificationFullscreen.tsx @@ -89,7 +89,7 @@ export const NotificationFullscreen = forwardRef< return (
- + {headlineLabel} {body && {body}} diff --git a/packages/circuit-ui/components/NotificationInline/NotificationInline.tsx b/packages/circuit-ui/components/NotificationInline/NotificationInline.tsx index 15d8ad6cae..d1029c3fa3 100644 --- a/packages/circuit-ui/components/NotificationInline/NotificationInline.tsx +++ b/packages/circuit-ui/components/NotificationInline/NotificationInline.tsx @@ -163,10 +163,7 @@ export const NotificationInline = forwardRef< {iconLabel}
{headline && ( - + {isString(headline) ? headline : headline.label} )} @@ -175,7 +172,7 @@ export const NotificationInline = forwardRef< )}
diff --git a/packages/circuit-ui/components/NotificationModal/NotificationModal.tsx b/packages/circuit-ui/components/NotificationModal/NotificationModal.tsx index 9dfc2ced05..3f91ce1cdf 100644 --- a/packages/circuit-ui/components/NotificationModal/NotificationModal.tsx +++ b/packages/circuit-ui/components/NotificationModal/NotificationModal.tsx @@ -151,7 +151,7 @@ export const NotificationModal: ModalComponent = ({ )} - + {headline} {body && {body}} diff --git a/packages/circuit-ui/components/NotificationToast/NotificationToast.tsx b/packages/circuit-ui/components/NotificationToast/NotificationToast.tsx index 70eff92576..17613d0688 100644 --- a/packages/circuit-ui/components/NotificationToast/NotificationToast.tsx +++ b/packages/circuit-ui/components/NotificationToast/NotificationToast.tsx @@ -123,7 +123,7 @@ export function NotificationToast({ {iconLabel}
{headline && ( - + {headline} )} diff --git a/packages/circuit-ui/components/SideNavigation/components/DesktopNavigation/DesktopNavigation.tsx b/packages/circuit-ui/components/SideNavigation/components/DesktopNavigation/DesktopNavigation.tsx index 9efa23c2ee..040b1e8167 100644 --- a/packages/circuit-ui/components/SideNavigation/components/DesktopNavigation/DesktopNavigation.tsx +++ b/packages/circuit-ui/components/SideNavigation/components/DesktopNavigation/DesktopNavigation.tsx @@ -83,7 +83,7 @@ export function DesktopNavigation({ aria-label={secondaryNavigationLabel} > - + {activePrimaryLink?.label} diff --git a/packages/circuit-ui/components/SideNavigation/components/SecondaryLinks/SecondaryLinks.tsx b/packages/circuit-ui/components/SideNavigation/components/SecondaryLinks/SecondaryLinks.tsx index 442446e891..3b98f9b32b 100644 --- a/packages/circuit-ui/components/SideNavigation/components/SecondaryLinks/SecondaryLinks.tsx +++ b/packages/circuit-ui/components/SideNavigation/components/SecondaryLinks/SecondaryLinks.tsx @@ -58,11 +58,7 @@ function SecondaryLink({ aria-current={isActive ? 'page' : undefined} > - + {label} diff --git a/packages/circuit-ui/components/SidePanel/components/Header/Header.tsx b/packages/circuit-ui/components/SidePanel/components/Header/Header.tsx index b12f8b2752..bb23beabd2 100644 --- a/packages/circuit-ui/components/SidePanel/components/Header/Header.tsx +++ b/packages/circuit-ui/components/SidePanel/components/Header/Header.tsx @@ -56,7 +56,7 @@ export const Header = ({ {backButtonLabel} )} - + {headline} {closeButtonLabel && ( diff --git a/packages/circuit-ui/components/Step/examples/MultiStepForm.tsx b/packages/circuit-ui/components/Step/examples/MultiStepForm.tsx index 5e5d069205..02fd3149a9 100644 --- a/packages/circuit-ui/components/Step/examples/MultiStepForm.tsx +++ b/packages/circuit-ui/components/Step/examples/MultiStepForm.tsx @@ -93,7 +93,7 @@ export function MultiStepForm() { return (
- + Step {stepNumber} of {totalSteps} ( {headline && ( {headline} )} - + {body} {action && ( diff --git a/packages/circuit-ui/components/TopNavigation/TopNavigation.stories.tsx b/packages/circuit-ui/components/TopNavigation/TopNavigation.stories.tsx index 96a372c3df..c8a51356a9 100644 --- a/packages/circuit-ui/components/TopNavigation/TopNavigation.stories.tsx +++ b/packages/circuit-ui/components/TopNavigation/TopNavigation.stories.tsx @@ -46,7 +46,7 @@ export default { function CustomComponent() { return ( - + {user.name} {user.id && ( - + {user.id} From fd427b93c4e9b1a6ecefa5741174482fa8fe17db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Thu, 17 Oct 2024 16:23:22 +0200 Subject: [PATCH 2/7] Support multiple components in no-renamed-props config --- .../no-renamed-props/index.ts | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts b/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts index 01960f82c4..5eae4a4ac7 100644 --- a/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts +++ b/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts @@ -36,14 +36,12 @@ const createRule = ESLintUtils.RuleCreator( type PropNameConfig = { type: 'name'; - component: string; hook?: string; props: Record; }; type PropValuesConfig = { type: 'values'; - component: string; hook?: string; prop: string; values: Record; @@ -51,10 +49,10 @@ type PropValuesConfig = { type CustomConfig = { type: 'custom'; - component: string; hook?: string; transform: ( node: TSESTree.JSXElement, + component: string, context: TSESLint.RuleContext< 'propName' | 'propValue' | 'bodyVariant', never[] @@ -64,17 +62,17 @@ type CustomConfig = { type Config = PropNameConfig | PropValuesConfig | CustomConfig; -const configs: Config[] = [ +const configs: (Config & { components: string[] })[] = [ { type: 'name', - component: 'Toggle', + components: ['Toggle'], props: { explanation: 'description', }, }, { type: 'values', - component: 'Badge', + components: ['Badge'], prop: 'variant', values: { confirm: 'success', @@ -84,7 +82,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'NotificationInline', + components: ['NotificationInline'], prop: 'variant', values: { confirm: 'success', @@ -94,7 +92,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'NotificationToast', + components: ['NotificationToast'], hook: 'setToast', prop: 'variant', values: { @@ -105,7 +103,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Button', + components: ['Button'], prop: 'size', values: { kilo: 's', @@ -114,7 +112,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'CloseButton', + components: ['CloseButton'], prop: 'size', values: { kilo: 's', @@ -123,7 +121,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'IconButton', + components: ['IconButton'], prop: 'size', values: { kilo: 's', @@ -132,7 +130,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Hamburger', + components: ['Hamburger'], prop: 'size', values: { kilo: 's', @@ -141,7 +139,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Avatar', + components: ['Avatar'], prop: 'size', values: { giga: 's', @@ -150,7 +148,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'ProgressBar', + components: ['ProgressBar'], prop: 'size', values: { byte: 's', @@ -160,7 +158,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Selector', + components: ['Selector'], prop: 'size', values: { kilo: 's', @@ -169,7 +167,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Spinner', + components: ['Spinner'], prop: 'size', values: { byte: 's', @@ -179,10 +177,9 @@ const configs: Config[] = [ }, { type: 'custom', - component: 'IconButton', + components: ['IconButton'], // children → icon - transform: (node, context) => { - const component = 'IconButton'; + transform: (node, component, context) => { const current = 'children'; const replacement = 'icon'; @@ -242,10 +239,9 @@ const configs: Config[] = [ }, { type: 'custom', - component: 'IconButton', + components: ['IconButton'], // label → children - transform: (node, context) => { - const component = 'IconButton'; + transform: (node, component, context) => { const current = 'label'; const replacement = 'children'; @@ -297,7 +293,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Title', + components: ['Title'], prop: 'size', values: { one: 'l', @@ -308,7 +304,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Display', + components: ['Display'], prop: 'size', values: { one: 'l', @@ -319,7 +315,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Headline', + components: ['Headline'], prop: 'size', values: { one: 'l', @@ -330,7 +326,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'Body', + components: ['Body'], prop: 'size', values: { one: 'm', @@ -339,7 +335,7 @@ const configs: Config[] = [ }, { type: 'values', - component: 'List', + components: ['List'], prop: 'size', values: { one: 'm', @@ -348,11 +344,9 @@ const configs: Config[] = [ }, { type: 'custom', - component: 'Body', + components: ['Body'], // variant → weight or color - transform: (node, context) => { - const component = 'IconButton'; - + transform: (node, component, context) => { node.openingElement.attributes.forEach((attribute) => { if ( attribute.type !== 'JSXAttribute' || @@ -427,9 +421,10 @@ export const noRenamedProps = createRule({ create(context) { function replaceComponentPropName( node: TSESTree.JSXElement, + component: string, config: PropNameConfig, ) { - const { component, props } = config; + const { props } = config; node.openingElement.attributes.forEach((attribute) => { if ( @@ -462,9 +457,10 @@ export const noRenamedProps = createRule({ function replaceComponentPropValues( node: TSESTree.JSXElement, + component: string, config: PropValuesConfig, ) { - const { component, prop, values } = config; + const { prop, values } = config; node.openingElement.attributes.forEach((attribute) => { if (attribute.type !== 'JSXAttribute' || attribute.name.name !== prop) { @@ -546,8 +542,11 @@ export const noRenamedProps = createRule({ const components = configs.reduce( (acc, config) => { - acc[config.component] = acc[config.component] || []; - acc[config.component].push(config); + const { components, ...rest } = config; + config.components.forEach((component) => { + acc[component] = acc[component] || []; + acc[component].push(rest); + }); return acc; }, {} as Record, @@ -562,13 +561,13 @@ export const noRenamedProps = createRule({ configs.forEach((config) => { switch (config.type) { case 'name': - replaceComponentPropName(node, config); + replaceComponentPropName(node, component, config); break; case 'values': - replaceComponentPropValues(node, config); + replaceComponentPropValues(node, component, config); break; case 'custom': - config.transform(node, context); + config.transform(node, component, context); break; } }); From e9e0209ede3aeb2351b0405367ee80eea52af354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Thu, 17 Oct 2024 16:25:24 +0200 Subject: [PATCH 3/7] Add missing migrations for Anchor component --- .../no-renamed-props/index.ts | 80 ++----------------- 1 file changed, 5 insertions(+), 75 deletions(-) diff --git a/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts b/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts index 5eae4a4ac7..b427c2d9fe 100644 --- a/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts +++ b/packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts @@ -72,7 +72,7 @@ const configs: (Config & { components: string[] })[] = [ }, { type: 'values', - components: ['Badge'], + components: ['Badge', 'NotificationInline', 'NotificationToast'], prop: 'variant', values: { confirm: 'success', @@ -82,46 +82,7 @@ const configs: (Config & { components: string[] })[] = [ }, { type: 'values', - components: ['NotificationInline'], - prop: 'variant', - values: { - confirm: 'success', - notify: 'warning', - alert: 'danger', - }, - }, - { - type: 'values', - components: ['NotificationToast'], - hook: 'setToast', - prop: 'variant', - values: { - confirm: 'success', - notify: 'warning', - alert: 'danger', - }, - }, - { - type: 'values', - components: ['Button'], - prop: 'size', - values: { - kilo: 's', - giga: 'm', - }, - }, - { - type: 'values', - components: ['CloseButton'], - prop: 'size', - values: { - kilo: 's', - giga: 'm', - }, - }, - { - type: 'values', - components: ['IconButton'], + components: ['Button', 'CloseButton', 'IconButton'], prop: 'size', values: { kilo: 's', @@ -293,18 +254,7 @@ const configs: (Config & { components: string[] })[] = [ }, { type: 'values', - components: ['Title'], - prop: 'size', - values: { - one: 'l', - two: 'm', - three: 'm', - four: 's', - }, - }, - { - type: 'values', - components: ['Display'], + components: ['Title', 'Display', 'Headline'], prop: 'size', values: { one: 'l', @@ -315,27 +265,7 @@ const configs: (Config & { components: string[] })[] = [ }, { type: 'values', - components: ['Headline'], - prop: 'size', - values: { - one: 'l', - two: 'm', - three: 'm', - four: 's', - }, - }, - { - type: 'values', - components: ['Body'], - prop: 'size', - values: { - one: 'm', - two: 's', - }, - }, - { - type: 'values', - components: ['List'], + components: ['Anchor', 'Body', 'List'], prop: 'size', values: { one: 'm', @@ -344,7 +274,7 @@ const configs: (Config & { components: string[] })[] = [ }, { type: 'custom', - components: ['Body'], + components: ['Anchor', 'Body'], // variant → weight or color transform: (node, component, context) => { node.openingElement.attributes.forEach((attribute) => { From c8c0121d769cb5de2d3f5f3e0821e78f97668fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Thu, 17 Oct 2024 16:28:59 +0200 Subject: [PATCH 4/7] Add missing rule for BodyLarge deprecation --- packages/circuit-ui/components/BodyLarge/BodyLarge.tsx | 2 +- packages/circuit-ui/components/SubHeadline/SubHeadline.tsx | 2 +- .../no-deprecated-components/index.ts | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/circuit-ui/components/BodyLarge/BodyLarge.tsx b/packages/circuit-ui/components/BodyLarge/BodyLarge.tsx index ec6dc6fb0a..2b5b32342d 100644 --- a/packages/circuit-ui/components/BodyLarge/BodyLarge.tsx +++ b/packages/circuit-ui/components/BodyLarge/BodyLarge.tsx @@ -20,7 +20,7 @@ import { Body, type BodyProps } from '../Body/Body.js'; export type BodyLargeProps = Omit; /** - * @deprecated Use the Body component in size `l` instead. + * @deprecated Use the Body component with `size="l"` instead. */ export const BodyLarge = forwardRef( (props, ref) => { diff --git a/packages/circuit-ui/components/SubHeadline/SubHeadline.tsx b/packages/circuit-ui/components/SubHeadline/SubHeadline.tsx index fc5ebeeef8..5f520c1f0e 100644 --- a/packages/circuit-ui/components/SubHeadline/SubHeadline.tsx +++ b/packages/circuit-ui/components/SubHeadline/SubHeadline.tsx @@ -28,7 +28,7 @@ export interface SubHeadlineProps extends HTMLAttributes { } /** - * @deprecated Use the Headline component in size `s` instead. + * @deprecated Use the Headline component with `size="s"` instead. */ export const SubHeadline = forwardRef( (props, ref) => { diff --git a/packages/eslint-plugin-circuit-ui/no-deprecated-components/index.ts b/packages/eslint-plugin-circuit-ui/no-deprecated-components/index.ts index d49163e463..d305e0ee63 100644 --- a/packages/eslint-plugin-circuit-ui/no-deprecated-components/index.ts +++ b/packages/eslint-plugin-circuit-ui/no-deprecated-components/index.ts @@ -33,12 +33,16 @@ const components = [ }, { name: 'SubHeadline', - alternative: 'Use the Headline component in size `s` instead.', + alternative: 'Use the Headline component with `size="s"` instead.', }, { name: 'Title', alternative: 'Use the new Display component instead.', }, + { + name: 'BodyLarge', + alternative: 'Use the Body component with `size="l"` instead.', + }, ]; export const noDeprecatedComponents = createRule({ From ac39e6dcf3caf590c0149ed24eee310e74cf4065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Thu, 17 Oct 2024 16:32:29 +0200 Subject: [PATCH 5/7] Migrate BodyLarge component uses --- .storybook/components/Intro.tsx | 13 ++++++++++--- templates/astro/src/pages/index.astro | 6 +++--- templates/nextjs/template/app/page.tsx | 6 +++--- templates/remix/app/routes/_index/route.tsx | 6 +++--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.storybook/components/Intro.tsx b/.storybook/components/Intro.tsx index 6a0c356928..5bb1b71075 100644 --- a/.storybook/components/Intro.tsx +++ b/.storybook/components/Intro.tsx @@ -13,7 +13,7 @@ * limitations under the License. */ -import { BodyLarge } from '../../packages/circuit-ui/index.js'; +import { Body } from '../../packages/circuit-ui/index.js'; import type { BodyLargeProps } from '../../packages/circuit-ui/index.js'; @@ -26,8 +26,15 @@ export function Intro({ children: BodyLargeProps['children']; }) { return ( - + {children} - + ); } diff --git a/templates/astro/src/pages/index.astro b/templates/astro/src/pages/index.astro index 4326b46f3d..fd41e79bfa 100644 --- a/templates/astro/src/pages/index.astro +++ b/templates/astro/src/pages/index.astro @@ -1,5 +1,5 @@ --- -import { Display, BodyLarge } from '@sumup-oss/circuit-ui'; +import { Display, Body } from '@sumup-oss/circuit-ui'; import Root from '../layouts/Root.astro'; import DocCard from '../components/DocCard.astro'; @@ -11,9 +11,9 @@ const title = 'Welcome to Circuit UI + Astro'; {title} - + Get started by editing src/pages/index.astro - +
- + Get started by editing app/page.tsx - +
- + Get started by editing app/routes/_index/route.tsx - +
Date: Thu, 17 Oct 2024 16:51:10 +0200 Subject: [PATCH 6/7] Revert unintentional migration in test file --- packages/circuit-ui/components/Body/Body.spec.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/circuit-ui/components/Body/Body.spec.tsx b/packages/circuit-ui/components/Body/Body.spec.tsx index fd6a471bcb..af5f680456 100644 --- a/packages/circuit-ui/components/Body/Body.spec.tsx +++ b/packages/circuit-ui/components/Body/Body.spec.tsx @@ -43,7 +43,8 @@ describe('Body', () => { }); it('should render the "highlight" variant as a "strong" element', () => { - const { container } = render(Highlight); + // eslint-disable-next-line @sumup-oss/circuit-ui/no-deprecated-props, @sumup-oss/circuit-ui/no-renamed-props + const { container } = render(Highlight); const actual = container.querySelector('strong'); expect(actual).toBeVisible(); }); From 6f82bbca798d4ec136f8ba117f825751dbe83c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Thu, 17 Oct 2024 16:56:44 +0200 Subject: [PATCH 7/7] Add changesets --- .changeset/eleven-moons-hear.md | 5 +++++ .changeset/thirty-lions-yawn.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/eleven-moons-hear.md create mode 100644 .changeset/thirty-lions-yawn.md diff --git a/.changeset/eleven-moons-hear.md b/.changeset/eleven-moons-hear.md new file mode 100644 index 0000000000..4dfd24104a --- /dev/null +++ b/.changeset/eleven-moons-hear.md @@ -0,0 +1,5 @@ +--- +"@sumup-oss/eslint-plugin-circuit-ui": major +--- + +Added missing rules for the Anchor and BodyLarge migrations. diff --git a/.changeset/thirty-lions-yawn.md b/.changeset/thirty-lions-yawn.md new file mode 100644 index 0000000000..47c7d82c88 --- /dev/null +++ b/.changeset/thirty-lions-yawn.md @@ -0,0 +1,5 @@ +--- +'@sumup-oss/circuit-ui': minor +--- + +Migrated to the new typography APIs internally.