JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 40423
  • Score
    100M100P100Q163174F
  • License MIT

A Stylelint plugin to enforce the use of logical CSS properties, values and units.

Package Exports

  • stylelint-plugin-logical-css
  • stylelint-plugin-logical-css/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stylelint-plugin-logical-css) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Stylelint Plugin Logical CSS

License NPM Version

Stylelint Plugin Logical CSS aims to enforce the use of logical CSS properties, values and units. The plugin provides two rules. But first, let's get set up.

Read more about Logical CSS on MDN

Getting Started

Before getting started with the plugin, you must first have Stylelint version 14.0.0 or greater installed

To get started using the plugin, it must first be installed.

npm i stylelint-plugin-logical-css --save-dev
yarn add stylelint-plugin-logical-css --dev

With the plugin installed, the rule(s) can now be added to the project's Stylelint configuration.

{
  "plugins": ["stylelint-plugin-logical-css"],
  "rules": {
    "plugin/use-logical-properties-and-values": [
      true,
      { "severity": "warning" }
    ],
    "plugin/use-logical-units": [true, { "severity": "warning" }]
  }
}

Rules

Let's explore each rule to better understand what it does, and does not, allow.

plugin/use-logical-properties-and-values

Learn more about the properties and values supported by this rule

This rule is responsible for checking both CSS properties and values. When a physical property or value is found, it will be flagged.

Not Allowed

.heading {
  max-width: 90ch; /* Will flag the use of "width" */
  text-align: left; /* Will flag the use of "left" */
}

Allowed

.heading {
  max-inline-size: 90ch;
  text-align: start;
}

plugin/use-logical-units

Learn more about the properties and values supported by this rule

Read about current browser support for logical viewport units.

This rule is responsible for checking that logical CSS units are used. Specifically, viewport units like vw and vh which stand for viewport width and viewport height respectively will not reflect different writing modes and directions. Instead, this rule will enforce the logical equivalents, vi and vb.

Not Allowed

body {
  max-block-size: 100vh; /* Will flag the physical use of viewport "height" */
}

Allowed

body {
  max-block-size: 100vb;
}