Meridian/Kit · Lint rules
Kit · @meridian/eslint-plugin
The rules in this book, as errors.
import meridian from "@meridian/eslint-plugin";
export default [meridian.configs.recommended];app/deploys/page.tsx
14:9 error Solid danger only inside a dialog danger-is-outlined
22:24 error Raw colour #DC3E42 in color no-raw-colors
31:7 error Status needs a word status-needs-label
3:10 error Import colors from tokens.stylex stylex-import-vars…
✖ 4 problems (4 errors) · 1 fixable with --fixEach rule has a docs page with ✓/✗ examples and a link back to the page of this book it enforces. 141 tests.
Rules
| Rule | What it checks |
|---|---|
| stylex-import-vars-from-stylex-files | Variables come from .stylex entry points; autofix |
| no-raw-colors | Hex, rgb() and named colours in styles |
| danger-is-outlined | dangerSolid only inside a dialog |
| one-accent-per-file | Cobalt is the single conversion moment |
| status-needs-label | No colour-only status or icon-only badge |
| icon-button-label | Icon buttons need label |
| one-staged-bar | One staged-changes bar per page |
| no-classname-on-kit | Use the style prop |
| meter-no-bad-tone | Meters go amber, never red |
| prefer-longhand | paddingBlock over "4px 8px" |
Setup
import tsParser from "@typescript-eslint/parser";
import meridian from "@meridian/eslint-plugin";
export default [
{
files: ["**/*.{ts,tsx}"],
languageOptions: { parser: tsParser, parserOptions: { ecmaFeatures: { jsx: true } } },
},
meridian.configs.recommended, // or meridian.configs.strict
{
// optional overrides
rules: {
"@meridian/no-raw-colors": ["error", { allow: ["#111110"], ignoreFiles: ["/legacy/"] }],
},
},
];
@meridian/eslint-plugin is flat config only, for ESLint 9 and 10. recommended warns on one-accent-per-file and prefer-longhand and errors on the rest; strict makes all ten errors.
Component rules resolve JSX tags by import binding: import { Button as B } from "@meridian/ui" and <UI.Button> are both checked; a Button from anywhere else is not. When the kit is vendored, list its paths in settings.meridian.componentSources.
Every rule · 10
@meridian/stylex-import-vars-from-stylex-files
Require StyleX variables to be imported straight from the kit's .stylex entry points
- Recommended
- error
- Autofix
- yes(source specifier, when the whole import can move); otherwise a suggestion splits the import
- Kit README
- Rule 1: import variables from the
.stylexentry points
StyleX resolves defineVars / defineConsts at compile time and only recognises them when they're imported directly from a .stylex file. A barrel re-export compiles to a runtime object and breaks the build.
import { colors, space } from "@meridian/ui/tokens";
import { media } from "@meridian/ui";
import { Button, colors } from "@meridian/ui"; // suggestion: split into two imports
import { colors, space } from "@meridian/ui/tokens.stylex";
import { media } from "@meridian/ui/palette.stylex";
import { theme, type } from "@meridian/ui/tokens"; // styles and themes may use the barrel
// No options.
"@meridian/stylex-import-vars-from-stylex-files": "error",
@meridian/no-raw-colors
Disallow hard-coded colors in StyleX styles; use the colors roles
- Recommended
- error
- Autofix
- no
- Kit README
- Writing styles · Changing a color
Color roles flip between light and dark automatically; a literal doesn't, and it silently drifts from the palette. Components read roles, never hex values or the palette. Always-dark surfaces use colors.codeBg / colors.codeFg.
const s = stylex.create({
card: { backgroundColor: "#fff", boxShadow: "0 0 0 1px rgba(0,0,0,.08)" },
link: { color: { default: "blue", ":hover": "navy" } },
});
const s = stylex.create({
card: { backgroundColor: colors.surface, boxShadow: `0 0 0 1px ${colors.border}` },
link: { color: { default: colors.accent, ":hover": colors.accentHover } },
icon: { fill: "currentColor", backgroundColor: "transparent" },
});
"@meridian/no-raw-colors": ["error", {
allow: ["#111110"], // extra literals to accept (case-insensitive). Always allowed: transparent, currentColor,
// inherit, initial, unset, revert, revert-layer, none
ignoreFiles: ["/legacy/"], // skip files whose path contains any of these substrings (no globs)
tokenDirs: ["/tokens/"], // defineVars/createTheme are not checked in these folders (default ["/tokens/"])
}]
@meridian/danger-is-outlined
Allow variant="dangerSolid" only on the confirm button inside a dialog
- Recommended
- error
- Autofix
- suggestion(
variant="danger") - Kit README
- Rules the components enforce
Danger is outlined. A filled red button is the last, deliberate step of a destructive flow, after the dialog has stated the consequence. Anywhere else it shouts.
<Button variant="dangerSolid">Delete</Button>
<Button variant="danger" icon={trash}>Delete</Button>
<Dialog open title="Delete api-gateway" footer={<Button variant="dangerSolid">Delete api-gateway</Button>} />
"@meridian/danger-is-outlined": ["error", {
dialogs: ["Dialog", "ConfirmDialog"], // ancestors that allow dangerSolid; extra names match your own wrappers
components: ["Button", "IconButton", "CopyButton"] // kit components to check
}]
@meridian/one-accent-per-file
Limit Cobalt (variant="accent") actions to the single conversion moment per module
- Recommended
- warn(error in
strict) - Autofix
- no
- Kit README
- Rules the components enforce
Primary actions are ink. Cobalt is reserved for the single conversion moment on a page — upgrade, deploy, create. Two accent buttons compete and neither reads as the moment.
<Button variant="accent">Upgrade</Button>
<Button variant="accent">Contact sales</Button>
<Button variant="accent">Upgrade</Button>
<Button variant="secondary">Contact sales</Button>
"@meridian/one-accent-per-file": ["warn", { max: 1 }]
@meridian/status-needs-label
Require a word next to every status: <Status> needs children, icon-only <Badge> needs an aria-label
- Recommended
- error
- Autofix
- no
- Kit README
- Rules the components enforce
Status is an outlined hexagon plus a word, never a colored dot alone. Color must never be the only carrier of meaning: it fails for color-blind users, screen readers and greyscale screenshots.
<Status state="bad" />
<Badge tone="good"><Check aria-hidden /></Badge>
<Status state="bad">Failed</Status>
<Badge tone="good"><Check aria-hidden /> Healthy</Badge>
<Badge tone="good" aria-label="Verified"><Check aria-hidden /></Badge>
// No options.
"@meridian/status-needs-label": "error",
@meridian/one-staged-bar
Allow one <StagedBar> per module
- Recommended
- error
- Autofix
- no
- Kit README
- Rules the components enforce
One StagedBar per page. It floats bottom-center and becomes a full-width footer under 640px, so a second bar stacks on top of the first and the user can't tell which changes each one applies.
<StagedBar added={2} onDiscard={discardDns} onReview={reviewDns} />
<StagedBar changed={1} onDiscard={discardAcl} onReview={reviewAcl} />
<StagedBar added={2} changed={1} onDiscard={discardAll} onReview={reviewAll} />
// No options.
"@meridian/one-staged-bar": "error",
@meridian/icon-button-label
Require a non-empty label on <IconButton> (it becomes the accessible name and tooltip)
- Recommended
- error
- Autofix
- yes(renames
aria-labeltolabel) - Kit README
- Components
An icon-only button has no visible text; label is its only accessible name. Accessibility: real roles and labels, color never the sole carrier of meaning.
<IconButton icon={<RotateCw />} />
<IconButton label="" icon={<RotateCw />} />
<IconButton aria-label="Reconnect" icon={<RotateCw />} /> // autofix → label="Reconnect"
<IconButton label="Reconnect" icon={<RotateCw size={14} strokeWidth={1.5} aria-hidden />} />
// No options.
"@meridian/icon-button-label": "error",
@meridian/no-classname-on-kit
Disallow className on kit components; override with the style prop
- Recommended
- error
- Autofix
- no
- Kit README
- Writing styles
Every kit component takes a style prop of StyleX styles, applied last so it wins; there's no className. A class would be dropped or fight StyleX's atomic ordering.
<Card className="mt-4" />
const s = stylex.create({ card: { marginTop: space.s4 } });
<Card style={s.card} />
// No options.
"@meridian/no-classname-on-kit": "error",
@meridian/meter-no-bad-tone
Keep meters out of red: no tone prop, no colors.bad* styles on <Meter>
- Recommended
- error
- Autofix
- no
- Kit README
- Rules the components enforce
Meters turn amber at 80% and never red: a full disk or quota is a warning, not a failure. Red is reserved for things that have actually failed.
<Meter value={97} tone="bad" />
<Meter value={97} style={s.red} />
const s = stylex.create({ red: { color: colors.bad } });
<Meter value={97} label="Disk" detail="97%" />
// No options.
"@meridian/meter-no-bad-tone": "error",
@meridian/prefer-longhand
Prefer longhand properties over multi-value shorthands in stylex.create
- Recommended
- warn(error in
strict) - Autofix
- suggestion(for plain string values)
- Kit README
- Writing styles
StyleX merges styles per property. Mixing padding with a later paddingTop override behaves predictably only with longhands, and longhands read better in review. The kit writes paddingInline / paddingBlock and borderTopColor.
const s = stylex.create({ row: { padding: "4px 8px", gap: "8px 12px" } });
const s = stylex.create({ row: { paddingBlock: "4px", paddingInline: "8px", rowGap: "8px", columnGap: "12px" } });
const t = stylex.create({ card: { padding: space.s6 } });
// No options.
"@meridian/prefer-longhand": "warn", // "error" in strict
Meridian Design Language47