No hardcoded values
Lengths and colors come from the scale and the tokens. One-off values drift: 13px here, 11px there, a gray that is almost the border color.
12345{ "rules": { "systomic/no-hardcoded-values": "warn" }}See the difference
className="p-[13px] gap-[11px] bg-[#f4f4f6]"className="p-3 gap-3 bg-muted"What doesn't work
6 findings12345678910111213141516171819import * as stylex from "@stylexjs/stylex";
const styles = stylex.create({ card: { padding: 12, backgroundColor: "#fafafa", },});
export function PlanCard() { return ( <> <div className="rounded-xl p-[12px] bg-[#fff]">Pro</div> <div style={{ marginTop: "13px" }} /> <div {...stylex.props(styles.card)} /> <svg><circle fill="#ff0000" /></svg> </> );}systomic/no-hardcoded-values padding: 12 hardcodes a length. Use a value from the scale or a token.
systomic/no-hardcoded-values backgroundColor: "#fafafa" hardcodes a color. Use a color token (a theme color or var(--…)).
systomic/no-hardcoded-values p-[12px] hardcodes a length. 12px is p-3 on the spacing scale.
systomic/no-hardcoded-values bg-[#fff] hardcodes a color. Use a color token (a theme color or var(--…)).
systomic/no-hardcoded-values marginTop: "13px" hardcodes a length. Use a value from the scale or a token.
systomic/no-hardcoded-values fill="#ff0000" hardcodes a color. Use a color token (a theme color or var(--…)).
What works
No findings123456789101112131415161718import * as stylex from "@stylexjs/stylex";
export const tokens = stylex.defineVars({ gutter: "12px", surface: "#fafafa" });
const styles = stylex.create({ card: { padding: tokens.gutter, backgroundColor: tokens.surface },});
export function PlanCard() { return ( <> <div className="rounded-xl p-3 bg-background">Pro</div> <div className="w-[calc(100%-var(--sidebar))] p-(--gutter)" style={{ marginTop: "var(--space-3)", width: "100%" }} /> <div {...stylex.props(styles.card)} /> <svg><circle fill="currentColor" /></svg> </> );}Details
Lengths and colors come from the design system’s scales and tokens, not from one-off values. oxlint --fix rewrites a length that is on the scale.
1<div className="rounded-xl p-[12px]" /> // reported, fixed to `p-3`
p-[12px]hardcodes a length. 12px isp-3on the spacing scale.
Reported:
- Tailwind arbitrary values with
px/remlengths or colors:p-[12px],text-[13px],rounded-[10px],w-[calc(100%-12px)],[height:52px],bg-[#fafafa],text-[rgb(0_0_0/50%)],shadow-[0_1px_2px_rgba(…)]. - Inline styles and StyleX (
stylex.create, including conditional values and pseudo blocks): non-zero numbers andpx/remstrings in length properties (padding: 12,marginTop: "8px",fontSize: "0.875rem"), and colors (color: "red",backgroundColor: "#fff",boxShadow: "0 1px 2px #0003"). - Color attributes:
fill="#ff0000",stroke,color,stopColor, ….
Autofix (classes only), when the value is on the scale:
| Found | Fixed to | Scale |
|---|---|---|
p-[12px], gap-[0.5rem], mt-[-4px], h-[1px] |
p-3, gap-2, -mt-1, h-px |
spacing (spacing px per step, whole and half steps) |
ring-[3px], border-[1px], border-t-[2px] |
ring-3, border, border-t-2 |
widths |
rounded-[8px] |
rounded-lg |
radius (Tailwind’s, plus radii) |
text-[14px] |
text-sm |
font size (Tailwind’s, plus fontSizes) |
Names from radii and fontSizes win over Tailwind’s names for the same value: with "radii": { "control": 4 }, rounded-[4px] is fixed to rounded-control, not rounded-sm. Give each value one name: when several of your names share a value, JavaScript’s key order decides (number-like names such as "1" come first). To use only your own scales, set "extendTailwind": false. A DEFAULT radius is the bare rounded:
1"systomic/no-hardcoded-values": ["warn", { "extendTailwind": false, "radii": { "DEFAULT": 6, "1": 4, "2": 8 }, "fontSizes": { "14-regular": 14 } }]Not reported:
- Tokens:
var(…),theme(…),p-(--gutter),calc(100% - var(--sidebar)),stylex.defineVars/ token references. - Relative and unitless values:
%,em, viewport units,0,z-[60],leading-[1.2],lineHeight: 1.5, durations. - Keywords:
currentColor,transparent,inherit,none. - Plain objects that aren’t styles (
const config = { padding: 12 }).
The design system itself has to define raw values somewhere. Exclude it with ignore:
1"systomic/no-hardcoded-values": ["warn", { "ignore": ["src/design-system/**"], "allow": ["h-[1px]"] }]ignore globs are relative to the nearest package.json, so in a monorepo src/design-system/** matches in every package. To exclude a folder in one package only, set the option in an Oxlint overrides entry for that package (see Configuration).
| Option | Default |
|---|---|
spacing |
4 (px per spacing step) |
radii |
{}, merged over Tailwind’s radius scale; its names win for the same value |
fontSizes |
{}, merged over Tailwind’s font sizes; its names win for the same value |
extendTailwind |
true; false drops Tailwind’s radius and font size scales and uses only radii and fontSizes |
lengths / colors |
true |
allow |
[]: classes or values, * wildcards |
ignore |
[]: file globs relative to the nearest package.json; see monorepos |
attributes, callees, styleAttributes |
see styling |
Inspired by no-raw-values from Outtrue by Jakub Krehel.