declaration-property-unit-allowed-list
Specify a list of allowed property and unit pairs within declarations.
a { width: 100px; }/** ↑ ↑ * These properties and these units */Use this rule to enforce a subset of units for a property as a convention. For example, allow only:
remandemforfont-size, so that text scales with your users’ settings- no units for
line-height, so that it scales with each element’s font size
This rule supports 2 message arguments: the property name and the disallowed unit.
Options
Section titled “Options”Object<string, Array<string>>
Section titled “Object<string, Array<string>>”{ "property-name": ["array", "of", "units"] }You can specify a regex for a property name, such as { "/^animation/": [] }.
Given:
{ "declaration-property-unit-allowed-list": { "font-size": ["em", "px"], "/^(-webkit-)?animation/": ["s"], "line-height": [] }}The following patterns are considered problems:
a { font-size: 1.2rem; }a { animation: animation-name 500ms ease; }a { -webkit-animation: animation-name 500ms ease; }a { animation-duration: 500ms; }a { line-height: 13px; }The following patterns are not considered problems:
a { font-size: 1em; }a { height: 100px; }a { animation: animation-name 5s ease; }a { -webkit-animation: animation-name 5s ease; }a { animation-duration: 5s; }a { line-height: 1; }Optional secondary options
Section titled “Optional secondary options”ignore
Section titled “ignore”{ "ignore": ["array", "of", "options"] }"inside-function"
Section titled “"inside-function"”Ignore units that are inside a function.
Given:
{ "declaration-property-unit-allowed-list": [ { "/^border/": ["px"], "/^background/": ["%"] }, { "ignore": ["inside-function"] } ]}The following patterns are not considered problems:
a { border: 1px solid hsla(162deg, 51%, 35%, 0.8);}a { background-image: linear-gradient(hsla(162deg, 51%, 35%, 0.8), hsla(62deg, 51%, 35%, 0.8));}