Tabular numbers
Proportional digits have different widths, so a changing number shakes everything next to it. Tabular figures keep every digit the same width.
12345{ "rules": { "systomic/tabular-nums": "warn" }}See the difference
<span>{total}</span><span className="tabular-nums">{total}</span>What doesn't work
2 findings123456789export function Counter({ count, price }: { count: number; price: number }) { const total = count * price; return ( <div> <span>{count}</span> <span className="font-medium">{total.toFixed(2)}</span> </div> );}systomic/tabular-nums <span> only shows a number. Add tabular-nums so its digits keep the same width when the value changes.
systomic/tabular-nums <span> only shows a number. Add tabular-nums so its digits keep the same width when the value changes.
What works
No findings123456789export function Counter({ count, name }: { count: number; name: string }) { return ( <div> <span className="tabular-nums">{count}</span> <span style={{ fontVariantNumeric: "tabular-nums" }}>{count}</span> <span>{name}</span> </div> );}Details
Reports an element whose content is only a number, unless it or an enclosing element in the same JSX tree uses tabular figures. Text next to the number is fine as long as it has no letters ($ {total}, {n}%, {h}:{m}).
1234function Cart({ total }: { total: number }) { return <span>{total}</span>; // ^^^^^^ add `tabular-nums`}Accepted: tabular-nums / normal-nums (any variant, cn() included), fontVariantNumeric or fontFeatureSettings: "'tnum'" in inline styles or StyleX, and configured tabularComponents. Quick-fixes add the class, or the style property when the element has an inline style object.
How numbers are detected
Oxlint JS plugins can’t ask the TypeScript checker for types yet (oxc#19596), so the rule infers them from the source. It only reports what it can prove is a number:
- Type annotations, including destructured props,
FC<Props>, interfaces withextends, type aliases,Readonly/Partial, and types imported from other files or packages (same resolution ascomponent-overrides). - Initializers:
const total = a * b,useState(0),useState<number>(),useMemo(() => a * b), defaults ({ count = 0 }). .map()/.filter()/ … callbacks over typed arrays (products.map((p) => p.price)).- Arithmetic, unary
-/+,.length,.size,Math.*,Number(),parseInt,Date.now(), date getters. - Formatting:
.toFixed(),.toLocaleString()on numbers,Intl.NumberFormat#format, functions whose declared return type is numeric, andnumericFunctions.
Not detected: inferred types without an annotation in the chain (const data = await fetchStats()), generics, and numbers rendered by other components.
| Option | Default |
|---|---|
components |
[]: components that render their children as text (Text), checked like host elements |
tabularComponents |
[]: components that already apply tabular figures |
numericFunctions |
[]: functions returning formatted numbers, by name or obj.method |
See Styling for how classes, inline styles, StyleX and stylesheets are read.