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.
This commit is contained in:
Maurice
2026-12-01 13:51:32 +01:00
parent b77c246df4
commit 60a30afb81
3 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -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,
@@ -4,9 +4,17 @@ import * as LucideIcons from 'lucide-react';
import { legacyLucideIcons } from './legacyLucideIcons';
const icons = Object.create(null) as Record<string, LucideIcon | undefined>;
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<unknown>(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;
}
}
+1 -1
View File
@@ -124,7 +124,7 @@ function serialize(node: unknown): string {
return `<${type}${serializeProps(props)}>${serialize(props.children)}</${type}>`
}
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))