diff --git a/packages/charts/src/components/BarChart/components/Bars.tsx b/packages/charts/src/components/BarChart/components/Bars.tsx index 0ba5496851b..4f86ed09f65 100644 --- a/packages/charts/src/components/BarChart/components/Bars.tsx +++ b/packages/charts/src/components/BarChart/components/Bars.tsx @@ -33,9 +33,8 @@ export const Bars = ({ series, horizontal, displayStyle }: BarGroupProps) => { colorAccessor={(datum: BarChartDataPoint) => { if (focusedItemLabel === datum.label) { return hoverColorAccessorByIndex(seriesIndex); - } else { - return colorAccessorByIndex(seriesIndex); } + return colorAccessorByIndex(seriesIndex); }} onPointerMove={isOverlapped ? onPointerMove : undefined} onPointerOut={isOverlapped ? onPointerOut : undefined} diff --git a/packages/charts/src/components/LineChart/helpers/createBackfilledSeries.ts b/packages/charts/src/components/LineChart/helpers/createBackfilledSeries.ts index 9d6bce35a1a..ead6b81efd1 100644 --- a/packages/charts/src/components/LineChart/helpers/createBackfilledSeries.ts +++ b/packages/charts/src/components/LineChart/helpers/createBackfilledSeries.ts @@ -67,8 +67,7 @@ export const createBackfilledSeries = (series: LineChartSeries[]): LineChartSeri dataPoints, })), ]; - } else { - return accumulator; } + return accumulator; }, []); }; diff --git a/packages/charts/src/components/Treemap/hooks/helpers/dataGroupingHelper.ts b/packages/charts/src/components/Treemap/hooks/helpers/dataGroupingHelper.ts index 6496be5e153..640fa3622d0 100644 --- a/packages/charts/src/components/Treemap/hooks/helpers/dataGroupingHelper.ts +++ b/packages/charts/src/components/Treemap/hooks/helpers/dataGroupingHelper.ts @@ -92,13 +92,12 @@ const addDataPointToGroup = ( value: (group.value ?? 0) + (dataPoint.value ?? 0), groupIds: [...(group.groupIds || []), dataPoint.id], }; - } else { - return { - ...dataPoint, - id: groupId, - description: '', - groupIds: [dataPoint.id], - parentId: parentGroup ? `group-${parentGroup.color}` : dataPoint.parentId, - }; } + return { + ...dataPoint, + id: groupId, + description: '', + groupIds: [dataPoint.id], + parentId: parentGroup ? `group-${parentGroup.color}` : dataPoint.parentId, + }; }; diff --git a/packages/charts/src/components/common/components/Tooltip/helpers/getFormattedTooltipDate.ts b/packages/charts/src/components/common/components/Tooltip/helpers/getFormattedTooltipDate.ts index 547a2fcc34d..625d85f5de3 100644 --- a/packages/charts/src/components/common/components/Tooltip/helpers/getFormattedTooltipDate.ts +++ b/packages/charts/src/components/common/components/Tooltip/helpers/getFormattedTooltipDate.ts @@ -7,7 +7,6 @@ export const getFormattedTooltipDate = (timestamp?: Date, locale?: string) => { day: '2-digit', year: 'numeric', }).format(timestamp); - } else { - return ''; } + return ''; }; diff --git a/packages/components/scripts/transforms.ts b/packages/components/scripts/transforms.ts index dcd31940fac..872198325ad 100644 --- a/packages/components/scripts/transforms.ts +++ b/packages/components/scripts/transforms.ts @@ -3,7 +3,7 @@ /** * Converts any given input to kebab-case * - * @param name String in any case (PascalCase, camelCase, ...) + * @param name - String in any case (PascalCase, camelCase, ...) * @returns String in kebab-case */ export const toKebabCase = (name: string): string => @@ -14,7 +14,7 @@ export const toKebabCase = (name: string): string => /** * Converts any given input to UPPERCASE_SNAKE_CASE * - * @param name String in any case (PascalCase, camelCase, ...) + * @param name - String in any case (PascalCase, camelCase, ...) * @returns String in UPPERCASE_SNAKE_CASE */ export const toUpperSnakeCase = (name: string): string => name.replaceAll(/([a-z])([A-Z])/g, '$1_$2').toUpperCase(); @@ -22,7 +22,7 @@ export const toUpperSnakeCase = (name: string): string => name.replaceAll(/([a-z /** * Converts any given input to camelCase * - * @param name String in any case (PascalCase, kebab-case, ...) + * @param name - String in any case (PascalCase, kebab-case, ...) * @returns String in camelCase */ export const toCamelCase = (name: string): string => { diff --git a/packages/components/src/components/Badge/utils.ts b/packages/components/src/components/Badge/utils.ts index 1874920c3ac..519028c14ab 100644 --- a/packages/components/src/components/Badge/utils.ts +++ b/packages/components/src/components/Badge/utils.ts @@ -6,8 +6,7 @@ export const DEFAULT_COLOR = { red: 255, green: 255, blue: 255, alpha: 1, name: /** * Converts a color object to a CSS color string. - * @param {RgbaColor} color - The color object to be converted. - * @returns {string} + * @param color - The color object to be converted. * @example * colorToCss({ red: 255, green: 255, blue: 255, alpha: 1 }); // 'rgba(255, 255, 255, 1)' * @example diff --git a/packages/components/src/components/ColorPicker/utils.ts b/packages/components/src/components/ColorPicker/utils.ts index 0a7d398dfb4..de95128da25 100644 --- a/packages/components/src/components/ColorPicker/utils.ts +++ b/packages/components/src/components/ColorPicker/utils.ts @@ -7,8 +7,7 @@ export const DEFAULT_FORMAT = 'HEX'; /** * Converts a color object to a CSS color string. - * @param {RgbaColor} color - The color object to be converted. - * @returns {string} + * @param color - The color object to be converted. * @example * colorToCss({ red: 255, green: 255, blue: 255, alpha: 1 }); // 'rgba(255, 255, 255, 1)' * @example @@ -26,8 +25,7 @@ export const colorToCss = (color?: RgbaColor) => { /** * Checks if a string is a valid hexadecimal color code. This function accepts * both three-digit and six-digit hex codes without the '#' symbol. - * @param {string} color - The color code to be checked. - * @returns {boolean} + * @param color - The color code to be checked. * @example * isValidHexColor('FFF'); // true * @example @@ -43,8 +41,7 @@ export const isValidHexColor = (color: string): boolean => { /** * Converts a hexadecimal color code to an RGBA color object. This function accepts * both three-digit and six-digit hex codes without the '#' symbol. - * @param {string} hex - The hex code, either 3 or 6 characters long. Characters should be from the set [0-9A-Fa-f]. - * @returns {RgbaColor} + * @param hex - The hex code, either 3 or 6 characters long. Characters should be from the set [0-9A-Fa-f]. * @example * hexColorToRgba('FFF'); // { red: 255, green: 255, blue: 255, alpha: 1 } * @example @@ -83,8 +80,7 @@ export const hexColorToRgba = (hex: string): RgbaColor => { /** * Converts an RGBA color object to a hexadecimal color code. This function returns a * six-digit hex code without the '#' symbol. - * @param {RgbaColor} rgb - The RGBA color object. - * @returns {string} + * @param rgb - The RGBA color object. * @example * rgbColorToHex({ red: 255, green: 255, blue: 255, alpha: 1 }); // '#FFFFFF' * @example @@ -99,8 +95,7 @@ export const rgbColorToHex = (rgb: Omit): string => { /** * Returns a hex color display name with alpha percentage if alpha < 100%. - * @param {RgbaColor} color - The RGBA color object. - * @returns {string} + * @param color - The RGBA color object. * @example * getHexDisplayName({ red: 255, green: 255, blue: 255, alpha: 1 }); // '#FFFFFF' * @example @@ -122,9 +117,8 @@ export const getHexDisplayName = (color: RgbaColor): string => { /** * Returns a color object with a name property based on the provided color and format. - * @param {RgbaColor} color - The RGBA color object. - * @param {ColorFormat} currentFormat - The current format of the color. - * @returns {RgbaColor} + * @param color - The RGBA color object. + * @param currentFormat - The current format of the color. * @example * getColorWithName({ red: 255, green: 255, blue: 255, alpha: 1 }, 'HEX'); // { red: 255, green: 255, blue: 255, alpha: 1, name: '#FFFFFF' } * @example @@ -149,10 +143,9 @@ export const getColorWithName = (color: RgbaColor, currentFormat: ColorFormat) = /** * Returns a number between a minimum and maximum value, inclusive. - * @param {string} value - The value to be limited. - * @param {number} [min=0] - The minimum value (inclusive). - * @param {number} [max=255] - The maximum value (inclusive). - * @returns {number} + * @param value - The value to be limited. + * @param [min=0] - The minimum value (inclusive). + * @param [max=255] - The maximum value (inclusive). * @example * getLimitedColorChannelValue('255'); // 255 * @example diff --git a/packages/components/src/components/Select/hooks/useSelectData.tsx b/packages/components/src/components/Select/hooks/useSelectData.tsx index bb8a3c4727b..b4c8b5e3f6c 100644 --- a/packages/components/src/components/Select/hooks/useSelectData.tsx +++ b/packages/components/src/components/Select/hooks/useSelectData.tsx @@ -74,8 +74,8 @@ const useAsyncItems = (filterText: string, getAsyncItems?: AsyncItemsFetcher) => * Recursively extracts option values from children. * This function traverses through the React component tree and collects all SelectItem values. * - * @param {ReactNode} children - The React children to extract values from. - * @returns {SelectItemType[]} An array of SelectItemType objects. + * @param children - The React children to extract values from. + * @returns An array of SelectItemType objects. * * @example * const options = ( @@ -105,9 +105,9 @@ export const getRecursiveOptionValues = ( /** * Custom hook for managing select data and filtering. * - * @param {ReactNode} children - The React children to process, typically SelectItem components. - * @param {AsyncItemsFetcher} [getAsyncItems] - Optional function to fetch items asynchronously based on filter text. - * @returns {Object} An object containing the processed data. + * @param children - The React children to process, typically SelectItem components. + * @param [getAsyncItems] - Optional function to fetch items asynchronously based on filter text. + * @returns An object containing the processed data. */ export const useSelectData = (children: ReactNode, getAsyncItems?: AsyncItemsFetcher) => { const [filterText, setFilterText] = useState(''); diff --git a/packages/components/src/components/Select/utils.ts b/packages/components/src/components/Select/utils.ts index e7e42edd052..e92f680f18c 100644 --- a/packages/components/src/components/Select/utils.ts +++ b/packages/components/src/components/Select/utils.ts @@ -15,8 +15,8 @@ import { ForwardedRefSelectItem, ForwardedRefSelectItemGroup, type SelectItemPro * Extracts and returns an object containing `value` and `label` from a given SelectItemProps object. * It prioritizes explicit `value` and `label` properties but will fall back to using `children` as the value or label if necessary. * - * @param {SelectItemProps} props - The properties of a select item, which include potential children, value, and label. - * @returns {{ value: string; label: string, children?: ReactNode }} An object containing `value` and `label` as strings. + * @param props - The properties of a select item, which include potential children, value, and label. + * @returns An object containing `value` and `label` as strings. * * @example * // Returns { value: 'option1', label: 'Option 1' } @@ -52,9 +52,9 @@ export const getSelectOptionValue = ({ /** * Determines if the child is a leaf node of React, meaning it has one final child of a native type; * - * @param {ReactNode} child - The React child node to check. - * @param {JSXElementConstructor} Component - The React component constructor used for comparison. - * @returns {boolean} Returns true if the `child` is a valid React element of the specified `Component` type. + * @param child - The React child node to check. + * @param Component - The React component constructor used for comparison. + * @returns Returns true if the `child` is a valid React element of the specified `Component` type. * * @example * // Assuming ForwardedRefSelectItem is a component that renders an element @@ -72,11 +72,11 @@ export const isReactLeaf = (child: ReactNode, Component: JSXElementConstructor} localRef - The local ref object used internally by the component. - * @param {ForwardedRef} forwardedRef - The ref forwarded from a parent component. + * @param localRef - The local ref object used internally by the component. + * @param forwardedRef - The ref forwarded from a parent component. * * @example * ```tsx diff --git a/packages/components/src/hooks/useTextTruncation.ts b/packages/components/src/hooks/useTextTruncation.ts index ca84cc73aec..65d62ab7c59 100644 --- a/packages/components/src/hooks/useTextTruncation.ts +++ b/packages/components/src/hooks/useTextTruncation.ts @@ -7,7 +7,7 @@ import { useEffect, type RefObject } from 'react'; * It observes the element's size and adds a title attribute with the full text * when the content is truncated. * - * @param {RefObject} ref - Reference to the HTML element to observe for truncation. + * @param ref - Reference to the HTML element to observe for truncation. * * @example * ```tsx diff --git a/packages/components/src/utilities/domUtilities.ts b/packages/components/src/utilities/domUtilities.ts index 2e137d8b8b6..73b3120f90d 100644 --- a/packages/components/src/utilities/domUtilities.ts +++ b/packages/components/src/utilities/domUtilities.ts @@ -9,7 +9,7 @@ export const MAX_HEIGHT_MARGIN = 8; * The function calculates the space below the dialog up to the bottom of the viewport window, * subtracting a default margin, and sets this value as the max-height style of the dialog. * - * @param {HTMLElement} dialog - The dialog element whose maximum height is to be set. + * @param dialog - The dialog element whose maximum height is to be set. * * @example * // Suppose you have a dialog element with id 'my-dialog'. @@ -41,8 +41,8 @@ export function setMaxHeightToAvailableSpace(dialog: HTMLElement) { * - The element's computed style must not be `display: none`, `visibility: hidden`, or `opacity: 0`. * - The element must be within the bounds of the current viewport. * - * @param {HTMLElement} element - The HTML element to check for visibility. - * @returns {boolean} Returns true if the element is visible according to the criteria specified, otherwise returns false. + * @param element - The HTML element to check for visibility. + * @returns Returns true if the element is visible according to the criteria specified, otherwise returns false. */ export function isElementVisible(element: HTMLElement) { const rect = element.getBoundingClientRect(); @@ -61,8 +61,8 @@ export function isElementVisible(element: HTMLElement) { /** * Assigns a local DOM ref to a forwarded ref. * - * @param {RefObject} localRef - The local React reference to an HTMLDivElement. - * @param {ForwardedRef} forwardedRef - The ref forwarded from a parent component. + * @param localRef - The local React reference to an HTMLDivElement. + * @param forwardedRef - The ref forwarded from a parent component. */ export function syncRefs( localRef: RefObject, diff --git a/packages/fondue/src/components/Badge/helpers.ts b/packages/fondue/src/components/Badge/helpers.ts index 72c475a3e90..06f42230b53 100644 --- a/packages/fondue/src/components/Badge/helpers.ts +++ b/packages/fondue/src/components/Badge/helpers.ts @@ -92,14 +92,13 @@ export const getSizeClasses = ( hasMaximumTwoComponents && 'tw-gap-x-1.5', isDismissable && 'tw-pr-5', ]); - } else { - return merge([ - 'tw-h-6', - 'tw-px-2.5 tw-gap-x-1', - hasMaximumTwoComponents && 'tw-gap-x-2', - isDismissable && 'tw-pr-6', - ]); } + return merge([ + 'tw-h-6', + 'tw-px-2.5 tw-gap-x-1', + hasMaximumTwoComponents && 'tw-gap-x-2', + isDismissable && 'tw-pr-6', + ]); }; /** diff --git a/packages/fondue/src/components/Tree/helpers/getMovementAnnouncements.ts b/packages/fondue/src/components/Tree/helpers/getMovementAnnouncements.ts index c5c5347bf46..45fac036b46 100644 --- a/packages/fondue/src/components/Tree/helpers/getMovementAnnouncements.ts +++ b/packages/fondue/src/components/Tree/helpers/getMovementAnnouncements.ts @@ -133,12 +133,11 @@ const getMovementAnnouncement = ({ overId === currentPosition.overId ) { return; - } else { - setCurrentPosition({ - parentId: projected.parentId, - overId, - }); } + setCurrentPosition({ + parentId: projected.parentId, + overId, + }); } const announcementNodes: AnnouncementItem[] = treeState.nodes.map(({ props }) => ({ diff --git a/packages/fondue/src/components/Tree/helpers/projection.ts b/packages/fondue/src/components/Tree/helpers/projection.ts index 7bf374f0450..68faeb3cb7c 100644 --- a/packages/fondue/src/components/Tree/helpers/projection.ts +++ b/packages/fondue/src/components/Tree/helpers/projection.ts @@ -49,9 +49,8 @@ const calculateMaxDepth = (previousNode: ReactElement, nextNode: ReactElement) = if (previousNode?.props.accepts) { const nextNodeDepth = getNodeDepth(nextNode); return previousNodeDepth >= nextNodeDepth ? previousNodeDepth + 1 : nextNodeDepth; - } else { - return previousNodeDepth; } + return previousNodeDepth; }; const calculateMinDepth = (previousNode: ReactElement, nextNode: ReactElement) => { @@ -59,9 +58,8 @@ const calculateMinDepth = (previousNode: ReactElement, nextNode: ReactElement) = if (previousNode?.props.accepts) { return nextNodeDepth; - } else { - return Math.min(getNodeDepth(previousNode), nextNodeDepth); } + return Math.min(getNodeDepth(previousNode), nextNodeDepth); }; /** diff --git a/packages/fondue/src/components/Tree/utils/removeFragmentsAndEnrichChildren.ts b/packages/fondue/src/components/Tree/utils/removeFragmentsAndEnrichChildren.ts index f42c03fcc5b..14b55abd8e5 100644 --- a/packages/fondue/src/components/Tree/utils/removeFragmentsAndEnrichChildren.ts +++ b/packages/fondue/src/components/Tree/utils/removeFragmentsAndEnrichChildren.ts @@ -11,8 +11,8 @@ type EnrichedProps = { /** * Recursively removes React Fragments and enriches the remaining child elements passed in with additional properties. * - * @param children The child elements to remove React Fragments from and enrich. - * @param enrichedProps Additional properties to add to each child element. + * @param children - The child elements to remove React Fragments from and enrich. + * @param enrichedProps - Additional properties to add to each child element. * @returns An array of ReactElements with enriched props. * * @example @@ -32,7 +32,7 @@ type EnrichedProps = { * * const flattenedAndEnriched = flattenAndEnrichChildren(children, enrichedProps); * - * @returns {ReactElement[]} Array with the three child elements from the example, each with the `parentId` and `level` props added. + * @returns Array with the three child elements from the example, each with the `parentId` and `level` props added. * * @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}. */ diff --git a/packages/fondue/src/utilities/merge.ts b/packages/fondue/src/utilities/merge.ts index 34c607ea695..61e7e5a7844 100644 --- a/packages/fondue/src/utilities/merge.ts +++ b/packages/fondue/src/utilities/merge.ts @@ -5,7 +5,7 @@ import { type MutableRefObject, type Ref, type RefCallback } from 'react'; /** * Cleans and joins an array of inputs with possible undefined or boolean values. * - * @param classNames Array of class names + * @param classNames - Array of class names * @returns Clean string to be used for class name * @deprecated This function is deprecated and will be removed in the next major version. */ diff --git a/packages/fondue/tools/codemod/findDeprecatedImports.ts b/packages/fondue/tools/codemod/findDeprecatedImports.ts index 88a9a2b1426..15f9b112fb1 100644 --- a/packages/fondue/tools/codemod/findDeprecatedImports.ts +++ b/packages/fondue/tools/codemod/findDeprecatedImports.ts @@ -26,9 +26,8 @@ const getImports = (pathToAnalyze: string, selectedImports: string[] = []) => { .map((line) => JSON.parse(line) as { path: string; imports: string[] }); rmSync(join(tempDir), { recursive: true }); return detectedImports; - } else { - return []; } + return []; }); }; diff --git a/packages/rte/cypress/support/component.ts b/packages/rte/cypress/support/component.ts index d7734ae2435..a214f0137ab 100644 --- a/packages/rte/cypress/support/component.ts +++ b/packages/rte/cypress/support/component.ts @@ -10,8 +10,8 @@ declare global { interface Chainable { /** * Mounts a React node - * @param component React Node to mount - * @param options Additional options to pass into mount + * @param component - React Node to mount + * @param options - Additional options to pass into mount */ mount(...parameters: Parameters): ReturnType; } diff --git a/packages/rte/src/components/Badge/helpers.ts b/packages/rte/src/components/Badge/helpers.ts index 851e7740311..13a7ad0f6d7 100644 --- a/packages/rte/src/components/Badge/helpers.ts +++ b/packages/rte/src/components/Badge/helpers.ts @@ -80,14 +80,13 @@ export const getSizeClasses = ( hasMaximumTwoComponents && 'tw-gap-x-1.5', isDismissable && 'tw-pr-5', ]); - } else { - return merge([ - 'tw-h-6', - 'tw-px-2.5 tw-gap-x-1', - hasMaximumTwoComponents && 'tw-gap-x-2', - isDismissable && 'tw-pr-6', - ]); } + return merge([ + 'tw-h-6', + 'tw-px-2.5 tw-gap-x-1', + hasMaximumTwoComponents && 'tw-gap-x-2', + isDismissable && 'tw-pr-6', + ]); }; export const badgeStatusClasses: Record = { diff --git a/packages/rte/src/components/Flyout/hooks/useContainScroll.ts b/packages/rte/src/components/Flyout/hooks/useContainScroll.ts index 72f2c61d2b9..75d931307d5 100644 --- a/packages/rte/src/components/Flyout/hooks/useContainScroll.ts +++ b/packages/rte/src/components/Flyout/hooks/useContainScroll.ts @@ -14,9 +14,8 @@ export const useContainScroll = (overlayRef: MutableRefObject element.clientHeight && hasVisibleScroll) { return element; - } else { - return closestScrollableAncestor(element.parentElement); } + return closestScrollableAncestor(element.parentElement); }; const scrollHandler = (event: WheelEvent) => { diff --git a/packages/rte/src/utilities/merge.ts b/packages/rte/src/utilities/merge.ts index 9b33078ce91..c9983a6884e 100644 --- a/packages/rte/src/utilities/merge.ts +++ b/packages/rte/src/utilities/merge.ts @@ -5,7 +5,7 @@ import { type MutableRefObject, type Ref, type RefCallback } from 'react'; /** * Cleans and joins an array of inputs with possible undefined or boolean values. * - * @param classNames Array of class names + * @param classNames - Array of class names * @returns Clean string to be used for class name */ export const merge = (classNames: (string | undefined | boolean)[]): string => classNames.filter(Boolean).join(' '); diff --git a/packages/tokens/stories/components/Tokens/TokenCollectionOverview.tsx b/packages/tokens/stories/components/Tokens/TokenCollectionOverview.tsx index f3964e425f2..60009765664 100644 --- a/packages/tokens/stories/components/Tokens/TokenCollectionOverview.tsx +++ b/packages/tokens/stories/components/Tokens/TokenCollectionOverview.tsx @@ -82,44 +82,43 @@ export const TokenCollectionOverview = ({ getClassName={getClassName} /> ); - } else { - const hasDirectTokens = Object.values(value).some((v) => typeof v === 'object' && 'value' in v); - - return ( - - -
- {hasDirectTokens ? ( - - - - ) : ( - - - - )} -
-
- ); } + const hasDirectTokens = Object.values(value).some((v) => typeof v === 'object' && 'value' in v); + + return ( + + +
+ {hasDirectTokens ? ( + + + + ) : ( + + + + )} +
+
+ ); } return false; }); diff --git a/storybook-docs/.storybook/main.ts b/storybook-docs/.storybook/main.ts index f986aafb305..8693dceed94 100644 --- a/storybook-docs/.storybook/main.ts +++ b/storybook-docs/.storybook/main.ts @@ -19,9 +19,8 @@ const packagePath = (...segments: string[]): string => join(packagesRoot, ...seg const getSubpackageURL = (subpackage: string): string => { if (process.env.CONTEXT === 'deploy-preview' && process.env.REVIEW_ID) { return `https://deploy-preview-${process.env.REVIEW_ID}.${subpackage}.fondue-components.frontify.com/`; - } else { - return `https://${subpackage}.fondue-components.frontify.com/`; } + return `https://${subpackage}.fondue-components.frontify.com/`; }; const config: StorybookConfig = {