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 🙏

© 2024 – Pkg Stats / Ryan Hefner

stylelint-config-property-sort-order-smacss

v10.0.0

Published

Stylelint config for Property Sort Ordering based on the SMACSS methodology

Downloads

206,843

Readme

stylelint-config-property-sort-order-smacss

SMACSS Logo Stylelint Logo

Build CodeQL NPM version NPM Downloads Coverage Status

Stylelint config for Property Sort Ordering based on the SMACSS methodology.

Installation

npm install stylelint-config-property-sort-order-smacss --save-dev
yarn add stylelint-config-property-sort-order-smacss --dev

Usage

To start using this configuration, simply extend this package in your Stylelint configuration.

{
  "extends": "stylelint-config-property-sort-order-smacss",
  "rules": {
    // Add additional rules here
  }
}

Given the above, the following patterns are considered violations:

a {
  color: red;
  top: 0;
}
a {
  top: 0;
  color: black;
  position: absolute;
  display: block;
}

The following patterns are not considered violations:

a {
  top: 0;
  color: red;
}
a {
  display: block;
  position: absolute;
  top: 0;
  color: black;
}

Refer to css-property-sort-order-smacss for the comprehensive list of property orders.

For more information on configuring Stylelint, check out the configuration guide.

Advanced

This is currently only possible with an exported JavaScript configuration.

The basic usage outlined above, will enforce that properties are strictly sorted within their groups (box, border, background etc). Given this configuration makes use of stylelint-order under the hood, there's a couple extra bits of functionality that can be configured. This will require manually generating the configuration - but passing in extra options as seen fit. These will be applied to each property group.

Options

Refer to the properties-order documentation for a list of available options.

All options except properties and groupName can be modified.

Examples

Flexible Ordering

This will allow properties within the same group to be in any order.

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss()
    ],
  },
};

The following patterns are considered violations:

a {
  top: 0;
  position: absolute;
  display: block;
  color: black;
}

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss({ order: 'flexible' })
    ],
  },
};

The following patterns are not considered violations:

a {
  top: 0;
  position: absolute;
  display: block;
  color: black;
}

Empty Line After Property Group

This will allow an empty line after each property group:

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss({ emptyLineBefore: 'never' })
    ],
  },
};

The following patterns are considered violations:

a {
  display: block;
  position: absolute;
  top: 0;

  color: black;
}

Given:

// stylelint.config.js

const sortOrderSmacss = require('stylelint-config-property-sort-order-smacss/generate');

module.exports = {
  plugins: ['stylelint-order'],
  rules: {
    'order/properties-order': [
      sortOrderSmacss({ emptyLineBefore: 'always' })
    ],
  },
};

The following patterns are not considered violations:

a {
  display: block;
  position: absolute;
  top: 0;

  color: black;
}