stylelint-order 3.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +28 -24
- package/index.js +1 -1
- package/package.json +28 -25
- package/rules/order/README.md +211 -157
- package/rules/order/checkNode.js +92 -31
- package/rules/order/checkOrder.js +33 -26
- package/rules/order/{createExpectedOrder.js → createOrderInfo.js} +26 -24
- package/rules/order/getDescription.js +4 -1
- package/rules/order/getOrderData.js +7 -7
- package/rules/order/index.js +28 -49
- package/rules/order/messages.js +6 -0
- package/rules/order/ruleName.js +3 -0
- package/rules/order/validatePrimaryOption.js +20 -16
- package/rules/properties-alphabetical-order/README.md +23 -4
- package/rules/properties-alphabetical-order/checkNode.js +63 -0
- package/rules/properties-alphabetical-order/index.js +20 -80
- package/rules/properties-order/README.md +345 -110
- package/rules/properties-order/checkEmptyLineBefore.js +72 -45
- package/rules/properties-order/checkEmptyLineBeforeFirstProp.js +39 -0
- package/rules/properties-order/checkNodeForEmptyLines.js +68 -0
- package/rules/properties-order/checkNodeForOrder.js +101 -0
- package/rules/properties-order/checkOrder.js +22 -12
- package/rules/properties-order/createFlatOrder.js +1 -1
- package/rules/properties-order/{createExpectedOrder.js → createOrderInfo.js} +5 -5
- package/rules/properties-order/getNodeData.js +15 -14
- package/rules/properties-order/index.js +41 -42
- package/rules/properties-order/messages.js +11 -0
- package/rules/properties-order/ruleName.js +3 -0
- package/rules/properties-order/validatePrimaryOption.js +6 -6
- package/utils/getContainingNode.js +1 -1
- package/utils/isCustomProperty.js +1 -1
- package/utils/isDollarVariable.js +1 -1
- package/utils/isStandardSyntaxProperty.js +2 -2
- package/rules/properties-order/checkNode.js +0 -133
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
# Change Log
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
4
5
|
|
|
6
|
+
## 4.1.0
|
|
7
|
+
|
|
8
|
+
* Added `name` option to extended rule object to improve error messaging (for `order`).
|
|
9
|
+
* Fixed `order` not reporting warnings, if autofix didn't fix them.
|
|
10
|
+
|
|
11
|
+
## 4.0.0
|
|
12
|
+
|
|
13
|
+
* Breaking change: Dropped Node.js 8 support. Node.js 10 or greater is now required.
|
|
14
|
+
* Breaking change: Always remove empty line before the first property if this property has any `emptyLineBefore*` option targeting it in `properties-order`. Even if option set to `always` empty line before the first property will be removed.
|
|
15
|
+
* Fixed false positives for `emptyLineBeforeUnspecified`.
|
|
16
|
+
|
|
17
|
+
## 3.1.1
|
|
18
|
+
|
|
19
|
+
* Added `stylelint@11` as a peer dependency.
|
|
20
|
+
|
|
21
|
+
## 3.1.0
|
|
22
|
+
|
|
23
|
+
* Added `emptyLineBefore: "threshold"` option, and related options (`emptyLineMinimumPropertyThreshold`, `emptyLineBeforeUnspecified: "threshold"`) to `properties-order`.
|
|
24
|
+
|
|
5
25
|
## 3.0.1
|
|
6
26
|
|
|
7
27
|
* Fixed `properties-order` not report warnings, if autofix didn't fix them.
|
package/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
# stylelint-order
|
|
1
|
+
# stylelint-order
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![npm version][npm-version-img]][npm] [![npm downloads last month][npm-downloads-img]][npm]
|
|
4
|
+
|
|
5
|
+
A plugin pack of order-related linting rules for [stylelint]. Every rule supports autofixing (`stylelint --fix`).
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
1. If you haven't, install [stylelint]:
|
|
8
10
|
|
|
9
11
|
```
|
|
10
12
|
npm install stylelint --save-dev
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
2. Install `stylelint-order`:
|
|
14
16
|
|
|
15
17
|
```
|
|
16
18
|
npm install stylelint-order --save-dev
|
|
@@ -18,29 +20,27 @@ npm install stylelint-order --save-dev
|
|
|
18
20
|
|
|
19
21
|
## Usage
|
|
20
22
|
|
|
21
|
-
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`.
|
|
22
|
-
|
|
23
|
-
Like so:
|
|
23
|
+
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`.
|
|
24
24
|
|
|
25
|
-
```
|
|
26
|
-
// .stylelintrc
|
|
25
|
+
```json
|
|
27
26
|
{
|
|
28
27
|
"plugins": [
|
|
29
28
|
"stylelint-order"
|
|
30
29
|
],
|
|
31
30
|
"rules": {
|
|
32
|
-
// ...
|
|
33
31
|
"order/order": [
|
|
34
32
|
"custom-properties",
|
|
35
33
|
"declarations"
|
|
36
34
|
],
|
|
37
|
-
"order/properties-
|
|
38
|
-
|
|
35
|
+
"order/properties-order": [
|
|
36
|
+
"width",
|
|
37
|
+
"height"
|
|
38
|
+
]
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## Rules
|
|
44
44
|
|
|
45
45
|
* [`order`](./rules/order/README.md): Specify the order of content within declaration blocks.
|
|
46
46
|
* [`properties-order`](./rules/properties-order/README.md): Specify the order of properties within declaration blocks.
|
|
@@ -48,16 +48,15 @@ Like so:
|
|
|
48
48
|
|
|
49
49
|
## Autofixing
|
|
50
50
|
|
|
51
|
-
Every rule
|
|
51
|
+
Every rule supports autofixing with `stylelint --fix`. [postcss-sorting] is used internally for order autofixing.
|
|
52
52
|
|
|
53
|
-
Automatic
|
|
53
|
+
Automatic sorting has some limitations that are described for every rule, if any. Please, take a look at [how comments are handled](https://github.com/hudochenkov/postcss-sorting#handling-comments) by `postcss-sorting`.
|
|
54
54
|
|
|
55
|
-
CSS-in-JS styles with template interpolation [could be ignored by autofixing](https://github.com/hudochenkov/postcss-sorting#css-in-js) to avoid
|
|
55
|
+
CSS-in-JS styles with template interpolation [could be ignored by autofixing](https://github.com/hudochenkov/postcss-sorting#css-in-js) to avoid style corruption.
|
|
56
56
|
|
|
57
|
-
Autofixing is enabled by default if it's enabled in stylelint configuration.
|
|
57
|
+
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:
|
|
58
58
|
|
|
59
59
|
```json
|
|
60
|
-
{
|
|
61
60
|
"rules": {
|
|
62
61
|
"order/order": [
|
|
63
62
|
[
|
|
@@ -69,20 +68,25 @@ Autofixing is enabled by default if it's enabled in stylelint configuration. Aut
|
|
|
69
68
|
}
|
|
70
69
|
]
|
|
71
70
|
}
|
|
72
|
-
}
|
|
73
71
|
```
|
|
74
72
|
|
|
75
|
-
Less
|
|
73
|
+
Less may work but isn't officially supported.
|
|
74
|
+
|
|
75
|
+
## Example configs
|
|
76
|
+
|
|
77
|
+
All these configs have `properties-order` configured with logical properties groups:
|
|
78
|
+
|
|
79
|
+
* [`stylelint-config-idiomatic-order`](https://github.com/ream88/stylelint-config-idiomatic-order)
|
|
80
|
+
* [`stylelint-config-hudochenkov/order`](https://github.com/hudochenkov/stylelint-config-hudochenkov/blob/master/order.js)
|
|
81
|
+
* [`stylelint-config-recess-order`](https://github.com/stormwarning/stylelint-config-recess-order)
|
|
82
|
+
* [`stylelint-config-property-sort-order-smacss`](https://github.com/cahamilton/stylelint-config-property-sort-order-smacss)
|
|
76
83
|
|
|
77
84
|
## Thanks
|
|
78
85
|
|
|
79
|
-
`properties-order` and `properties-alphabetical-order` code and
|
|
86
|
+
`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.
|
|
80
87
|
|
|
81
|
-
[ci-img]: https://travis-ci.org/hudochenkov/stylelint-order.svg
|
|
82
|
-
[ci]: https://travis-ci.org/hudochenkov/stylelint-order
|
|
83
88
|
[npm-version-img]: https://img.shields.io/npm/v/stylelint-order.svg
|
|
84
89
|
[npm-downloads-img]: https://img.shields.io/npm/dm/stylelint-order.svg
|
|
85
90
|
[npm]: https://www.npmjs.com/package/stylelint-order
|
|
86
|
-
|
|
87
91
|
[stylelint]: https://stylelint.io/
|
|
88
92
|
[postcss-sorting]: https://github.com/hudochenkov/postcss-sorting
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const { createPlugin } = require('stylelint');
|
|
|
2
2
|
const { namespace } = require('./utils');
|
|
3
3
|
const rules = require('./rules');
|
|
4
4
|
|
|
5
|
-
const rulesPlugins = Object.keys(rules).map(ruleName => {
|
|
5
|
+
const rulesPlugins = Object.keys(rules).map((ruleName) => {
|
|
6
6
|
return createPlugin(namespace(ruleName), rules[ruleName]);
|
|
7
7
|
});
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-order",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "A collection of order related linting rules for stylelint.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stylelint-plugin",
|
|
@@ -12,13 +12,6 @@
|
|
|
12
12
|
"author": "Aleks Hudochenkov <aleks@hudochenkov.com>",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": "hudochenkov/stylelint-order",
|
|
15
|
-
"bugs": {
|
|
16
|
-
"url": "https://github.com/hudochenkov/stylelint-order/issues"
|
|
17
|
-
},
|
|
18
|
-
"homepage": "https://github.com/hudochenkov/stylelint-order",
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=8.7.0"
|
|
21
|
-
},
|
|
22
15
|
"files": [
|
|
23
16
|
"rules",
|
|
24
17
|
"utils",
|
|
@@ -28,42 +21,51 @@
|
|
|
28
21
|
],
|
|
29
22
|
"main": "index.js",
|
|
30
23
|
"dependencies": {
|
|
31
|
-
"lodash": "^4.17.
|
|
32
|
-
"postcss": "^7.0.
|
|
24
|
+
"lodash": "^4.17.15",
|
|
25
|
+
"postcss": "^7.0.31",
|
|
33
26
|
"postcss-sorting": "^5.0.1"
|
|
34
27
|
},
|
|
35
28
|
"peerDependencies": {
|
|
36
|
-
"stylelint": "^10.0.1"
|
|
29
|
+
"stylelint": "^10.0.1 || ^11.0.0 || ^12.0.0 || ^13.0.0"
|
|
37
30
|
},
|
|
38
31
|
"devDependencies": {
|
|
39
|
-
"eslint": "^6.0
|
|
40
|
-
"eslint-config-hudochenkov": "^
|
|
41
|
-
"eslint-config-prettier": "^6.
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"stylelint": "^
|
|
32
|
+
"eslint": "^6.8.0",
|
|
33
|
+
"eslint-config-hudochenkov": "^5.0.3",
|
|
34
|
+
"eslint-config-prettier": "^6.11.0",
|
|
35
|
+
"eslint-plugin-import": "^2.20.2",
|
|
36
|
+
"eslint-plugin-unicorn": "^18.0.1",
|
|
37
|
+
"husky": "^4.2.5",
|
|
38
|
+
"jest": "^26.0.1",
|
|
39
|
+
"jest-preset-stylelint": "^3.0.0",
|
|
40
|
+
"jest-watch-typeahead": "^0.6.0",
|
|
41
|
+
"lint-staged": "^10.2.7",
|
|
42
|
+
"prettier": "~2.0.5",
|
|
43
|
+
"prettier-config-hudochenkov": "^0.2.0",
|
|
44
|
+
"stylelint": "^13.5.0"
|
|
47
45
|
},
|
|
48
46
|
"scripts": {
|
|
49
|
-
"pretest": "eslint .",
|
|
47
|
+
"pretest": "eslint . --max-warnings=0 && prettier '**/*.js' --check",
|
|
50
48
|
"test": "jest",
|
|
51
49
|
"jest": "jest",
|
|
52
50
|
"watch": "jest --watch",
|
|
53
51
|
"coverage": "jest --coverage",
|
|
54
|
-
"fix": "eslint . --fix && prettier '**/*.js' --write"
|
|
52
|
+
"fix": "eslint . --fix --max-warnings=0 && prettier '**/*.js' --write"
|
|
55
53
|
},
|
|
56
54
|
"lint-staged": {
|
|
57
55
|
"*.js": [
|
|
58
|
-
"eslint --fix",
|
|
59
|
-
"prettier --write"
|
|
60
|
-
"git add"
|
|
56
|
+
"eslint --fix --max-warnings=0",
|
|
57
|
+
"prettier --write"
|
|
61
58
|
]
|
|
62
59
|
},
|
|
63
60
|
"jest": {
|
|
61
|
+
"preset": "jest-preset-stylelint",
|
|
64
62
|
"setupFiles": [
|
|
65
63
|
"./jest-setup.js"
|
|
66
64
|
],
|
|
65
|
+
"watchPlugins": [
|
|
66
|
+
"jest-watch-typeahead/filename",
|
|
67
|
+
"jest-watch-typeahead/testname"
|
|
68
|
+
],
|
|
67
69
|
"testEnvironment": "node",
|
|
68
70
|
"testRegex": ".*\\.test\\.js$|rules/.*/tests/.*\\.js$"
|
|
69
71
|
},
|
|
@@ -71,5 +73,6 @@
|
|
|
71
73
|
"hooks": {
|
|
72
74
|
"pre-commit": "lint-staged"
|
|
73
75
|
}
|
|
74
|
-
}
|
|
76
|
+
},
|
|
77
|
+
"prettier": "prettier-config-hudochenkov"
|
|
75
78
|
}
|