Outtrue
A set of lint rules that keep your design system clean and agent-ready.
Outtrue has three different configs. base enables three rules to start with: no-raw-values, layout-only-classname and one-way-imports. recommended adds twelve more and all turns on all 23.
{
"extends": ["./node_modules/outtrue/configs/recommended.json"]
}no-raw-values
Flags hardcoded lengths and colors in classes, attributes and inline styles. oxlint --fix automatically rewrites a length that is on the spacing scale and a width such as ring-[3px].
<div className="rounded-xl p-[12px]">
<div className="rounded-xl p-3">
<PlanName />
</div>layout-only-classname
Flags a className that restyles a primitive. A className can only place the primitive or arrange its children.
<Button className="mt-4 rounded-full bg-blue-600">Upgrade</Button>
<Button className="mt-4" variant="primary">Upgrade</Button>Let a class through with allow, or on one component with allowFor.
{
"rules": {
"design-system/layout-only-classname": [
"error",
{
"allow": ["^hover:bg-muted$"],
"allowFor": {
"Card": ["^p[xy]?-"],
"Dialog.Content": ["^p[xy]?-"]
}
}
]
}
}one-way-imports
Flags an import from a level above.
import { PLANS } from "@/app/pricing/plans";
export default function PlanCard() {
export default function PlanCard({ plans }: PlanCardProps) {Use layers to list your folders, lowest first.
{
"rules": {
"design-system/one-way-imports": [
"error",
{ "layers": ["src/components/ui", "src/components", "src/app"] }
]
}
}no-rebuilt-primitives
Flags a raw <button>, <input> or overlay where a primitive exists.
<button type="submit">Save</button>
<Button type="submit">Save</Button>no-duplicate-primitives
Flags a component file named like a primitive, such as billing/button.tsx.
export default function Button({ plan }: Props) {
export default function UpgradeButton({ plan }: Props) {
const checkout = useCheckout(plan);
return <Button onClick={checkout}>Upgrade to {plan}</Button>;
}Rename the file as well. This one becomes billing/upgrade-button.tsx.
wrapped-libraries
Flags an import of a library the design system wraps, such as Base UI.
import { Dialog } from "@base-ui/react/dialog";
import { Dialog } from "@/design-system/components/dialog";index-in-sync
Flags a component missing from the index or an index line with no file.
- Button: triggers an action. `components/button`
- Dialog: shows content over the page. `components/dialog`
- Tooltip: names a control on hover. `components/tooltip`complete-composition
Flags a composable component used without a required part.
<Accordion>
<AccordionItem>
<AccordionTrigger>Can I cancel anytime?</AccordionTrigger>
<AccordionPanel>Yes, from the billing page.</AccordionPanel>
</AccordionItem>
</Accordion>List the parts each component needs in parts, or nothing is checked.
{
"rules": {
"design-system/complete-composition": [
"error",
{
"parts": {
"Accordion": ["AccordionItem", "AccordionTrigger", "AccordionPanel"],
"Dialog": [["DialogContent", "DialogPopup"]]
}
}
]
}
}closed-variants
Flags a variant or size prop typed as any string.
interface ButtonProps {
children: React.ReactNode;
variant?: string;
variant?: "primary" | "secondary";
}semantic-tokens-only
Flags a raw palette class such as text-gray-900 outside the design system.
<p className="text-gray-900">Billed yearly</p>
<p className="text-foreground">Billed yearly</p>Map a raw class to the variable that replaces it in suggest and oxlint --fix will rewrite it for you automatically.
{
"rules": {
"design-system/semantic-tokens-only": [
"error",
{ "suggest": { "text-gray-900": "text-foreground" } }
]
}
}no-deprecated
Flags a deprecated component, prop or import path.
<Button color="blue">Upgrade</Button>
<Button variant="primary">Upgrade</Button>Map each old name to the new one in components, props or imports. oxlint --fix automatically rewrites an import path.
{
"rules": {
"design-system/no-deprecated": [
"error",
{
"components": { "Modal": "Dialog" },
"props": { "Button.color": "variant" }
}
]
}
}primitive-naming
Flags a primitive named after a page or a variant, such as pricing-card-pro.
export default function PricingCardPro({ children }: Props) {
export default function Card({ children, variant }: Props) {
return <div className="rounded-xl p-4">{children}</div>;
}Rename the file as well. This one becomes card.tsx.
no-boolean-variants
Flags a boolean prop such as isPrimary where a variant value belongs.
interface ButtonProps {
children: React.ReactNode;
isPrimary?: boolean;
variant?: "primary" | "secondary";
}no-theme-overrides
Flags a color set for one theme at the call site, such as dark:bg-gray-900.
<div className="bg-white dark:bg-gray-900">
<div className="bg-background">
<PlanName />
</div>prefer-shorthand
Flags w-4 h-4, h-screen and an arbitrary z-[n]. oxlint --fix automatically rewrites w-4 h-4 to size-4.
<span className="w-4 h-4 rounded-full" />
<span className="size-4 rounded-full" />no-template-classname
Flags a className built with a template literal.
<li className={`px-3 ${active ? "text-foreground" : "text-muted"}`}>
<li className={cn("px-3", active ? "text-foreground" : "text-muted")}>
{label}
</li>icon-button-label
Flags an icon-only button with no label or an empty one. An aria-label or a title counts.
<Button>
<Button aria-label="Delete">
<TrashIcon />
</Button>no-cross-surface-imports
Flags one part of the product importing a component from another.
import EmptyState from "@/components/settings/empty-state";
import EmptyState from "@/design-system/components/empty-state";Each folder in src/components counts as one part. Put a folder in shared if every part can import it or in composers if it can import every part.
{
"rules": {
"design-system/no-cross-surface-imports": [
"error",
{ "shared": ["layout"], "composers": ["shell"] }
]
}
}no-reach-in-selectors
Flags a class that styles the inside of a primitive, such as [&_svg]:size-4.
<Button className="[&_svg]:size-4">Delete</Button>
<Button iconSize="sm">Delete</Button>known-tokens
Flags a color step the theme does not define, such as bg-gray-150.
<div className="h-px bg-gray-150" />
<div className="h-px bg-gray-200" />classname-passthrough
Flags a primitive that accepts className and never applies it.
export default function Badge({ children, className }: BadgeProps) {
return <span className="rounded-md px-2">{children}</span>;
return <span className={cn("rounded-md px-2", className)}>{children}</span>;
}no-important
Flags the ! modifier.
<h2 className="mt-0!">Plans</h2>
<h2 className="mt-0">Plans</h2>no-inline-style
Flags a fixed value in a style object.
<div style={{ padding: 12 }} />
<div className="p-3" />Configuration
To see what Outtrue flags, run pnpm oxlint or pnpm eslint. If you want to configure the rules manually, you can turn them on or off individually in rules.
{
"extends": ["./node_modules/outtrue/configs/base.json"],
"rules": {
"design-system/known-tokens": "error",
"design-system/one-way-imports": "off"
}
}Options
Set primitives to the folder that has your design system’s components. The default one is src/design-system.
{
"extends": ["./node_modules/outtrue/configs/recommended.json"],
"settings": { "design-system": { "primitives": "src/components/ui" } }
}Paths start from the folder that has your package.json. In a monorepo that is each package, so write src/components/ui and not apps/web/src/components/ui.
Imports that start with @/ are read from src. If your project has no src folder, point alias at the root.
{
"settings": {
"design-system": {
"alias": { "@/": "" },
"primitives": "@/components/ui"
}
}
}To give a rule options, add them after "error". Every option is listed in OPTIONS.md (opens in a new tab).
{
"rules": {
"design-system/no-important": ["error", { "allow": ["^!hidden$"] }]
}
}If your codebase already breaks a lot of rules, you can save a baseline (opens in a new tab) so only new ones fail while you fix the rest.
ESLint
Outtrue also works with ESLint, you can add it to eslint.config.mjs.
import parser from "@typescript-eslint/parser";
import { defineConfig } from "eslint/config";
import outtrue from "outtrue";
export default defineConfig({
files: ["**/*.{js,jsx,ts,tsx}"],
languageOptions: {
parser,
parserOptions: { ecmaFeatures: { jsx: true } },
},
plugins: { "design-system": outtrue },
rules: outtrue.configs.recommended.rules,
settings: { "design-system": { primitives: "src/components/ui" } },
});More
If you enjoy these rules and want to learn more, take a look at Interfaces, my design engineering magazine.
It’s where I share everything I know about building great interfaces. From animation and typography to performance and accessibility.