Skip to content

Commit f60b333

Browse files
committed
Enforce ordering of declaration blocks with stylelint-order
1 parent 2d3dfd4 commit f60b333

File tree

5 files changed

+43
-15
lines changed

5 files changed

+43
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Unreleased
8+
9+
### Features
10+
11+
- Enforce ordering of declaration blocks with [stylelint-order](https://github.com/hudochenkov/stylelint-order).
12+
713
## [0.1.0](https://github.com/torchbox/stylelint-config-torchbox/releases/tag/v0.1.0) (YYYY-MM-DD)
814

915
First release

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ To get the most out of this config, it is assumed that projects have the followi
3838
> See [`config.js`](./config.js) for the config definition. This package depends on:
3939
>
4040
> - [`stylelint-scss`](https://github.com/kristerkari/stylelint-scss)
41+
> - [`stylelint-order`](https://github.com/hudochenkov/stylelint-order)
4142
> - [`stylelint-config-standard`](https://github.com/stylelint/stylelint-config-standard)
4243
> - [`stylelint-config-prettier`](https://github.com/prettier/stylelint-config-prettier)
4344
@@ -67,6 +68,7 @@ To get the most out of this config, it is assumed that projects have the followi
6768
- [`scss/dollar-variable-no-missing-interpolation`](https://github.com/kristerkari/stylelint-scss#readme)
6869
- [`scss/at-mixin-argumentless-call-parentheses`](https://github.com/kristerkari/stylelint-scss#readme): `always`
6970
- [`scss/media-feature-value-dollar-variable`](https://github.com/kristerkari/stylelint-scss#readme): `always`
71+
- [`order/order`](https://github.com/hudochenkov/stylelint-order): `dollar-variables, custom-properties, type: at-rule, hasBlock: false, declarations, rules, type: at-rule, hasBlock: true`
7072

7173
#### Rules of `stylelint-config-standard`
7274

config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// See https://stylelint.io/user-guide/rules/.
44
module.exports = {
55
extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
6-
plugins: ['stylelint-scss'],
6+
plugins: ['stylelint-scss', 'stylelint-order'],
77
rules: {
88
'color-named': 'never',
99
'declaration-block-no-shorthand-property-overrides': true,
@@ -28,5 +28,15 @@ module.exports = {
2828
'scss/dollar-variable-no-missing-interpolation': true,
2929
'scss/at-mixin-argumentless-call-parentheses': 'always',
3030
'scss/media-feature-value-dollar-variable': 'always',
31+
'order/order': [
32+
'dollar-variables',
33+
'custom-properties',
34+
// @-rules that have no nesting.
35+
{ type: 'at-rule', hasBlock: false },
36+
'declarations',
37+
'rules',
38+
// @-rules that have nested elements, e.g. media queries
39+
{ type: 'at-rule', hasBlock: true },
40+
],
3141
},
3242
};

package-lock.json

Lines changed: 23 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"dependencies": {
3636
"stylelint-config-prettier": "^5.2.0",
3737
"stylelint-config-standard": "^18.3.0",
38+
"stylelint-order": "^3.1.1",
3839
"stylelint-scss": "^3.10.0"
3940
},
4041
"peerDependencies": {

0 commit comments

Comments
 (0)