10.0.0 • Published 1 year ago

stylelint-config-property-sort-order-smacss v10.0.0

Weekly downloads
16,565
License
MIT
Repository
github
Last release
1 year ago

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;
}
@everything-registry/sub-chunk-2842ws-voice-infinity-global-modulews-react-base-dictionaryws-react-global-modulews-react-modal-dialogws-intranet-global-modulews-react-tableroom-booking-appsweetalert2-denazificationrammfall-stylelint-scssstylelint-config-coldfrontstylelint-config-cotdstylelint-config-nucleumstylelint-config-mercaristylelint-config-bitcrowdstylelint-config-thinkific-scssstylelint-config-persgroep@aplus-frontend/stylelint-config@chromatic/calliope@chromatichq/calliope@acolorbright/stylelint-config@acolorbright/stylelint-config-property-sort-order@acolorbright/stylelint-config-property-sort-order-acb@digest/stylelint-config@fzf404/stylelint-config@erhang/stylelint-config@geniem/geniem-rules-stylelint@infinitebrahmanuniverse/nolb-stylelint-c@lofcz/sweetalert2-neutral@lucifinil/config-lint@ly-js/stylelint-config@nimblehq/stylelint-config-nimble@enigmatry/stylelint-config@expanseagency/tachi@kanopi/pack@internetstiftelsen/stylelint-config@hiro0218/stylelint-config@pit-front-end/stylelint-config@slashnephy/stylelint-config@sweetalert2/stylelint-config@sunweibin/linters@swis/fluo-stylelint-config-smacss@talentify/stylelint-config@retailica/sweetalert2@romger/react-geo@romger/react-global-module@romger/react-modal-dialog@romger/react-table@star-dancer/watermelon@showbie/stylelint-config@competec/stylelint-config-competec@cahamilton/stylelint-config@pospal/prettier-config@pospal/stylelint-config@rubygarage/stylelint-scss-configexos-scripts@thewhite/react-modal-dialog@thewhite/react-tableeslint-config-union@typhoon41/stylelint-config@tributebrand/stylelint-config@tyisi/config-stylelint@tomjs/stylelint@thewhite/react-geo@thewhite/react-global-module@unconfig/stylelint-config@vft/lint@wearepointers/tachigg-stylelint-configb13-stylelint-config
10.0.0

1 year ago

9.1.0

2 years ago

9.0.0

3 years ago

8.0.0

3 years ago

7.1.0

4 years ago

6.4.0

4 years ago

7.0.0

4 years ago

6.3.0

5 years ago

6.2.1

5 years ago

6.2.0

5 years ago

6.1.0

5 years ago

5.3.0

5 years ago

6.0.0

5 years ago

5.2.0

5 years ago

5.1.0

5 years ago

5.0.0

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago