Fix no-inline-named-types to match required members only

Ignore optional members instead of skipping the entire type.
{ x: number; y: number; label?: string } now correctly flags as
Vector, while { x?: number; y?: number } is still ignored.
This commit is contained in:
Danila Poyarkov 2026-03-09 09:48:38 +03:00
parent 5ef7111998
commit df0ccbca48

View file

@ -28,9 +28,10 @@ const noInlineNamedTypes = {
)
if (!props || props.length < 2) return
if (props.some((m) => m.optional)) return
const required = props.filter((m) => !m.optional)
if (required.length < 2) return
const shape = props
const shape = required
.map((m) => {
const typeNode = m.typeAnnotation?.typeAnnotation
let typeName = 'unknown'