stylelint-plugin-logical-css 0.2.0 → 0.3.1
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🛸 Stylelint Plugin Logical CSS
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
@@ -24,8 +24,8 @@ npm i stylelint-plugin-logical-css --save-dev
|
|
|
24
24
|
yarn add stylelint-plugin-logical-css --dev
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
With the plugin installed, the rule(s) can
|
|
28
|
-
|
|
27
|
+
With the plugin installed, the rule(s) can be added to the project's Stylelint
|
|
28
|
+
configuration.
|
|
29
29
|
|
|
30
30
|
```json
|
|
31
31
|
{
|
|
@@ -46,19 +46,19 @@ Let's explore each rule to better understand what it does, and does not, allow.
|
|
|
46
46
|
|
|
47
47
|
### `plugin/use-logical-properties-and-values`
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
**👉 [Learn more about this rule](./src/rules/use-logical-properties-and-values)
|
|
50
|
+
👈**
|
|
51
51
|
|
|
52
52
|
This rule is responsible for checking both CSS properties and values. When a
|
|
53
53
|
physical property or value is found, it will be flagged.
|
|
54
54
|
|
|
55
55
|
#### Options
|
|
56
56
|
|
|
57
|
-
The
|
|
57
|
+
The use-logical-properties-and-values rule accepts the following options:
|
|
58
58
|
|
|
59
|
-
| Option
|
|
60
|
-
|
|
|
61
|
-
|
|
|
59
|
+
| Option | Description |
|
|
60
|
+
| --------------- | ----------------------------------------------------------------------------------------------- |
|
|
61
|
+
| enable-auto-fix | Use this option in addition to the native Stylelint `--fix` flag to enable auto fixing on save. |
|
|
62
62
|
|
|
63
63
|
```json
|
|
64
64
|
{
|
|
@@ -91,13 +91,11 @@ The `use-logical-properties-and-values` rule accepts the following options:
|
|
|
91
91
|
}
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
---
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
> [Learn more about the properties and values supported by this rule](./src/rules/use-logical-units)
|
|
96
|
+
### `plugin/use-logical-units`
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
> [browser support for logical viewport units](https://caniuse.com/mdn-css_types_length_viewport_percentage_units_dynamic).
|
|
98
|
+
**👉 [Learn more about this rule](./src/rules/use-logical-units) 👈**
|
|
101
99
|
|
|
102
100
|
This rule is responsible for checking that logical CSS units are used.
|
|
103
101
|
Specifically, viewport units like `vw` and `vh` which stand for viewport width
|
|
@@ -107,11 +105,11 @@ directions. Instead, this rule will enforce the logical equivalents, `vi` and
|
|
|
107
105
|
|
|
108
106
|
#### Options
|
|
109
107
|
|
|
110
|
-
The
|
|
108
|
+
The use-logical-units rule accepts the following options:
|
|
111
109
|
|
|
112
|
-
| Option
|
|
113
|
-
|
|
|
114
|
-
|
|
|
110
|
+
| Option | Description |
|
|
111
|
+
| --------------- | ----------------------------------------------------------------------------------------------- |
|
|
112
|
+
| enable-auto-fix | Use this option in addition to the native Stylelint `--fix` flag to enable auto fixing on save. |
|
|
115
113
|
|
|
116
114
|
```json
|
|
117
115
|
{
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ const { isPhysicalProperty } = require('../../utils/isPhysicalProperty');
|
|
|
7
7
|
const { isPhysicalValue } = require('../../utils/isPhysicalValue');
|
|
8
8
|
const { physicalPropertiesMap } = require('../../utils/physicalPropertiesMap');
|
|
9
9
|
const { physicalValuesMap } = require('../../utils/physicalValuesMap');
|
|
10
|
+
const { propsToSkip } = require('../../utils/propsToSkip');
|
|
10
11
|
|
|
11
12
|
const ruleFunction = (_, options, context) => {
|
|
12
13
|
return (root, result) => {
|
|
@@ -17,9 +18,14 @@ const ruleFunction = (_, options, context) => {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
root.walkDecls((decl) => {
|
|
21
|
+
if (propsToSkip.includes(decl.prop)) return;
|
|
22
|
+
|
|
20
23
|
const propIsPhysical = isPhysicalProperty(decl.prop);
|
|
21
24
|
const valueIsPhysical = isPhysicalValue(decl.value);
|
|
22
25
|
|
|
26
|
+
if (decl.prop.includes('grid')) {
|
|
27
|
+
console.log({ decl, propIsPhysical, valueIsPhysical });
|
|
28
|
+
}
|
|
23
29
|
if (!propIsPhysical && !valueIsPhysical) return;
|
|
24
30
|
|
|
25
31
|
const message = propIsPhysical
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
The properties included in this array can contain physical values like left and bottom.
|
|
3
|
+
However, logical values for the4se properties are not yet supported. So for the time being,
|
|
4
|
+
we skip linting them entirely.
|
|
5
|
+
*/
|
|
6
|
+
const propsToSkip = [
|
|
7
|
+
'background',
|
|
8
|
+
'background-position',
|
|
9
|
+
'grid-area',
|
|
10
|
+
'grid-template-areas',
|
|
11
|
+
'transform-origin',
|
|
12
|
+
'vertical-align',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
propsToSkip,
|
|
17
|
+
};
|