React PlumberInstall package

Concepts

Habits

Habits are rules about how styles are written, such as keeping hover styles off touch screens, or replacing a focus outline when you remove it. Your team chooses them, and plumber check runs them along with the token checks.

Turning habits on

List the habits you want in your config. plumber init turns on the first four. The others are off until you add them.

js
// plumber.config.ts
export default {
  habits: ['hover-gate', 'focus-outline', 'transition-named', 'no-ease-in'],
};

With no habits, no habit runs. npx plumber habits lists all fifteen, with the number of times each would break in your project and whether it is on.

The fifteen habits

HabitSeverityBreaks when
hover-gateerrora hover style isn't limited to devices that hover, so it sticks after a tap
focus-outlineerroran outline is removed with no visible focus style to replace it
transition-namederrortransition: all, which also animates changes you didn't mean to animate
no-ease-inerrorease-in on a transition or animation, so feedback starts slowly
logical-inlineerrora physical side, like left or margin-right, that won't mirror right to left
viewport-dynamicerrorvh or vw, which jump as mobile toolbars come and go
safe-area-fallbackerrorenv(safe-area-inset-*) with no fallback
overflow-clipwarna decorative overflow: hidden that also creates a scroll container
overscroll-containwarna scrolling area whose scroll leaks to the page behind it
tracking-emwarnletter spacing written in px, which doesn't grow with the font size
color-schemewarna dark theme that never sets color-scheme, so scrollbars and controls stay light
composited-motionwarna transition on a layout property (width, height, top, margin…), which re-lays out every frame
reduced-motion-fadewarna global reduced-motion rule that turns every animation and transition off, so state changes vanish
font-metricswarnweb fonts with no metric-matched fallback (size-adjust, ascent-override), so the page jumps when they load
real-quoteswarnstraight quotes, ... and spaced hyphens in text a person reads; the fix is the typeset text

A habit finding has the same parts as any other. plumber check --rule habits lists just these:

text
  !  color: red                                            styles.css:1
     also applies on touch screens [habits/hover-gate]
     → Use pointer-hover: (or wrap the rule in @media (hover: hover) and (pointer: fine))

If one is on purpose, accept it with a reason: plumber accept --rule habits/hover-gate --site src/styles.css:1 --why "…".

Your own habits

Add an object to habits to write a rule of your own. It matches declarations by property, value, where they came from and what they're on:

js
export default {
  habits: [
    'hover-gate',
    {
      id: 'no-fixed-heights-on-text',
      when: { prop: 'height', value: '^\\d+px$', ownerElements: ['p'] },
      message: 'Text must grow with its content.',
      severity: 'warn',
    },
  ],
};
FieldMatches
propthe CSS property
valuea regular expression for the value
originhow it was written: class, arbitrary, stylesheet, apply, inline, custom-property or keyframes
owner, ownerElementsthe element or component it's on
when.has, when.lacksa media, pseudo or selector condition the declaration must have, or must not

Severity defaults to error. A habit of your own is plain data, so it can be validated and shared.