unit-layout-mappings
Specify flow-relative or physical layout mappings for units.
a { width: 100vw; }/** ↑ * This unit */Use this rule to enforce a convention. Physical units like vw and vh are tied to the viewport, while flow-relative units like vi and vb follow the writing mode.
Choose:
"flow-relative"to support right-to-left and vertical writing modes"physical"if you support only one writing mode, or for older browsers
The fix option can automatically fix problems reported by this rule when both the primary option is "flow-relative" and the languageOptions.directionality configuration property is configured.
This rule supports 2 message arguments: the disallowed mapping and the unit, or the physical unit and its flow-relative equivalent.
Prior art:
Options
Section titled “Options”"flow-relative"
Section titled “"flow-relative"”Layout mappings for units must always be flow-relative.
Given:
{ "unit-layout-mappings": "flow-relative"}The following patterns are considered problems:
a { margin-inline-start: 10vw; }a { inline-size: 50cqw; }The following patterns are not considered problems:
a { margin-inline-start: 10vi; }a { inline-size: 50cqi; }"physical"
Section titled “"physical"”Layout mappings for units must always be physical.
Given:
{ "unit-layout-mappings": "physical"}The following patterns are considered problems:
a { margin-top: 10vb; }a { width: 50cqi; }The following patterns are not considered problems:
a { margin-top: 10vh; }a { width: 50cqw; }Optional secondary options
Section titled “Optional secondary options”ignoreUnits
Section titled “ignoreUnits”Ignore the specified units.
{ "ignoreUnits": ["array", "of", "units", "/regex/"] }Given:
{ "unit-layout-mappings": ["flow-relative", { "ignoreUnits": ["vh", "/^cq/"] }]}The following patterns are not considered problems:
a { margin-inline-start: 10vh; }a { width: 50cqw; }