systomic

Tabular numbers

Proportional digits have different widths, so a changing number shakes everything next to it. Tabular figures keep every digit the same width.

  • RuleIn recommended.json: breaking it breaks the design-system contract.
  • WarningShows in the editor and in CI output, but doesn't fail the run (unless you pass --deny-warnings).
  • Quick-fixYour editor offers a one-click fix. oxlint --fix leaves it to you.

See the difference

Before
Total$1,111.11USD
<span>{total}</span>
After
Total$1,111.11USD
<span className="tabular-nums">{total}</span>

What doesn't work

2 findings

What works

No findings

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}).

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 with extends, type aliases, Readonly/Partial, and types imported from other files or packages (same resolution as component-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, and numericFunctions.

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.

Esc