You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/variable-for-property.md
+95Lines changed: 95 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,10 @@ The `!important` flag will also be excluded when used.
14
14
15
15
*`properties`: `[array of property names]` (defaults to empty array `[]`)
16
16
17
+
*`allow-map-get`: `true`/`false` (defaults to `true`) You may allow/disallow the use of `map-get()` as property values
18
+
19
+
*`allowed-functions`: `[array of function names]` (defaults to empty array `[]`)
20
+
17
21
You may pass an array of properties you wish to enforce the use of variables for
18
22
19
23
```yaml
@@ -26,10 +30,54 @@ variable-for-property:
26
30
- 'content'
27
31
```
28
32
33
+
You may pass an array of function names you wish to allow as property values
34
+
35
+
```yaml
36
+
37
+
variable-for-property:
38
+
- 1
39
+
-
40
+
'allowed-functions':
41
+
- 'my-map-func'
42
+
- 'palette'
43
+
```
44
+
45
+
*** full config example ***
46
+
47
+
```yaml
48
+
variable-for-property:
49
+
- 1
50
+
-
51
+
allow-map-get: true
52
+
allowed-functions:
53
+
- my-map-func
54
+
- palette
55
+
properties:
56
+
- margin
57
+
- content
58
+
```
59
+
29
60
## Examples
30
61
31
62
By default `properties` is an empty array and therefore no properties are forced to use variables as values.
32
63
64
+
```scss
65
+
.bar {
66
+
content: ' ';
67
+
margin: 0;
68
+
69
+
&__element {
70
+
margin: 0;
71
+
}
72
+
}
73
+
74
+
@mixin red() {
75
+
margin: 0;
76
+
}
77
+
```
78
+
79
+
## [properties: []]
80
+
33
81
When `properties` contains the values shown in the options section example the following would be disallowed:
34
82
35
83
```scss
@@ -65,6 +113,53 @@ When `properties` contains the values shown in the options section example the f
65
113
66
114
```
67
115
116
+
## [allow-map-get: true]
117
+
118
+
When allow-map-get is set to `true` and properties contains the `color` property, the following would be allowed
119
+
120
+
```scss
121
+
.foo {
122
+
color: map-get(blueish, light);
123
+
}
124
+
```
125
+
126
+
When allow-map-get is set to `false` and properties contains the `color` property, the following would be disallowed
127
+
128
+
```scss
129
+
.foo {
130
+
color: map-get(blueish, light);
131
+
}
132
+
```
133
+
134
+
## [allowed-functions: []]
135
+
136
+
When `allowed-functions` contains the values shown in the options section and `properties` includes the `color` property the following would be disallowed:
137
+
138
+
```scss
139
+
.foo {
140
+
color: disallowed-function($test, $vars);
141
+
142
+
&__element {
143
+
color: invalid-func-name($test, $vars);
144
+
}
145
+
}
146
+
```
147
+
148
+
When `allowed-functions` contains the values shown in the options section and `properties` includes the `color` property the following would be disallowed:
149
+
150
+
```scss
151
+
.foo {
152
+
color: my-map-func($allowed);
153
+
154
+
&__element {
155
+
color: palette(blue, light);
156
+
}
157
+
}
158
+
159
+
```
160
+
161
+
## Extra info
162
+
68
163
The `!important` flag will be excluded from any lint warnings.
69
164
70
165
For example if `properties` contains the value `color` the following would be disallowed
0 commit comments