Skip to content

property-layout-mappings

Specify flow-relative or physical layout mappings for properties.

a { margin-left: 0; }
/** ↑
* This property */

Use this rule to enforce a convention. Physical properties like margin-left are tied to the screen, while flow-relative properties like margin-inline-start 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 up to 3 message arguments: the disallowed mapping and the property, or the physical property and its flow-relative equivalents.

Prior art:

Layout mappings for properties must always be flow-relative.

Given:

{
"property-layout-mappings": "flow-relative"
}

The following patterns are considered problems:

a { margin-left: 0; }
a { width: 0; }
a { margin: 0 1px; }
a { transition: margin-left 0 ease; }

The following patterns are not considered problems:

a { margin-inline-start: 0; }
a { inline-size: 0; }
a { margin: 0; }
a { transition: margin-inline-start 0 ease; }

Layout mappings for properties must always be physical.

Given:

{
"property-layout-mappings": "physical"
}

The following patterns are considered problems:

a { margin-inline-start: 0; }
a { inline-size: 0; }
a { transition: margin-inline-start 0 ease; }

The following patterns are not considered problems:

a { margin-left: 0; }
a { width: 0; }
a { transition: margin-left 0 ease; }

Ignore the specified properties.

{ "ignoreProperties": ["array", "of", "properties", "/regex/"] }

Given:

{
"property-layout-mappings": [
"flow-relative",
{ "ignoreProperties": ["/^margin/", "width"] }
]
}

The following patterns are not considered problems:

a { margin-left: 0; }
a { width: 0; }
a { transition: margin-left 0 ease; }