From 99cee5f7c458ed6f800b0a3af28560dd96633424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matth=C3=A4us=20N=C3=B6ssing?= Date: Tue, 27 Aug 2024 16:15:27 +0200 Subject: [PATCH] fix lint errors --- .../content/DescriptionItem/DescriptionItem.tsx | 11 ++++++++--- .../content/WithPlaceholder/WithPlaceholder.tsx | 5 +++-- src/components/util/useId.ts | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/content/DescriptionItem/DescriptionItem.tsx b/src/components/content/DescriptionItem/DescriptionItem.tsx index 29ecdb9c..19d0e16d 100644 --- a/src/components/content/DescriptionItem/DescriptionItem.tsx +++ b/src/components/content/DescriptionItem/DescriptionItem.tsx @@ -47,15 +47,20 @@ export function DescriptionItem({ title, className, contentProps, - ...props + hideIfEmpty = false, + content, }: DescriptionItemProps) { return ( <> - {((props.hideIfEmpty && props.content) ?? !props.hideIfEmpty) && ( + {((hideIfEmpty && + content !== null && + content !== undefined && + content !== '') || + !hideIfEmpty) && ( {title} - {props.content} + {content} )} diff --git a/src/components/content/WithPlaceholder/WithPlaceholder.tsx b/src/components/content/WithPlaceholder/WithPlaceholder.tsx index 9a913dff..4cf4ee8d 100644 --- a/src/components/content/WithPlaceholder/WithPlaceholder.tsx +++ b/src/components/content/WithPlaceholder/WithPlaceholder.tsx @@ -14,14 +14,15 @@ export function WithPlaceholder({ placeholder = '-', children, }: WithPlaceholderProps) { - /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ return ( <> {typeof children === 'number' ? isNaN(children) ? placeholder : children - : children || placeholder} + : children === null || children === undefined || children === '' + ? placeholder + : children} ) } diff --git a/src/components/util/useId.ts b/src/components/util/useId.ts index 4b57d971..8338457c 100644 --- a/src/components/util/useId.ts +++ b/src/components/util/useId.ts @@ -22,6 +22,8 @@ const useIsomorphicLayoutEffect = canUseDOM() ? useLayoutEffect : useEffect function canUseDOM() { return Boolean( typeof window !== 'undefined' && + // eslint-disable-next-line @typescript-eslint/prefer-optional-chain + typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined', ) }