JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 36266
  • Score
    100M100P100Q154588F
  • 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 Main Workflow Status

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 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 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.

Options

The use-logical-properties-and-values rule accepts the following options:

Option Description
enable-auto-fix Use this option in addition to the native Stylelint --fix flag to enable auto fixing on save.
{
  "rules": {
    "plugin/use-logical-properties-and-values": [
      true,
      { "severity": "warning", "enable-auto-fix": true }
    ]
  }
}

Usage

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 this rule 👈

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.

Options

The use-logical-units rule accepts the following options:

Option Description
enable-auto-fix Use this option in addition to the native Stylelint --fix flag to enable auto fixing on save.
{
  "rules": {
    "plugin/use-logical-units": [
      true,
      { "severity": "warning", "enable-auto-fix": true }
    ]
  }
}

Usage

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

TODO

What can be expected in the future.

  • Support disabling individual property checks