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
"flow-relative"
Layout mappings for units must always be flow-relative.
If you want this rule to automatically fix problems, you must configure the languageOptions.directionality configuration property.
For example, for Latin-based languages such as English:
{
"languageOptions": {
"directionality": {
"block": "top-to-bottom",
"inline": "left-to-right"
}
}
}
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"
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
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; }