@alfalab/stylelint-core-vars 0.0.4 → 1.0.0-beta.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,17 +1,19 @@
1
1
  # stylelint-core-vars
2
2
 
3
- [![NPM Version](https://img.shields.io/npm/v/stylelint-core-vars.svg)](https://www.npmjs.com/package/stylelint-core-vars)
3
+ [![NPM Version](https://img.shields.io/npm/v/@alfalab/stylelint-core-vars.svg)](https://www.npmjs.com/package/@alfalab/stylelint-core-vars)
4
4
 
5
5
  [Stylelint](http://stylelint.io) плагин, проверяющий использование [дизайн-токенов](https://github.com/alfa-laboratory/core-components/tree/master/packages/vars/src)
6
6
 
7
7
  ## Установка
8
8
 
9
9
  ```
10
- yarn add --dev stylelint stylelint-core-vars
10
+ yarn add --dev stylelint @alfalab/stylelint-core-vars
11
11
  ```
12
+
12
13
  или
14
+
13
15
  ```
14
- npm install --save-dev stylelint stylelint-core-vars
16
+ npm install --save-dev stylelint @alfalab/stylelint-core-vars
15
17
  ```
16
18
 
17
19
  ## Использование
@@ -24,7 +26,63 @@ npm install --save-dev stylelint stylelint-core-vars
24
26
  "@alfalab/stylelint-core-vars"
25
27
  ],
26
28
  "rules": {
27
- "stylelint-core-vars/use-vars": true
28
- }
29
+ "stylelint-core-vars/use-vars": [
30
+ true,
31
+ {
32
+ "allowNumericValues": true
33
+ }
34
+ ],
35
+ "stylelint-core-vars/use-mixins": true,
36
+ "stylelint-core-vars/use-one-of-vars": [
37
+ true,
38
+ {
39
+ "severity": "warning"
40
+ }
41
+ ],
42
+ "stylelint-core-vars/use-one-of-mixins": [
43
+ true,
44
+ {
45
+ "severity": "warning"
46
+ }
47
+ ],
48
+ "stylelint-core-vars/do-not-use-dark-colors": [
49
+ true,
50
+ {
51
+ "severity": "warning"
52
+ }
53
+ ],
54
+ "stylelint-core-vars/do-not-use-old-vars": [
55
+ true,
56
+ {
57
+ "severity": "warning"
58
+ }
59
+ ],
60
+ },
29
61
  }
30
- ```
62
+ ```
63
+
64
+ ## Лицензия
65
+
66
+ ```
67
+ The MIT License (MIT)
68
+
69
+ Copyright (c) 2024 core-ds contributors
70
+
71
+ Permission is hereby granted, free of charge, to any person obtaining a copy
72
+ of this software and associated documentation files (the "Software"), to deal
73
+ in the Software without restriction, including without limitation the rights
74
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
75
+ copies of the Software, and to permit persons to whom the Software is
76
+ furnished to do so, subject to the following conditions:
77
+
78
+ The above copyright notice and this permission notice shall be included in
79
+ all copies or substantial portions of the Software.
80
+
81
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
84
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
86
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
87
+ THE SOFTWARE.
88
+ ```
package/index.js CHANGED
@@ -1,149 +1 @@
1
- const stylelint = require('stylelint');
2
- const toOneLine = require('./utils').toOneLine;
3
- const formatVar = require('./utils').formatVar;
4
- const findVar = require('./utils').findVar;
5
- const findTypographyMixin = require('./utils').findTypographyMixin;
6
- const VARS_AVAILABLE = require('./utils').VARS_AVAILABLE;
7
-
8
- const ruleName = 'stylelint-core-vars/use-vars';
9
-
10
- const messages = stylelint.utils.ruleMessages(ruleName, {
11
- expectedVar: (variable, value) => {
12
- return `Use variable '${variable}' instead of plain value '${value}'`;
13
- },
14
- expectedVars: (variables, value) => {
15
- const variablesPart = variables.map((v) => ` - ${v}`).join('\n');
16
-
17
- return `Use variables instead of plain value '${value}':\n${variablesPart}\n`;
18
- },
19
- expectedMixin: (mixin) => {
20
- return `Use mixin '${mixin}' instead of plain values`;
21
- },
22
- expectedMixins: (mixins) => {
23
- const mixinsPart = mixins
24
- .map(({ name, props }) => ` - ${name} (${Object.values(props).join('|')})`)
25
- .join('\n');
26
- return `Use mixins instead of plain values:\n${mixinsPart}\n`;
27
- },
28
- });
29
-
30
- const checkVars = (decl, result, context) => {
31
- const { prop, raws } = decl;
32
-
33
- let value = toOneLine(decl.value);
34
-
35
- let substitution;
36
- const previousValues = [];
37
-
38
- while ((substitution = findVar(value, prop))) {
39
- let fixed = false;
40
- const exactVar = Array.isArray(substitution.variable) === false;
41
- const fixedValue = formatVar(exactVar ? substitution.variable : substitution.variable[0]);
42
-
43
- value = value.replace(substitution.value, fixedValue);
44
-
45
- if (context.fix && exactVar) {
46
- decl.value = value;
47
- fixed = true;
48
- }
49
-
50
- const originalValueIndex = previousValues.reduce(
51
- (acc, sub) => (acc > sub.index + sub.diff ? acc - sub.diff : acc),
52
- substitution.index
53
- );
54
-
55
- const messageTemplate = exactVar ? messages.expectedVar : messages.expectedVars;
56
-
57
- if (!fixed && exactVar) {
58
- stylelint.utils.report({
59
- result,
60
- ruleName,
61
- message: messageTemplate(substitution.variable, substitution.value),
62
- node: decl,
63
- word: value,
64
- index: originalValueIndex + prop.length + raws.between.length,
65
- });
66
- }
67
-
68
- previousValues.unshift({
69
- ...substitution,
70
- diff: fixedValue.length - substitution.value.length,
71
- });
72
- }
73
- };
74
-
75
- const checkTypography = (rule, result, context) => {
76
- const typographyProps = rule.nodes.reduce((acc, node) => {
77
- if (['font-size', 'line-height', 'font-weight'].includes(node.prop)) {
78
- acc[node.prop] = node.value;
79
- }
80
- return acc;
81
- }, {});
82
-
83
- const hasTypography = 'font-size' in typographyProps;
84
- if (!hasTypography) return;
85
-
86
- const mixin = findTypographyMixin(typographyProps);
87
-
88
- if (!mixin) return;
89
-
90
- const exactMixin = Array.isArray(mixin) === false;
91
-
92
- let fixed = false;
93
- if (context.fix && exactMixin) {
94
- fixed = true;
95
- const { name, props } = mixin;
96
-
97
- const before = rule.nodes[0].raws.before;
98
- rule.walkDecls((decl) => {
99
- if (decl.prop in props) {
100
- decl.remove();
101
- }
102
- });
103
-
104
- rule.prepend(`${before}@mixin ${name};\n`);
105
- }
106
-
107
- if (!fixed) {
108
- if (exactMixin) {
109
- stylelint.utils.report({
110
- result,
111
- ruleName,
112
- message: messages.expectedMixin(mixin.name),
113
- node: rule,
114
- word: 'font-size',
115
- index: 0,
116
- });
117
- } else {
118
- // stylelint.utils.report({
119
- // result,
120
- // ruleName,
121
- // message: messages.expectedMixins(mixin),
122
- // node: rule,
123
- // word: 'font-size',
124
- // index: 0,
125
- // });
126
- }
127
- }
128
- };
129
-
130
- module.exports = stylelint.createPlugin(ruleName, (enabled, _, context) => {
131
- if (!enabled || !VARS_AVAILABLE) {
132
- return function () {
133
- return;
134
- };
135
- }
136
-
137
- return (root, result) => {
138
- root.walkRules((rule) => {
139
- checkTypography(rule, result, context);
140
-
141
- rule.walkDecls((decl) => {
142
- checkVars(decl, result, context);
143
- });
144
- });
145
- };
146
- });
147
-
148
- module.exports.ruleName = ruleName;
149
- module.exports.messages = messages;
1
+ module.exports = require('./lib');
package/lib/index.js ADDED
@@ -0,0 +1,279 @@
1
+ const stylelint = require('stylelint');
2
+ const { findOldVars } = require('./utils');
3
+ const toOneLine = require('./utils').toOneLine;
4
+ const findVars = require('./utils').findVars;
5
+ const colorsSet = require('./utils').colorsSet;
6
+ const findTypographyMixins = require('./utils').findTypographyMixins;
7
+ const VARS_AVAILABLE = require('./utils').VARS_AVAILABLE;
8
+
9
+ const RULE_USE_VARS = 'stylelint-core-vars/use-vars';
10
+ const RULE_USE_ONE_OF_VARS = 'stylelint-core-vars/use-one-of-vars';
11
+ const RULE_USE_MIXINS = 'stylelint-core-vars/use-mixins';
12
+ const RULE_USE_ONE_OF_MIXINS = 'stylelint-core-vars/use-one-of-mixins';
13
+ const RULE_DO_NOT_USE_DARK_COLORS = 'stylelint-core-vars/do-not-use-dark-colors';
14
+ const RULE_DO_NOT_USE_OLD_VARS = 'stylelint-core-vars/do-not-use-old-vars';
15
+
16
+ const messages = {
17
+ [RULE_USE_VARS]: stylelint.utils.ruleMessages(RULE_USE_VARS, {
18
+ expected: (variable, value) => {
19
+ return `Use variable 'var(${variable})' instead of plain value '${value}'`;
20
+ },
21
+ }),
22
+ [RULE_USE_ONE_OF_VARS]: stylelint.utils.ruleMessages(RULE_USE_ONE_OF_VARS, {
23
+ expected: (variables, value) => {
24
+ const variablesPart = variables.map((v) => `var(${v})`).join('\n');
25
+
26
+ return `Use variables instead of plain value '${value}':\n${variablesPart}\n`;
27
+ },
28
+ }),
29
+ [RULE_DO_NOT_USE_OLD_VARS]: stylelint.utils.ruleMessages(RULE_DO_NOT_USE_OLD_VARS, {
30
+ expected: (variables, value, fixable = true) => {
31
+ if (!variables.length) return `Ask you designer how to replace old token '${value}'`;
32
+
33
+ const startMsg = fixable ? 'Use' : 'Cant find proper token, but you can use';
34
+
35
+ if (variables.length === 1) {
36
+ return `${startMsg} variable 'var(${variables[0]})' instead of old '${value}'`;
37
+ }
38
+
39
+ const variablesPart = variables.map((v) => `var(${v})`).join('\n');
40
+
41
+ return `${startMsg} one of new variables instead of old '${value}':\n${variablesPart}\n`;
42
+ },
43
+ }),
44
+ [RULE_USE_MIXINS]: stylelint.utils.ruleMessages(RULE_USE_MIXINS, {
45
+ expected: (mixin) => {
46
+ return `Use mixin '${mixin.name}' instead of plain values`;
47
+ },
48
+ }),
49
+ [RULE_USE_ONE_OF_MIXINS]: stylelint.utils.ruleMessages(RULE_USE_ONE_OF_MIXINS, {
50
+ expected: (mixins) => {
51
+ const mixinsPart = mixins
52
+ .map(({ name, props }) => `${name} (${Object.values(props).join('|')})`)
53
+ .join('\n');
54
+ return `Use mixins instead of plain values:\n${mixinsPart}\n`;
55
+ },
56
+ }),
57
+ [RULE_DO_NOT_USE_DARK_COLORS]: stylelint.utils.ruleMessages(RULE_DO_NOT_USE_DARK_COLORS, {
58
+ expected: () => {
59
+ return 'Do not use dark colors directly. Only light and static colors are allowed';
60
+ },
61
+ }),
62
+ };
63
+
64
+ const checkVars = (decl, result, context, ruleName, matcher, shouldReport, options = {}) => {
65
+ const { prop, raws } = decl;
66
+
67
+ let value = toOneLine(decl.value);
68
+ let substitution;
69
+
70
+ const previousValues = [];
71
+
72
+ while ((substitution = matcher(value, prop, options))) {
73
+ let fixed = false;
74
+
75
+ value = value.replace(substitution.value, substitution.fixedValue);
76
+
77
+ if (context.fix && substitution.fixable) {
78
+ decl.value = value;
79
+ fixed = true;
80
+ }
81
+
82
+ const originalValueIndex = previousValues.reduce(
83
+ (acc, sub) => (acc > sub.index + sub.diff ? acc - sub.diff : acc),
84
+ substitution.index
85
+ );
86
+
87
+ if (shouldReport(substitution.fixable, fixed)) {
88
+ stylelint.utils.report({
89
+ result,
90
+ ruleName,
91
+ message: messages[ruleName].expected(
92
+ substitution.variables,
93
+ substitution.value,
94
+ substitution.fixable
95
+ ),
96
+ node: decl,
97
+ word: value,
98
+ index: originalValueIndex + prop.length + raws.between.length,
99
+ });
100
+ }
101
+
102
+ previousValues.unshift({
103
+ ...substitution,
104
+ diff: substitution.fixedValue.length - substitution.value.length,
105
+ });
106
+ }
107
+ };
108
+
109
+ const checkTypography = (rule, result, context, ruleName) => {
110
+ const typographyProps = rule.nodes.reduce((acc, node) => {
111
+ if (['font-size', 'line-height', 'font-weight'].includes(node.prop)) {
112
+ acc[node.prop] = node.value;
113
+ }
114
+ return acc;
115
+ }, {});
116
+
117
+ const hasTypography = 'font-size' in typographyProps;
118
+ if (!hasTypography) return;
119
+
120
+ const mixins = findTypographyMixins(typographyProps);
121
+
122
+ if (!mixins || !mixins.length) return;
123
+
124
+ const exactMixin = mixins.length === 1;
125
+
126
+ let fixed = false;
127
+ if (context.fix && exactMixin) {
128
+ fixed = true;
129
+ const { name, props } = mixins[0];
130
+
131
+ const before = rule.nodes[0].raws.before;
132
+ rule.walkDecls((decl) => {
133
+ if (decl.prop in props) {
134
+ decl.remove();
135
+ }
136
+ });
137
+
138
+ rule.prepend(`${before}@mixin ${name};\n`);
139
+ }
140
+
141
+ const shouldReport =
142
+ !fixed &&
143
+ ((ruleName === RULE_USE_ONE_OF_MIXINS && !exactMixin) ||
144
+ (ruleName === RULE_USE_MIXINS && exactMixin));
145
+
146
+ if (shouldReport) {
147
+ stylelint.utils.report({
148
+ result,
149
+ ruleName,
150
+ message: messages[ruleName].expected(mixins),
151
+ node: rule,
152
+ word: 'font-size',
153
+ index: 0,
154
+ });
155
+ }
156
+ };
157
+
158
+ const checkDarkColorsUsage = (decl, result, context, ruleName) => {
159
+ const { prop, raws } = decl;
160
+
161
+ let value = toOneLine(decl.value);
162
+
163
+ const matches = /--color-dark-[\w-]+/.exec(value);
164
+
165
+ if (matches && colorsSet.has(matches[0])) {
166
+ stylelint.utils.report({
167
+ result,
168
+ ruleName: RULE_DO_NOT_USE_DARK_COLORS,
169
+ message: messages[RULE_DO_NOT_USE_DARK_COLORS].expected(),
170
+ node: decl,
171
+ word: value,
172
+ index: prop.length + raws.between.length + decl.value.indexOf(matches[0]),
173
+ });
174
+ }
175
+ };
176
+
177
+ module.exports = [
178
+ stylelint.createPlugin(RULE_USE_VARS, (enabled, config, context) => {
179
+ if (!enabled || !VARS_AVAILABLE) {
180
+ return () => {};
181
+ }
182
+
183
+ const allowNumericValues = config?.allowNumericValues || false;
184
+
185
+ return (root, result) => {
186
+ root.walkDecls((decl) => {
187
+ checkVars(
188
+ decl,
189
+ result,
190
+ context,
191
+ RULE_USE_VARS,
192
+ findVars,
193
+ (fixable, fixed) => fixable && !fixed,
194
+ { allowNumericValues }
195
+ );
196
+ });
197
+ };
198
+ }),
199
+ stylelint.createPlugin(RULE_USE_ONE_OF_VARS, (enabled, config, context) => {
200
+ if (!enabled || !VARS_AVAILABLE) {
201
+ return () => {};
202
+ }
203
+
204
+ const allowNumericValues = config?.allowNumericValues || false;
205
+
206
+ return (root, result) => {
207
+ root.walkDecls((decl) => {
208
+ checkVars(
209
+ decl,
210
+ result,
211
+ context,
212
+ RULE_USE_ONE_OF_VARS,
213
+ findVars,
214
+ (fixable, fixed) => !fixable && !fixed,
215
+ { allowNumericValues }
216
+ );
217
+ });
218
+ };
219
+ }),
220
+ stylelint.createPlugin(RULE_DO_NOT_USE_OLD_VARS, (enabled, _, context) => {
221
+ if (!enabled || !VARS_AVAILABLE) {
222
+ return () => {};
223
+ }
224
+
225
+ return (root, result) => {
226
+ root.walkDecls((decl) => {
227
+ checkVars(
228
+ decl,
229
+ result,
230
+ context,
231
+ RULE_DO_NOT_USE_OLD_VARS,
232
+ findOldVars,
233
+ (_, fixed) => !fixed
234
+ );
235
+ });
236
+ };
237
+ }),
238
+ stylelint.createPlugin(RULE_USE_MIXINS, (enabled, _, context) => {
239
+ if (!enabled || !VARS_AVAILABLE) {
240
+ return () => {};
241
+ }
242
+
243
+ return (root, result) => {
244
+ root.walkRules((rule) => {
245
+ checkTypography(rule, result, context, RULE_USE_MIXINS);
246
+ });
247
+ };
248
+ }),
249
+ stylelint.createPlugin(RULE_USE_ONE_OF_MIXINS, (enabled, _, context) => {
250
+ if (!enabled || !VARS_AVAILABLE) {
251
+ return () => {};
252
+ }
253
+
254
+ return (root, result) => {
255
+ root.walkRules((rule) => {
256
+ checkTypography(rule, result, context, RULE_USE_ONE_OF_MIXINS);
257
+ });
258
+ };
259
+ }),
260
+ stylelint.createPlugin(RULE_DO_NOT_USE_DARK_COLORS, (enabled, _, context) => {
261
+ if (!enabled || !VARS_AVAILABLE) {
262
+ return () => {};
263
+ }
264
+
265
+ return (root, result) => {
266
+ root.walkDecls((decl) => {
267
+ checkDarkColorsUsage(decl, result, context);
268
+ });
269
+ };
270
+ }),
271
+ ];
272
+
273
+ module.exports.messages = messages;
274
+ module.exports.RULE_USE_VARS = RULE_USE_VARS;
275
+ module.exports.RULE_USE_ONE_OF_VARS = RULE_USE_ONE_OF_VARS;
276
+ module.exports.RULE_USE_MIXINS = RULE_USE_MIXINS;
277
+ module.exports.RULE_USE_ONE_OF_MIXINS = RULE_USE_ONE_OF_MIXINS;
278
+ module.exports.RULE_DO_NOT_USE_DARK_COLORS = RULE_DO_NOT_USE_DARK_COLORS;
279
+ module.exports.RULE_DO_NOT_USE_OLD_VARS = RULE_DO_NOT_USE_OLD_VARS;
@@ -0,0 +1,122 @@
1
+ module.exports = {
2
+ '--color-dark-indigo': [
3
+ '--color-light-text-primary',
4
+ '--color-light-bg-primary-inverted',
5
+ '--color-light-border-key',
6
+ '--color-light-graphic-primary',
7
+ ],
8
+ '--color-dark-indigo-60-flat': [
9
+ '--color-light-text-secondary',
10
+ '--color-light-border-tertiary-inverted',
11
+ '--color-light-graphic-secondary',
12
+ ],
13
+ '--color-dark-indigo-30-flat': [
14
+ '--color-light-text-tertiary',
15
+ '--color-light-border-secondary-inverted',
16
+ '--color-light-graphic-tertiary',
17
+ ],
18
+ '--color-dark-indigo-15-flat': [
19
+ '--color-light-text-disabled',
20
+ '--color-light-bg-quaternary',
21
+ '--color-light-border-primary',
22
+ '--color-light-graphic-quaternary',
23
+ ],
24
+ '--color-dark-indigo-10-flat': ['--color-light-bg-tertiary', '--color-light-border-secondary'],
25
+ '--color-dark-indigo-07-flat': ['--color-light-specialbg-component'],
26
+ '--color-dark-indigo-05-flat': [
27
+ '--color-light-bg-secondary',
28
+ '--color-light-border-tertiary',
29
+ '--color-light-graphic-primary-inverted',
30
+ ],
31
+ '--color-red-brand': [
32
+ '--color-light-text-accent',
33
+ '--color-light-bg-accent',
34
+ '--color-light-border-accent',
35
+ '--color-light-graphic-accent',
36
+ ],
37
+ '--color-red-brand-85-flat': [],
38
+ '--color-red-brand-70-flat': [],
39
+ '--color-red-brand-50-flat': [],
40
+ '--color-red-brand-30-flat': [],
41
+ '--color-red-brand-20-flat': [],
42
+ '--color-red-brand-10-flat': ['--color-light-bg-negative-muted'],
43
+ '--color-red-brand-05-flat': ['--color-light-bg-negative-muted'],
44
+ '--color-red-dark': ['--color-light-text-negative', '--color-light-graphic-negative'],
45
+ '--color-red-error': ['--color-light-text-negative', '--color-light-graphic-negative'],
46
+ '--color-green-text': ['--color-light-text-positive'],
47
+ '--color-green-text-60-flat': [],
48
+ '--color-green-done': ['--color-light-graphic-positive'],
49
+ '--color-green-done-20-flat': [],
50
+ '--color-green-done-10-flat': ['--color-light-bg-positive-muted'],
51
+ '--color-green-done-05-flat': ['--color-light-bg-positive-muted'],
52
+ '--color-blue-action': [],
53
+ '--color-blue-swipe-a': [],
54
+ '--color-blue-swipe-b': [],
55
+ '--color-blue-swipe-c': [],
56
+ '--color-blue-link-mobile': [
57
+ '--color-light-text-link',
58
+ '--color-light-graphic-link',
59
+ '--color-light-border-link',
60
+ ],
61
+ '--color-blue-link-mobile-10-flat': ['--color-light-bg-info'],
62
+ '--color-blue-link-web': [
63
+ '--color-light-text-link',
64
+ '--color-light-graphic-link',
65
+ '--color-light-border-link',
66
+ ],
67
+ '--color-sand': ['--color-static-graphic-sand'],
68
+ '--color-lavender': ['--color-static-graphic-lavender'],
69
+ '--color-amethyst': ['--color-static-graphic-amethyst'],
70
+ '--color-black': [],
71
+ '--color-black-60-flat': ['--color-light-bg-overlay'],
72
+ '--color-black-30-flat': [],
73
+ '--color-black-10-flat': [],
74
+ '--color-white': [
75
+ '--color-light-text-primary-inverted',
76
+ '--color-light-bg-primary',
77
+ '--color-light-border-key-inverted',
78
+ ],
79
+ '--color-bg-corporate': ['--color-static-corpbg-primary'],
80
+ '--color-bg-corporate-90-flat': ['--color-static-corpbg-secondary'],
81
+ '--color-bg-corporate-60-flat': ['--color-static-corpbg-tertiary'],
82
+ '--color-bg-corporate-30-flat': ['--color-static-corpbg-neutral'],
83
+ '--color-light-blue': ['--color-static-local-light-blue'],
84
+ '--color-dark-indigo-60': [
85
+ '--color-light-text-secondary-transparent',
86
+ '--color-light-border-tertiary-inverted',
87
+ '--color-light-graphic-secondary',
88
+ ],
89
+ '--color-dark-indigo-30': [
90
+ '--color-light-text-tertiary',
91
+ '--color-light-border-secondary-inverted',
92
+ '--color-light-graphic-tertiary',
93
+ ],
94
+ '--color-dark-indigo-15': ['--color-light-text-disabled'],
95
+ '--color-dark-indigo-10': ['--color-light-bg-tertiary', '--color-light-border-secondary'],
96
+ '--color-dark-indigo-07': ['--color-light-specialbg-component'],
97
+ '--color-dark-indigo-05': [
98
+ '--color-light-bg-secondary',
99
+ '--color-light-border-tertiary',
100
+ '--color-light-graphic-primary-inverted',
101
+ ],
102
+ '--color-red-brand-85': [],
103
+ '--color-red-brand-70': [],
104
+ '--color-red-brand-50': [],
105
+ '--color-red-brand-30': [],
106
+ '--color-red-brand-20': [],
107
+ '--color-red-brand-10': ['--color-light-bg-negative-muted'],
108
+ '--color-green-text-60': [],
109
+ '--color-green-done-20': [],
110
+ '--color-green-done-10': ['--color-light-bg-positive-muted'],
111
+ '--color-green-done-05': ['--color-light-bg-positive-muted'],
112
+ '--color-blue-link-mobile-10': ['--color-light-bg-info'],
113
+ '--color-black-60': ['--color-light-bg-overlay'],
114
+ '--color-black-30': [],
115
+ '--color-black-10': [],
116
+ '--color-white-60': ['--color-light-text-secondary-inverted', '--color-light-bg-opaque'],
117
+ '--color-white-30': ['--color-light-text-tertiary-inverted'],
118
+ '--color-white-10': [],
119
+ '--color-bg-corporate-90': ['--color-static-corpbg-secondary'],
120
+ '--color-bg-corporate-60': ['--color-static-corpbg-tertiary'],
121
+ '--color-bg-corporate-30': ['--color-static-corpbg-neutral'],
122
+ };
@@ -1,7 +1,9 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
+ const oldNewMap = require('./old-new-map');
3
4
 
4
5
  const CORE_COMPONENTS_PACKAGE = '@alfalab/core-components';
6
+ const CORE_COMPONENTS_VARS_PACKAGE = '@alfalab/core-components-vars';
5
7
  const VAR_RE = /(?:^|\n)\s+(--[-\w]+):\s*([\s\S]+?);/gm;
6
8
  const MIXIN_RE = /@define-mixin (.*?) {(.*?)}/g;
7
9
  const BORDERS = {
@@ -15,8 +17,15 @@ const vars = {
15
17
  gaps: loadVars('gaps.css'),
16
18
  shadows: loadVars('shadows-indigo.css'),
17
19
  colors: loadVars('colors-indigo.css'),
20
+ borderRadiuses: loadVars('border-radius.css'),
18
21
  };
19
22
 
23
+ const colorsSet = Object.values(vars.colors).reduce((acc, vars) => {
24
+ vars.forEach((colorVar) => acc.add(colorVar));
25
+
26
+ return acc;
27
+ }, new Set());
28
+
20
29
  const mixins = {
21
30
  typography: loadMixins('typography.css'),
22
31
  };
@@ -34,6 +43,7 @@ const varsByProperties = {
34
43
  'margin-left': vars.gaps,
35
44
  'box-shadow': vars.shadows,
36
45
  color: vars.colors,
46
+ fill: vars.colors,
37
47
  background: vars.colors,
38
48
  'background-color': vars.colors,
39
49
  border: vars.colors,
@@ -41,16 +51,26 @@ const varsByProperties = {
41
51
  'border-right': vars.colors,
42
52
  'border-bottom': vars.colors,
43
53
  'border-left': vars.colors,
54
+ 'border-radius': vars.borderRadiuses,
55
+ 'border-top-left-radius': vars.borderRadiuses,
56
+ 'border-top-right-radius': vars.borderRadiuses,
57
+ 'border-bottom-left-radius': vars.borderRadiuses,
58
+ 'border-bottom-right-radius': vars.borderRadiuses,
44
59
  };
45
60
 
46
- const VARS_AVAILABLE = coreComponentsInstalled() || runInsideCoreComponents();
61
+ const VARS_AVAILABLE = Boolean(getInstalledVarsPackage()) || runInsideCoreComponents();
47
62
 
48
- function coreComponentsInstalled() {
63
+ function getInstalledVarsPackage() {
49
64
  try {
50
65
  require.resolve(`${CORE_COMPONENTS_PACKAGE}/package.json`);
51
- return true;
66
+ return CORE_COMPONENTS_PACKAGE;
52
67
  } catch (e) {
53
- return false;
68
+ try {
69
+ require.resolve(`${CORE_COMPONENTS_VARS_PACKAGE}/package.json`);
70
+ return CORE_COMPONENTS_VARS_PACKAGE;
71
+ } catch (e) {
72
+ return false;
73
+ }
54
74
  }
55
75
  }
56
76
 
@@ -65,8 +85,14 @@ function runInsideCoreComponents() {
65
85
  }
66
86
 
67
87
  function resolveVarsFile(file) {
68
- if (coreComponentsInstalled()) {
69
- return fs.readFileSync(require.resolve(`${CORE_COMPONENTS_PACKAGE}/vars/${file}`));
88
+ const packageName = getInstalledVarsPackage();
89
+ if (packageName) {
90
+ const fullPath =
91
+ packageName === CORE_COMPONENTS_PACKAGE
92
+ ? `${packageName}/vars/${file}`
93
+ : `${packageName}/${file}`;
94
+
95
+ return fs.readFileSync(require.resolve(fullPath));
70
96
  } else {
71
97
  return fs.readFileSync(path.resolve(__dirname, `../../../packages/vars/src/${file}`));
72
98
  }
@@ -131,7 +157,7 @@ function loadMixins(file) {
131
157
  }
132
158
 
133
159
  function formatVar(variable) {
134
- return `var(${variable})`;
160
+ return variable.startsWith('var(') ? variable : `var(${variable})`;
135
161
  }
136
162
 
137
163
  function findInValue(haystack, needle, fromIndex) {
@@ -145,62 +171,96 @@ function findInValue(haystack, needle, fromIndex) {
145
171
  );
146
172
  }
147
173
 
148
- function choiceVar(variables, prop, group) {
149
- if (group === 'colors') {
150
- const colorVariants = () => {
151
- switch (prop) {
152
- case 'color':
153
- return ['text'];
154
- case 'background-color':
155
- case 'background':
156
- return ['bg', 'specialbg', 'graphic'];
157
- case 'border':
158
- case 'border-top':
159
- case 'border-right':
160
- case 'border-bottom':
161
- case 'border-left':
162
- return ['border', 'graphic', 'bg', 'specialbg'];
163
- default:
164
- return [];
165
- }
166
- };
174
+ function getColorVariants(prop) {
175
+ switch (prop) {
176
+ case 'color':
177
+ return ['text'];
178
+ case 'background-color':
179
+ case 'background':
180
+ return ['bg', 'specialbg', 'graphic'];
181
+ case 'border':
182
+ case 'border-top':
183
+ case 'border-right':
184
+ case 'border-bottom':
185
+ case 'border-left':
186
+ return ['border', 'graphic', 'bg', 'specialbg'];
187
+ default:
188
+ return [];
189
+ }
190
+ }
167
191
 
168
- const variants = colorVariants();
192
+ function choiceVars(variables, prop, group) {
193
+ if (group === 'colors') {
194
+ const variants = getColorVariants(prop);
169
195
 
170
196
  const condition = (variable) =>
171
197
  variants.some((variant) => variable.startsWith(`--color-light-${variant}`));
172
198
 
173
- const result = sortVarsByUsage(variables, variants).filter(condition);
174
-
175
- return result.length <= 1 ? result[0] : result;
199
+ return sortVarsByUsage(variables, variants).filter(condition);
176
200
  }
177
201
 
178
- return variables[0];
202
+ return variables;
179
203
  }
180
204
 
181
- function findVar(cssValue, prop) {
205
+ function findVars(cssValue, prop, options) {
182
206
  const vars = varsByProperties[prop];
183
207
  if (!vars) return;
184
208
 
185
209
  const group = getVarsGroup(vars);
186
210
 
211
+ if (group === 'gaps' || group === 'borderRadiuses') {
212
+ if (options.allowNumericValues) {
213
+ return;
214
+ }
215
+ }
216
+
187
217
  for (const [value, variables] of Object.entries(vars)) {
188
- const variable = choiceVar(variables, prop, group);
218
+ const chosen = choiceVars(variables, prop, group);
189
219
 
190
- if (!variable) continue;
220
+ if (!chosen || !chosen.length) continue;
191
221
 
192
222
  const index = findInValue(cssValue, value);
223
+
193
224
  if (index !== false) {
194
225
  return {
195
226
  index,
196
227
  value,
197
- variable,
228
+ variables: chosen,
229
+ fixedValue: formatVar(chosen[0]),
230
+ fixable: chosen.length === 1,
198
231
  };
199
232
  }
200
233
  }
201
234
  }
202
235
 
203
- function findTypographyMixin(ruleProps) {
236
+ function findOldVars(cssValue, prop) {
237
+ const matches = /var\(([^\),]+)/g.exec(cssValue);
238
+
239
+ if (matches) {
240
+ const oldVar = matches[1];
241
+ const replacements = oldNewMap[oldVar];
242
+ if (!replacements) return;
243
+
244
+ const variants = getColorVariants(prop);
245
+
246
+ let variables = replacements.filter((r) => variants.some((v) => r.includes(v)));
247
+ const fixable = variables.length === 1;
248
+
249
+ if (!variables.length) {
250
+ variables = replacements;
251
+ }
252
+
253
+ return {
254
+ index: cssValue.indexOf(oldVar),
255
+ value: oldVar,
256
+ variables,
257
+ fixedValue: variables.length ? variables[0] : 'NON_FIXABLE',
258
+ fixable,
259
+ };
260
+ }
261
+ }
262
+
263
+ function findTypographyMixins(ruleProps) {
204
264
  const findMixin = (exact) => {
205
265
  return Object.entries(mixins.typography)
206
266
  .filter(([_, mixinProps]) => {
@@ -217,9 +277,10 @@ function findTypographyMixin(ruleProps) {
217
277
 
218
278
  const exact = findMixin(true);
219
279
  if (exact.length) {
220
- return exact[0];
280
+ return exact;
221
281
  } else {
222
- return findMixin(false);
282
+ const mixins = findMixin(false);
283
+ return mixins.length > 0 ? mixins : null;
223
284
  }
224
285
  }
225
286
 
@@ -242,10 +303,14 @@ function sortVarsByUsage(arr, sortingArr) {
242
303
  });
243
304
  }
244
305
 
245
- module.exports.VARS_AVAILABLE = VARS_AVAILABLE;
246
- module.exports.vars = vars;
247
- module.exports.mixins = mixins;
248
- module.exports.findVar = findVar;
249
- module.exports.formatVar = formatVar;
250
- module.exports.toOneLine = toOneLine;
251
- module.exports.findTypographyMixin = findTypographyMixin;
306
+ module.exports = {
307
+ VARS_AVAILABLE,
308
+ vars,
309
+ colorsSet,
310
+ mixins,
311
+ findVars,
312
+ formatVar,
313
+ toOneLine,
314
+ findTypographyMixins,
315
+ findOldVars,
316
+ };
package/package.json CHANGED
@@ -1,23 +1,48 @@
1
1
  {
2
2
  "name": "@alfalab/stylelint-core-vars",
3
- "version": "0.0.4",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "core-components css linter",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "jest"
8
8
  },
9
- "author": "reme3d2y",
10
- "license": "ISC",
9
+ "author": "core-ds contributors",
10
+ "license": "MIT",
11
11
  "devDependencies": {
12
- "@alfalab/core-components": "^5.10.0",
13
- "jest": "^26.6.3",
14
- "jest-preset-stylelint": "^3.0.0",
15
- "stylelint": "^13.8.0"
12
+ "@alfalab/core-components-vars": "7.0.0",
13
+ "@semantic-release/changelog": "6.0.3",
14
+ "@semantic-release/commit-analyzer": "11.1.0",
15
+ "@semantic-release/git": "10.0.1",
16
+ "@semantic-release/github": "9.2.6",
17
+ "@semantic-release/npm": "11.0.2",
18
+ "@semantic-release/release-notes-generator": "12.1.0",
19
+ "arui-presets-lint": "7.3.0",
20
+ "jest": "29.7.0",
21
+ "jest-preset-stylelint": "6.3.2",
22
+ "lint-staged": "15.2.7",
23
+ "prettier": "3.3.2",
24
+ "semantic-release": "22.0.12",
25
+ "simple-git-hooks": "2.11.1",
26
+ "stylelint": "13.13.1"
16
27
  },
17
28
  "jest": {
18
29
  "preset": "jest-preset-stylelint",
19
30
  "setupFiles": [
20
31
  "./jest.setup.js"
21
32
  ]
22
- }
33
+ },
34
+ "commitlint": {
35
+ "extends": "./node_modules/arui-presets-lint/commitlint"
36
+ },
37
+ "lint-staged": {
38
+ "*.{js,jsx,ts,tsx,json}": [
39
+ "prettier --write"
40
+ ]
41
+ },
42
+ "simple-git-hooks": {
43
+ "pre-commit": "./node_modules/.bin/lint-staged",
44
+ "commit-msg": "./node_modules/.bin/commitlint --edit $1"
45
+ },
46
+ "prettier": "arui-presets-lint/prettier",
47
+ "packageManager": "yarn@4.3.1"
23
48
  }
package/.prettierrc.js DELETED
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- trailingComma: 'es5',
3
- tabWidth: 4,
4
- semi: true,
5
- singleQuote: true,
6
- printWidth: 100,
7
- };
package/index.test.js DELETED
@@ -1,333 +0,0 @@
1
- const vars = require('./utils').vars;
2
- const mixins = require('./utils').mixins;
3
- const { messages, ruleName } = require('.');
4
-
5
- testRule({
6
- plugins: ['.'],
7
- ruleName,
8
- config: true,
9
- fix: true,
10
- accept: [
11
- {
12
- code: `.class {
13
- padding-left: var(--gap-2xs);
14
- }`,
15
- description: 'singleline rule with single value',
16
- },
17
- {
18
- code: `.class {
19
- padding: var(--gap-xs) 0 var(--gap-m) 0;
20
- }`,
21
- description: 'singleline rule with multiple values',
22
- },
23
- {
24
- code: `.class {
25
- margin-top: var(--gap-xs);
26
- margin-bottom: var(--gap-l);
27
- }`,
28
- description: 'multiline rule',
29
- },
30
- {
31
- code: `.class {
32
- padding: var(--gap-xs) 0 var(--gap-m) 0;
33
- margin: var(--gap-l);
34
- }`,
35
- description: 'multiline rule',
36
- },
37
- {
38
- code: `.class {
39
- padding-left: 3px;
40
- color: #000;
41
- }`,
42
- description: 'custom value',
43
- },
44
- {
45
- code: `.class {
46
- box-shadow: 0 0 8px #B000B5, 0 0 8px #BADA55,
47
- 0 4px 8px #C0FFEE;
48
- }`,
49
- description: 'singleline rule with multiline value',
50
- },
51
- {
52
- code: `.class {
53
- background-color: var(--color-light-bg-primary);
54
- background: var(--color-light-bg-primary);
55
- color: var(--color-light-text-primary);
56
- }`,
57
- description: 'colors',
58
- },
59
- {
60
- code: `.class {
61
- @mixin headline_xlarge;
62
- }`,
63
- description: 'typography',
64
- },
65
- ],
66
- reject: [
67
- {
68
- code: `.class {\n padding-top: 8px;\n}`,
69
- fixed: `.class {\n padding-top: var(--gap-xs);\n}`,
70
- description: 'hardcode single gap',
71
- message: messages.expectedVar('--gap-xs', '8px'),
72
- line: 2,
73
- column: 18,
74
- },
75
- {
76
- code: `.class {\n padding: 8px 12px 4px 16px;\n}`,
77
- fixed: `.class {\n padding: var(--gap-xs) var(--gap-s) var(--gap-2xs) var(--gap-m);\n}`,
78
- description: 'hardcode multiple gaps',
79
- warnings: [
80
- {
81
- message: messages.expectedVar('--gap-2xs', '4px'),
82
- line: 2,
83
- column: 23,
84
- },
85
- {
86
- message: messages.expectedVar('--gap-xs', '8px'),
87
- line: 2,
88
- column: 14,
89
- },
90
- {
91
- message: messages.expectedVar('--gap-s', '12px'),
92
- line: 2,
93
- column: 18,
94
- },
95
- {
96
- message: messages.expectedVar('--gap-m', '16px'),
97
- line: 2,
98
- column: 27,
99
- },
100
- ],
101
- },
102
- {
103
- code: `.class {\n box-shadow: 0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04);\n}`,
104
- fixed: `.class {\n box-shadow: var(--shadow-xs);\n}`,
105
- description: 'hardcode singleline shadow',
106
- message: messages.expectedVar(
107
- '--shadow-xs',
108
- '0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04)'
109
- ),
110
- line: 2,
111
- column: 17,
112
- },
113
- {
114
- code: `.class {\n box-shadow: 0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04),
115
- 0 2px 4px rgba(11, 31, 53, 0.16);\n}`,
116
- fixed: `.class {\n box-shadow: var(--shadow-xs-hard);\n}`,
117
- description: 'hardcode multiline shadow',
118
- message: messages.expectedVar(
119
- '--shadow-xs-hard',
120
- '0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04), 0 2px 4px rgba(11, 31, 53, 0.16)'
121
- ),
122
- line: 2,
123
- column: 17,
124
- },
125
- {
126
- code: `.class {\n color: #0b1f35;\n}`,
127
- fixed: `.class {\n color: var(--color-light-text-primary);\n}`,
128
- description: 'hardcode single color',
129
- message: messages.expectedVar('--color-light-text-primary', '#0b1f35'),
130
- line: 2,
131
- column: 12,
132
- },
133
- {
134
- code: `.class {\n padding-top: 8px;\n box-shadow: 0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04);\n}`,
135
- fixed: `.class {\n padding-top: var(--gap-xs);\n box-shadow: var(--shadow-xs);\n}`,
136
- description: 'hardcode multiple props',
137
- warnings: [
138
- {
139
- message: messages.expectedVar('--gap-xs', '8px'),
140
- line: 2,
141
- column: 18,
142
- },
143
- {
144
- message: messages.expectedVar(
145
- '--shadow-xs',
146
- '0 0 4px rgba(11, 31, 53, 0.02), 0 2px 4px rgba(11, 31, 53, 0.04)'
147
- ),
148
- line: 3,
149
- column: 17,
150
- },
151
- ],
152
- },
153
- // {
154
- // code: `.class {
155
- // background-color: #fff;
156
- // background: #fff;
157
- // border: 1px solid #0b1f35;
158
- // }`,
159
- // fixed: `.class {
160
- // background-color: #fff;
161
- // background: #fff;
162
- // border: 1px solid #0b1f35;
163
- // }`,
164
- // unfixable: true,
165
- // description: 'hardcode colors',
166
- // warnings: [
167
- // {
168
- // column: 35,
169
- // line: 2,
170
- // message: messages.expectedVars(
171
- // ['--color-light-bg-primary', '--color-light-specialbg-secondary-grouped'],
172
- // '#fff'
173
- // ),
174
- // },
175
- // {
176
- // column: 29,
177
- // line: 3,
178
- // message: messages.expectedVars(
179
- // ['--color-light-bg-primary', '--color-light-specialbg-secondary-grouped'],
180
- // '#fff'
181
- // ),
182
- // },
183
- // {
184
- // column: 35,
185
- // line: 4,
186
- // message: messages.expectedVars(
187
- // [
188
- // '--color-light-border-key',
189
- // '--color-light-graphic-primary',
190
- // '--color-light-bg-primary-inverted',
191
- // ],
192
- // '#0b1f35'
193
- // ),
194
- // },
195
- // ],
196
- // },
197
- {
198
- code: `.class {
199
- background-color: var(--color-light-bg-primary);
200
- font-size: 48px;
201
- line-height: 64px;
202
- background: var(--color-light-bg-primary);
203
- font-weight: 500;
204
- color: var(--color-light-text-primary);
205
- }`,
206
- fixed: `.class {
207
- @mixin headline_xlarge;
208
- background-color: var(--color-light-bg-primary);
209
- background: var(--color-light-bg-primary);
210
- color: var(--color-light-text-primary);
211
- }`,
212
- description: 'typography',
213
- message: messages.expectedMixin('headline_xlarge'),
214
- line: 3,
215
- column: 17,
216
- },
217
- {
218
- code: `.class {
219
- font-size: 48px;
220
- line-height: 64px;
221
- font-weight: 500;
222
- }`,
223
- fixed: `.class {
224
- @mixin headline_xlarge;
225
- }`,
226
- description: 'typography',
227
- message: messages.expectedMixin('headline_xlarge'),
228
- line: 2,
229
- column: 17,
230
- },
231
- {
232
- code: `.class {
233
- font-size: 14px;
234
- line-height: 20px;
235
- font-weight: 400;
236
- }`,
237
- fixed: `.class {
238
- @mixin paragraph_primary_small;
239
- }`,
240
- description: 'typography',
241
- message: messages.expectedMixin('paragraph_primary_small'),
242
- line: 2,
243
- column: 17,
244
- },
245
- // {
246
- // code: `.class {
247
- // font-size: 14px;
248
- // line-height: 20px;
249
- // }`,
250
- // fixed: `.class {
251
- // font-size: 14px;
252
- // line-height: 20px;
253
- // }`,
254
- // unfixable: true,
255
- // description: 'typography',
256
- // message: messages.expectedMixins([
257
- // {
258
- // name: 'paragraph_primary_small',
259
- // props: mixins.typography['paragraph_primary_small'],
260
- // },
261
- // { name: 'accent_primary_small', props: mixins.typography['accent_primary_small'] },
262
- // { name: 'action_primary_small', props: mixins.typography['action_primary_small'] },
263
- // ]),
264
- // line: 2,
265
- // column: 17,
266
- // },
267
- // {
268
- // code: `.class {
269
- // font-size: 14px;
270
- // }`,
271
- // fixed: `.class {
272
- // font-size: 14px;
273
- // }`,
274
- // unfixable: true,
275
- // description: 'typography',
276
- // message: messages.expectedMixins([
277
- // {
278
- // name: 'paragraph_primary_small',
279
- // props: mixins.typography['paragraph_primary_small'],
280
- // },
281
- // { name: 'accent_primary_small', props: mixins.typography['accent_primary_small'] },
282
- // { name: 'action_primary_small', props: mixins.typography['action_primary_small'] },
283
- // { name: 'legacy_primary_small', props: mixins.typography['legacy_primary_small'] },
284
- // { name: 'system_14-18_regular', props: mixins.typography['system_14-18_regular'] },
285
- // ]),
286
- // line: 2,
287
- // column: 17,
288
- // },
289
- ...Object.entries(vars.gaps).map(([value, vars]) => {
290
- const gapVar = vars[0];
291
-
292
- const props = [
293
- 'padding',
294
- 'margin',
295
- 'padding-left',
296
- 'padding-right',
297
- 'padding-top',
298
- 'padding-bottom',
299
- 'margin-left',
300
- 'margin-right',
301
- 'margin-top',
302
- 'margin-bottom',
303
- ];
304
-
305
- return {
306
- code: `.class {
307
- ${props.map((prop) => `${prop}: ${value};`).join('\n')}
308
- }`,
309
- fixed: `.class {
310
- ${props.map((prop) => `${prop}: var(${gapVar});`).join('\n')}
311
- }`,
312
- description: `should use ${gapVar}`,
313
- warnings: props.map((_) => ({
314
- message: messages.expectedVar(gapVar, value),
315
- })),
316
- };
317
- }),
318
- ...Object.entries(vars.shadows).map(([value, vars]) => {
319
- const shadowVar = vars[0];
320
-
321
- return {
322
- code: `.class {
323
- box-shadow: ${value};
324
- }`,
325
- fixed: `.class {
326
- box-shadow: var(${shadowVar});
327
- }`,
328
- description: `should use ${shadowVar}`,
329
- message: messages.expectedVar(shadowVar, value),
330
- };
331
- }),
332
- ],
333
- });