Skip to content

Latest commit

 

History

History
119 lines (91 loc) · 2.01 KB

File metadata and controls

119 lines (91 loc) · 2.01 KB

declaration-property-unit-allowed-list

Specify a list of allowed property and unit pairs within declarations.

a { width: 100px; }
/** ↑         ↑
 * These properties and these units */

Options

object: { "unprefixed-property-name": ["array", "of", "units"] }

If a property name is surrounded with "/" (e.g. "/^animation/"), it is interpreted as a regular expression. This allows, for example, easy targeting of shorthands: /^animation/ will match animation, animation-duration, animation-timing-function, etc.

Given:

{
  "font-size": ["em", "px"],
  "/^animation/": ["s"],
  "line-height": []
}

The following patterns are considered violations:

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 violations:

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

ignore: ["inside-function"]

Ignore units that are inside a function.

For example, given:

{
  "/^border/": ["px"],
  "/^background/": ["%"],
},
{
  ignore: ["inside-function"],
},

The following patterns are not considered violations:

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));
}