stylelint-plugin-logical-css 0.11.0 → 0.13.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/README.md +18 -10
- package/package.json +1 -1
- package/src/rules/use-logical-properties-and-values/index.js +1 -1
- package/src/rules/use-logical-units/index.js +2 -1
- package/src/utils/isPhysicalUnit.js +1 -1
- package/src/utils/logical.js +2 -0
- package/src/utils/physical.js +2 -0
- package/src/utils/physicalUnitsMap.js +2 -0
package/README.md
CHANGED
|
@@ -65,10 +65,12 @@ physical property or value is found, it will be flagged.
|
|
|
65
65
|
|
|
66
66
|
#### Options
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
|
68
|
+
> Note: As of v0.13.0, the original `disable-auto-fix` option has been removed.
|
|
69
|
+
> PLease use Stylelint's `disableFix` option instead.
|
|
70
|
+
|
|
71
|
+
| Option | Description |
|
|
72
|
+
| ------ | ------------------------------------------------------------- |
|
|
73
|
+
| ignore | Pass an array of physical properties to ignore while linting. |
|
|
72
74
|
|
|
73
75
|
```json
|
|
74
76
|
{
|
|
@@ -77,7 +79,6 @@ physical property or value is found, it will be flagged.
|
|
|
77
79
|
true,
|
|
78
80
|
{
|
|
79
81
|
"severity": "warning",
|
|
80
|
-
"disable-auto-fix": true,
|
|
81
82
|
"ignore": ["overflow-y", "overflow-x"]
|
|
82
83
|
}
|
|
83
84
|
]
|
|
@@ -93,6 +94,8 @@ physical property or value is found, it will be flagged.
|
|
|
93
94
|
.heading {
|
|
94
95
|
max-width: 90ch; /* Will flag the use of "width" */
|
|
95
96
|
text-align: left; /* Will flag the use of "left" */
|
|
97
|
+
opacity: 1;
|
|
98
|
+
transition: opacity 1s ease, max-width 1s ease; /* Will flag the use of 'max-width' */
|
|
96
99
|
}
|
|
97
100
|
```
|
|
98
101
|
|
|
@@ -102,6 +105,8 @@ physical property or value is found, it will be flagged.
|
|
|
102
105
|
.heading {
|
|
103
106
|
max-inline-size: 90ch;
|
|
104
107
|
text-align: start;
|
|
108
|
+
opacity: 1;
|
|
109
|
+
transition: opacity 1s ease, max-inline-size: 1s ease;
|
|
105
110
|
}
|
|
106
111
|
```
|
|
107
112
|
|
|
@@ -236,10 +241,12 @@ directions. Instead, this rule will enforce the logical equivalents, `vi` and
|
|
|
236
241
|
|
|
237
242
|
#### Options
|
|
238
243
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
|
244
|
+
> Note: As of v0.13.0, the original `disable-auto-fix` option has been removed.
|
|
245
|
+
> PLease use Stylelint's `disableFix` option instead.
|
|
246
|
+
|
|
247
|
+
| Option | Description |
|
|
248
|
+
| ------ | -------------------------------------------------------- |
|
|
249
|
+
| ignore | Pass an array of physical units to ignore while linting. |
|
|
243
250
|
|
|
244
251
|
```json
|
|
245
252
|
{
|
|
@@ -248,7 +255,6 @@ directions. Instead, this rule will enforce the logical equivalents, `vi` and
|
|
|
248
255
|
true,
|
|
249
256
|
{
|
|
250
257
|
"severity": "warning",
|
|
251
|
-
"disable-auto-fix": true,
|
|
252
258
|
"ignore": ["dvh", "dvw"]
|
|
253
259
|
}
|
|
254
260
|
]
|
|
@@ -281,6 +287,8 @@ body {
|
|
|
281
287
|
|
|
282
288
|
| Physical Unit | Logical Unit |
|
|
283
289
|
| ------------- | ------------- |
|
|
290
|
+
| cqh | cqb |
|
|
291
|
+
| cqw | cqi |
|
|
284
292
|
| dvh | dvb |
|
|
285
293
|
| dvw | dvi |
|
|
286
294
|
| lvh | lvb |
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ const { getValueUnit, isPhysicalUnit } = require('../../utils/isPhysicalUnit');
|
|
|
7
7
|
const { physicalUnitsMap } = require('../../utils/physicalUnitsMap');
|
|
8
8
|
|
|
9
9
|
const ruleFunction = (_, options, context) => {
|
|
10
|
+
console.log({ options, context });
|
|
10
11
|
return (root, result) => {
|
|
11
12
|
const validOptions = stylelint.utils.validateOptions(result, ruleName);
|
|
12
13
|
|
|
@@ -33,7 +34,7 @@ const ruleFunction = (_, options, context) => {
|
|
|
33
34
|
physicalUnitsMap[physicalUnit],
|
|
34
35
|
);
|
|
35
36
|
|
|
36
|
-
if (context.fix
|
|
37
|
+
if (context.fix) {
|
|
37
38
|
decl.value = decl.value.replace(
|
|
38
39
|
physicalUnit,
|
|
39
40
|
physicalUnitsMap[physicalUnit],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { physicalUnits } = require('./physical');
|
|
2
2
|
|
|
3
|
-
const expression = /(\d+\s?)(dvh|dvw|lvh|lvw|svh|svw|vh|vw|)(\s+|$)/;
|
|
3
|
+
const expression = /(\d+\s?)(cqh|cqw|dvh|dvw|lvh|lvw|svh|svw|vh|vw|)(\s+|$)/;
|
|
4
4
|
|
|
5
5
|
function getValueUnit(value) {
|
|
6
6
|
const match = value.match(expression);
|
package/src/utils/logical.js
CHANGED
package/src/utils/physical.js
CHANGED
|
@@ -2,6 +2,8 @@ const { logicalUnits } = require('./logical');
|
|
|
2
2
|
const { physicalUnits } = require('./physical');
|
|
3
3
|
|
|
4
4
|
const physicalUnitsMap = Object.freeze({
|
|
5
|
+
[physicalUnits.cqh]: logicalUnits.cqb,
|
|
6
|
+
[physicalUnits.cqw]: logicalUnits.cqi,
|
|
5
7
|
[physicalUnits.dvh]: logicalUnits.dvb,
|
|
6
8
|
[physicalUnits.dvw]: logicalUnits.dvi,
|
|
7
9
|
[physicalUnits.lvh]: logicalUnits.lvb,
|