Skip to main content

value-keyword-layout-mappings

Specify flow-relative or physical layout mappings for value keywords.

a { float: left; }
/** ↑
* This keyword */

Use this rule to enforce a convention. Physical keywords like left and top are tied to the screen, while flow-relative keywords like inline-start and block-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 2 message arguments: the disallowed mapping and the keyword, or the physical keyword and its flow-relative equivalent.

Prior art:

Options​

"flow-relative"​

Layout mappings for value keywords must always be flow-relative.

note

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:

{
"value-keyword-layout-mappings": "flow-relative"
}

The following patterns are considered problems:

a { float: left; }
a { text-align: right; }
a { resize: horizontal; }

The following patterns are not considered problems:

a { float: inline-start; }
a { text-align: end; }
a { resize: inline; }

"physical"​

Layout mappings for value keywords must always be physical.

Given:

{
"value-keyword-layout-mappings": "physical"
}

The following patterns are considered problems:

a { float: inline-start; }
a { text-align: start; }
a { resize: inline; }

The following patterns are not considered problems:

a { float: left; }
a { text-align: right; }
a { resize: horizontal; }

Optional secondary options​

ignoreProperties​

Ignore the specified properties.

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

Given:

{
"value-keyword-layout-mappings": [
"flow-relative",
{ "ignoreProperties": ["text-align", "/^offset-/"] }
]
}

The following patterns are not considered problems:

a { text-align: left; }
a { offset-anchor: top left; }

ignoreKeywords​

Ignore the specified keywords.

{ "ignoreKeywords": ["array", "of", "keywords", "/regex/"] }

Given:

{
"value-keyword-layout-mappings": [
"flow-relative",
{ "ignoreKeywords": ["left", "/^hor/"] }
]
}

The following patterns are not considered problems:

a { float: left; }
a { resize: horizontal; }