npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

stylelint-8-point-grid

v5.0.1

Published

Stylelint plugin to validate CSS with 8-point grid guideline

Readme

stylelint-8-point-grid

Node.js CI npm version

A Stylelint plugin that ensures spacing values (margin, padding, height, width, etc.) adhere to an 8-point grid system.

/* ❌ Invalid */
.element {
  margin: 5px; /* not divisible by 8 */
  padding: 0.3rem; /* not divisible by 0.5 */
}

/* ✅ Valid */
.element {
  margin: 8px; /* 1x grid */
  padding: 0.5rem; /* 1x grid */
}

Features

  • Validates pixel (px) and rem values
  • Supports CSS Logical Properties
  • Configurable base value (default: 8px / 0.5rem)
  • Allowlist for exceptions
  • Ignore specific properties

Installation

npm install stylelint-8-point-grid --save-dev
# or
yarn add stylelint-8-point-grid --dev

Quick Start

Add to your .stylelintrc:

{
  "extends": ["stylelint-8-point-grid"]
}

This enforces the default 8px grid (0.5rem for rem values).

Options

{
  "extends": ["stylelint-8-point-grid"],
  "rules": {
    "plugin/8-point-grid": {
      "base": 4,
      "allowlist": ["2px", "1px", "0.0625rem"],
      "customProperties": ["size", "position"],
      "ignorelist": ["width", "height"]
    }
  }
}

| Option | Type | Default | Description | | ------------------ | -------- | ------- | --------------------------------------------------------------------------------------------------- | | base | number | 8 | Base grid value. Pixel values must be divisible by this. Rem values must be divisible by base/16. | | allowlist | string[] | [] | Values to exclude from validation | | customProperties | string[] | [] | Additional CSS properties to validate | | ignorelist | string[] | [] | CSS properties to skip validation |

Supported Properties

Box Model

  • margin, margin-top, margin-bottom, margin-left, margin-right
  • padding, padding-top, padding-bottom, padding-left, padding-right
  • height, min-height, max-height
  • width, min-width, max-width

Positioning

  • top, bottom, left, right

CSS Logical Properties

  • margin-block, margin-block-start, margin-block-end
  • margin-inline, margin-inline-start, margin-inline-end
  • padding-block, padding-block-start, padding-block-end
  • padding-inline, padding-inline-start, padding-inline-end
  • block-size, min-block-size, max-block-size
  • inline-size, min-inline-size, max-inline-size
  • inset, inset-block, inset-inline
  • inset-block-start, inset-block-end
  • inset-inline-start, inset-inline-end

Limitations

The following patterns are ignored as they require runtime or preprocessing context:

  • CSS calc() functions - computed at runtime
  • Sass/SCSS variables - values unavailable during linting
/* Ignored examples */
.element {
  width: calc(100% - 31px);
  margin: $spacing;
}

Workarounds:

  • Use pre-calculated CSS custom properties or utility classes
  • Ensure variables follow grid values (e.g., $spacing: 8px)
  • Document grid compliance in comments when using calc()

Best Practices

  1. Design Tokens: Pre-calculate grid-compliant values

    :root {
      --spacing-sm: 8px; /* 1x */
      --spacing-md: 16px; /* 2x */
      --spacing-lg: 24px; /* 3x */
    }
  2. Utility Classes: Common spacing patterns

    .p-1 {
      padding: 8px;
    }
    .p-2 {
      padding: 16px;
    }
    .m-1 {
      margin: 8px;
    }
    .m-2 {
      margin: 16px;
    }
  3. Document calc() usage

    /* 16px margins = 2x grid */
    .container {
      width: calc(100% - 32px);
      margin: 0 16px;
    }

References

License

MIT