DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to lock component styling with per-component contracts with Lint

Let pages change some styles on a component while keeping its size, shape, and font fixed.

Short answer: Run npm install -D @shadcn/lint eslint @typescript-eslint/parser in the project; then in eslint.config.mjs, set "shadcn/no-restyle" with allow: ["layout"] and a contracts entry such as { pattern: "^Button$", allow: ["w-full", "mt-*", "mb-*"] }; add a custom message under message, such as spacing: "Use the size prop instead of padding.", so the error tells the agent what to do. All steps.

Who it is forA design system owner who ships shared components and wants pages and agents to change only the parts the design allows.

The problemShared components get restyled in ways the design did not intend, and typed props alone cannot express rules like allow margin but keep padding.

The outcomeEach component gets its own allow and deny rules in config, and violations show a message that explains the allowed options.

What you need first

  • Node.js 20.19 or later
  • A Tailwind v4 project (shadcn/ui is not required)
  • ESLint 9.30 or later, or Oxlint 1.80 or later
  • A React, Vue, or Svelte project

Steps

  1. Run npm install -D @shadcn/lint eslint @typescript-eslint/parser in the project.
  2. In eslint.config.mjs, set "shadcn/no-restyle" with allow: ["layout"] and a contracts entry such as { pattern: "^Button$", allow: ["w-full", "mt-*", "mb-*"] }.
  3. Add a custom message under message, such as spacing: "Use the size prop instead of padding.", so the error tells the agent what to do.
  4. Run npx eslint . and check that an allowed class passes while a disallowed class such as a custom padding is reported.

Prompt for your agent

Use the GitHub repo shadcn-ui/lint to add a no-restyle contract for <component-name> in <project-path>. Write the contract in the ESLint config, then run the lint command. Expected output: the contract allows the listed classes and reports the others. Verify that one disallowed class on <component-name> produces the custom message from the config.

Caveat. The README examples use component names such as Button and CardTitle, so contract patterns must match the names in your own code.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for shadcn-ui/lint and "Lock component styling with per-component contracts"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer