From 60a30afb819b4cd1318689e7c4cab337f52543ff Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 1 Dec 2026 13:51:32 +0100 Subject: [PATCH] fix(deps): narrow Lucide icon types and lower the lint baseline Keep the typed icon lookup aligned with the runtime namespace and record the three removed test assertions. --- client/scripts/eslint-baseline.json | 2 +- client/src/components/shared/lucideIconLookup.ts | 12 ++++++++++-- client/src/utils/iconMarkup.ts | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/scripts/eslint-baseline.json b/client/scripts/eslint-baseline.json index 0c5bc98a9..c0691d5f8 100644 --- a/client/scripts/eslint-baseline.json +++ b/client/scripts/eslint-baseline.json @@ -35,7 +35,7 @@ }, "tests": { "@typescript-eslint/no-explicit-any": 484, - "@typescript-eslint/no-non-null-assertion": 1848, + "@typescript-eslint/no-non-null-assertion": 1845, "@typescript-eslint/no-misused-promises": 22, "@typescript-eslint/no-unused-vars": 48, "@typescript-eslint/no-floating-promises": 33, diff --git a/client/src/components/shared/lucideIconLookup.ts b/client/src/components/shared/lucideIconLookup.ts index 02afe936c..38eaa4925 100644 --- a/client/src/components/shared/lucideIconLookup.ts +++ b/client/src/components/shared/lucideIconLookup.ts @@ -4,9 +4,17 @@ import * as LucideIcons from 'lucide-react'; import { legacyLucideIcons } from './legacyLucideIcons'; const icons = Object.create(null) as Record; +const forwardRef = Symbol.for('react.forward_ref'); -for (const [name, component] of Object.entries(LucideIcons)) { - if (/^[A-Z][A-Za-z0-9]*$/.test(name) && name !== 'Icon' && typeof component === 'object' && component !== null) { +for (const [name, component] of Object.entries(LucideIcons)) { + if ( + /^[A-Z][A-Za-z0-9]*$/.test(name) && + name !== 'Icon' && + typeof component === 'object' && + component !== null && + '$$typeof' in component && + component.$$typeof === forwardRef + ) { icons[name] = component as LucideIcon; } } diff --git a/client/src/utils/iconMarkup.ts b/client/src/utils/iconMarkup.ts index 646514024..422e31441 100644 --- a/client/src/utils/iconMarkup.ts +++ b/client/src/utils/iconMarkup.ts @@ -124,7 +124,7 @@ function serialize(node: unknown): string { return `<${type}${serializeProps(props)}>${serialize(props.children)}` } if (type === Icon && props.icon) { - return serializeLucideIcon(props as LucideElementProps) + return serializeLucideIcon({ ...props, icon: props.icon as LucideIconData }) } if (typeof type === 'object' && type !== null && (type as ForwardRefComponent).$$typeof === FORWARD_REF) { return serialize((type as ForwardRefComponent).render(props, null))