mirror of
https://github.com/anthropics/claude-code.git
synced 2026-01-30 04:02:03 +00:00
Add two lint mechanisms to catch the Ink error "<Box> can't be nested inside <Text> component" at build/lint time rather than runtime: 1. Biome GritQL plugin (no-box-in-text.grit) - for Biome v2+ users 2. Build-time check script (check-box-in-text.ts) - standalone AST check These help prevent the runtime error that occurs when Box components are incorrectly nested inside Text components in Ink applications.
23 lines
800 B
Plaintext
23 lines
800 B
Plaintext
// Biome GritQL Plugin: Prevent <Box> from being nested inside <Text>
|
|
// This catches the Ink error: "<Box> can't be nested inside <Text> component"
|
|
|
|
language js;
|
|
|
|
// Match Text elements that contain Box children (direct nesting)
|
|
`<Text$_>$children</Text>` where {
|
|
$children <: contains `<Box$_>$_</Box>`,
|
|
register_diagnostic(
|
|
span = $children,
|
|
message = "<Box> can't be nested inside <Text> component. Use <Box> as a sibling or wrap <Text> inside <Box> instead."
|
|
)
|
|
}
|
|
|
|
// Also match self-closing Box inside Text
|
|
`<Text$_>$children</Text>` where {
|
|
$children <: contains `<Box$_ />`,
|
|
register_diagnostic(
|
|
span = $children,
|
|
message = "<Box> can't be nested inside <Text> component. Use <Box> as a sibling or wrap <Text> inside <Box> instead."
|
|
)
|
|
}
|