lix-website/themes/lix/assets/bootstrap/node_modules/stylelint-order
2024-04-26 22:49:34 -06:00
..
node_modules initial commit of template 2024-04-26 22:49:34 -06:00
rules initial commit of template 2024-04-26 22:49:34 -06:00
utils initial commit of template 2024-04-26 22:49:34 -06:00
CHANGELOG.md initial commit of template 2024-04-26 22:49:34 -06:00
index.js initial commit of template 2024-04-26 22:49:34 -06:00
LICENSE.md initial commit of template 2024-04-26 22:49:34 -06:00
package.json initial commit of template 2024-04-26 22:49:34 -06:00
README.md initial commit of template 2024-04-26 22:49:34 -06:00

stylelint-order

npm version npm downloads last month

A plugin pack of order-related linting rules for stylelint. Every rule supports autofixing (stylelint --fix).

Installation

  1. If you haven't, install stylelint:
npm install stylelint --save-dev
  1. Install stylelint-order:
npm install stylelint-order --save-dev

Usage

Add stylelint-order to your stylelint config plugins array, then add rules you need to the rules list. All rules from stylelint-order need to be namespaced with order.

{
	"plugins": [
		"stylelint-order"
	],
	"rules": {
		"order/order": [
			"custom-properties",
			"declarations"
		],
		"order/properties-order": [
			"width",
			"height"
		]
	}
}

Rules

Autofixing

Every rule supports autofixing with stylelint --fix. postcss-sorting is used internally for order autofixing.

Automatic sorting has some limitations that are described for every rule, if any. Please, take a look at how comments are handled by postcss-sorting.

CSS-in-JS styles with template interpolation could be ignored by autofixing to avoid style corruption.

Autofixing is enabled by default if it's enabled in stylelint's configuration file. It can be disabled on a per rule basis using the secondary option disableFix: true. Here's an example:

	"rules": {
		"order/order": [
			[
				"custom-properties",
				"declarations"
			],
			{
				"disableFix": true
			}
		]
	}

Less may work but isn't officially supported.

Example configs

All these configs have properties-order configured with logical properties groups:

Thanks

properties-order and properties-alphabetical-order code and README were based on the declaration-block-properties-order rule which was a core rule prior to stylelint 8.0.0.