build(lint): catch optional named type shapes
This commit is contained in:
parent
170db518e9
commit
3c73c34d37
|
|
@ -95,10 +95,7 @@ const noInlineNamedTypes = {
|
|||
)
|
||||
if (!props || props.length < 2) return
|
||||
|
||||
const required = props.filter((m) => !m.optional)
|
||||
if (required.length < 2) return
|
||||
|
||||
const shape = required
|
||||
const shape = props
|
||||
.map((m) => {
|
||||
const typeNode = m.typeAnnotation?.typeAnnotation
|
||||
let typeName = 'unknown'
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ function variableValueToKiwi(
|
|||
}
|
||||
if (type === 'COLOR' && typeof value === 'object' && 'r' in value) {
|
||||
return {
|
||||
value: { colorValue: safeColor(value as { r: number; g: number; b: number; a?: number }) },
|
||||
value: { colorValue: safeColor(value) },
|
||||
dataType: 'COLOR',
|
||||
resolvedDataType: 'COLOR'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from '#core/kiwi/node-change/convert'
|
||||
import type { SceneNode, ArcData, TextAutoResize } from '#core/scene-graph'
|
||||
import { styleToWeight } from '#core/text/fonts'
|
||||
import type { Vector } from '#core/types'
|
||||
|
||||
function applyOverridePaints(ov: Record<string, unknown>, updates: Partial<SceneNode>): void {
|
||||
if (ov.textData != null) {
|
||||
|
|
@ -39,7 +40,7 @@ function applyOverridePaints(ov: Record<string, unknown>, updates: Partial<Scene
|
|||
|
||||
function applyOverrideGeometry(ov: Record<string, unknown>, updates: Partial<SceneNode>): void {
|
||||
if (ov.size != null) {
|
||||
const sz = ov.size as { x?: number; y?: number }
|
||||
const sz = ov.size as Partial<Vector>
|
||||
if (sz.x != null) updates.width = sz.x
|
||||
if (sz.y != null) updates.height = sz.y
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ interface SceneNodeToKiwiContext {
|
|||
fractionalPosition: (index: number) => string
|
||||
mapToFigmaType: (type: SceneNode['type']) => string
|
||||
fillToKiwiPaint: (fill: SceneNode['fills'][number]) => Paint
|
||||
safeColor: (color: { r: number; g: number; b: number; a?: number }) => Color
|
||||
safeColor: (color: Color) => Color
|
||||
computeExportTransform: (node: SceneNode, graph: SceneGraph) => Matrix
|
||||
serializeCornerRadii: (node: SceneNode, nc: KiwiNodeChange) => void
|
||||
serializeTextProps: (
|
||||
|
|
|
|||
|
|
@ -190,8 +190,8 @@ function exportTextData(node: SceneNode): NodeChange['textData'] {
|
|||
}
|
||||
}
|
||||
|
||||
export function safeColor(c: { r: number; g: number; b: number; a?: number }): Color {
|
||||
return { r: c.r, g: c.g, b: c.b, a: c.a ?? 1 }
|
||||
export function safeColor(c: Color): Color {
|
||||
return { r: c.r, g: c.g, b: c.b, a: c.a }
|
||||
}
|
||||
|
||||
function fillToKiwiPaint(f: SceneNode['fills'][number]): Paint {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Color, Matrix, Vector } from '#core/types'
|
||||
import type { Color, Matrix, Rect, Vector } from '#core/types'
|
||||
|
||||
export interface SceneGraphEvents {
|
||||
'node:created': (node: SceneNode) => void
|
||||
|
|
@ -233,7 +233,7 @@ export interface SceneNode {
|
|||
width: number
|
||||
height: number
|
||||
rotation: number
|
||||
figmaDerivedLayout: { x?: number; y?: number; width?: number; height?: number } | null
|
||||
figmaDerivedLayout: Partial<Rect> | null
|
||||
|
||||
fills: Fill[]
|
||||
strokes: Stroke[]
|
||||
|
|
|
|||
Loading…
Reference in a new issue