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.
// 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
| Habit | Severity | Breaks when |
|---|---|---|
hover-gate | error | a hover style isn't limited to devices that hover, so it sticks after a tap |
focus-outline | error | an outline is removed with no visible focus style to replace it |
transition-named | error | transition: all, which also animates changes you didn't mean to animate |
no-ease-in | error | ease-in on a transition or animation, so feedback starts slowly |
logical-inline | error | a physical side, like left or margin-right, that won't mirror right to left |
viewport-dynamic | error | vh or vw, which jump as mobile toolbars come and go |
safe-area-fallback | error | env(safe-area-inset-*) with no fallback |
overflow-clip | warn | a decorative overflow: hidden that also creates a scroll container |
overscroll-contain | warn | a scrolling area whose scroll leaks to the page behind it |
tracking-em | warn | letter spacing written in px, which doesn't grow with the font size |
color-scheme | warn | a dark theme that never sets color-scheme, so scrollbars and controls stay light |
composited-motion | warn | a transition on a layout property (width, height, top, margin…), which re-lays out every frame |
reduced-motion-fade | warn | a global reduced-motion rule that turns every animation and transition off, so state changes vanish |
font-metrics | warn | web fonts with no metric-matched fallback (size-adjust, ascent-override), so the page jumps when they load |
real-quotes | warn | straight 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:
! 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:
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',
},
],
};
| Field | Matches |
|---|---|
prop | the CSS property |
value | a regular expression for the value |
origin | how it was written: class, arbitrary, stylesheet, apply, inline, custom-property or keyframes |
owner, ownerElements | the element or component it's on |
when.has, when.lacks | a 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.