@alfalab/stylelint-core-vars 1.4.0 → 1.5.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 CHANGED
@@ -1,19 +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
13
  или
14
14
 
15
15
  ```
16
- npm install --save-dev stylelint stylelint-core-vars
16
+ npm install --save-dev stylelint @alfalab/stylelint-core-vars
17
17
  ```
18
18
 
19
19
  ## Использование
@@ -45,7 +45,13 @@ npm install --save-dev stylelint stylelint-core-vars
45
45
  {
46
46
  "severity": "warning"
47
47
  }
48
- ]
48
+ ],
49
+ "stylelint-core-vars/do-not-use-old-vars": [
50
+ true,
51
+ {
52
+ "severity": "warning"
53
+ }
54
+ ],
49
55
  },
50
56
  }
51
57
  ```
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const stylelint = require('stylelint');
2
+ const { findOldVars } = require('./utils');
2
3
  const toOneLine = require('./utils').toOneLine;
3
- const formatVar = require('./utils').formatVar;
4
4
  const findVars = require('./utils').findVars;
5
5
  const colorsSet = require('./utils').colorsSet;
6
6
  const findTypographyMixins = require('./utils').findTypographyMixins;
@@ -11,6 +11,7 @@ const RULE_USE_ONE_OF_VARS = 'stylelint-core-vars/use-one-of-vars';
11
11
  const RULE_USE_MIXINS = 'stylelint-core-vars/use-mixins';
12
12
  const RULE_USE_ONE_OF_MIXINS = 'stylelint-core-vars/use-one-of-mixins';
13
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';
14
15
 
15
16
  const messages = {
16
17
  [RULE_USE_VARS]: stylelint.utils.ruleMessages(RULE_USE_VARS, {
@@ -25,6 +26,21 @@ const messages = {
25
26
  return `Use variables instead of plain value '${value}':\n${variablesPart}\n`;
26
27
  },
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
+ }),
28
44
  [RULE_USE_MIXINS]: stylelint.utils.ruleMessages(RULE_USE_MIXINS, {
29
45
  expected: (mixin) => {
30
46
  return `Use mixin '${mixin.name}' instead of plain values`;
@@ -45,23 +61,20 @@ const messages = {
45
61
  }),
46
62
  };
47
63
 
48
- const checkVars = (decl, result, context, ruleName) => {
64
+ const checkVars = (decl, result, context, ruleName, matcher, shouldReport) => {
49
65
  const { prop, raws } = decl;
50
66
 
51
67
  let value = toOneLine(decl.value);
52
-
53
68
  let substitution;
69
+
54
70
  const previousValues = [];
55
71
 
56
- while ((substitution = findVars(value, prop))) {
72
+ while ((substitution = matcher(value, prop))) {
57
73
  let fixed = false;
58
74
 
59
- const exactVar = substitution.variables.length === 1;
60
- const fixedValue = formatVar(substitution.variables[0]);
61
-
62
- value = value.replace(substitution.value, fixedValue);
75
+ value = value.replace(substitution.value, substitution.fixedValue);
63
76
 
64
- if (context.fix && exactVar) {
77
+ if (context.fix && substitution.fixable) {
65
78
  decl.value = value;
66
79
  fixed = true;
67
80
  }
@@ -71,16 +84,15 @@ const checkVars = (decl, result, context, ruleName) => {
71
84
  substitution.index
72
85
  );
73
86
 
74
- const shouldReport =
75
- !fixed &&
76
- ((ruleName === RULE_USE_ONE_OF_VARS && !exactVar) ||
77
- (ruleName === RULE_USE_VARS && exactVar));
78
-
79
- if (shouldReport) {
87
+ if (shouldReport(substitution.fixable, fixed)) {
80
88
  stylelint.utils.report({
81
89
  result,
82
90
  ruleName,
83
- message: messages[ruleName].expected(substitution.variables, substitution.value),
91
+ message: messages[ruleName].expected(
92
+ substitution.variables,
93
+ substitution.value,
94
+ substitution.fixable
95
+ ),
84
96
  node: decl,
85
97
  word: value,
86
98
  index: originalValueIndex + prop.length + raws.between.length,
@@ -89,7 +101,7 @@ const checkVars = (decl, result, context, ruleName) => {
89
101
 
90
102
  previousValues.unshift({
91
103
  ...substitution,
92
- diff: fixedValue.length - substitution.value.length,
104
+ diff: substitution.fixedValue.length - substitution.value.length,
93
105
  });
94
106
  }
95
107
  };
@@ -170,7 +182,14 @@ module.exports = [
170
182
 
171
183
  return (root, result) => {
172
184
  root.walkDecls((decl) => {
173
- checkVars(decl, result, context, RULE_USE_VARS);
185
+ checkVars(
186
+ decl,
187
+ result,
188
+ context,
189
+ RULE_USE_VARS,
190
+ findVars,
191
+ (fixable, fixed) => fixable && !fixed
192
+ );
174
193
  });
175
194
  };
176
195
  }),
@@ -181,7 +200,32 @@ module.exports = [
181
200
 
182
201
  return (root, result) => {
183
202
  root.walkDecls((decl) => {
184
- checkVars(decl, result, context, RULE_USE_ONE_OF_VARS);
203
+ checkVars(
204
+ decl,
205
+ result,
206
+ context,
207
+ RULE_USE_ONE_OF_VARS,
208
+ findVars,
209
+ (fixable, fixed) => !fixable && !fixed
210
+ );
211
+ });
212
+ };
213
+ }),
214
+ stylelint.createPlugin(RULE_DO_NOT_USE_OLD_VARS, (enabled, _, context) => {
215
+ if (!enabled || !VARS_AVAILABLE) {
216
+ return () => {};
217
+ }
218
+
219
+ return (root, result) => {
220
+ root.walkDecls((decl) => {
221
+ checkVars(
222
+ decl,
223
+ result,
224
+ context,
225
+ RULE_DO_NOT_USE_OLD_VARS,
226
+ findOldVars,
227
+ (_, fixed) => !fixed
228
+ );
185
229
  });
186
230
  };
187
231
  }),
@@ -226,3 +270,4 @@ module.exports.RULE_USE_ONE_OF_VARS = RULE_USE_ONE_OF_VARS;
226
270
  module.exports.RULE_USE_MIXINS = RULE_USE_MIXINS;
227
271
  module.exports.RULE_USE_ONE_OF_MIXINS = RULE_USE_ONE_OF_MIXINS;
228
272
  module.exports.RULE_DO_NOT_USE_DARK_COLORS = RULE_DO_NOT_USE_DARK_COLORS;
273
+ module.exports.RULE_DO_NOT_USE_OLD_VARS = RULE_DO_NOT_USE_OLD_VARS;
package/index.test.js CHANGED
@@ -5,8 +5,9 @@ const {
5
5
  RULE_USE_ONE_OF_VARS,
6
6
  RULE_USE_MIXINS,
7
7
  RULE_USE_ONE_OF_MIXINS,
8
- messages,
9
8
  RULE_DO_NOT_USE_DARK_COLORS,
9
+ RULE_DO_NOT_USE_OLD_VARS,
10
+ messages,
10
11
  } = require('.');
11
12
 
12
13
  testRule({
@@ -232,8 +233,8 @@ testRule({
232
233
  message: messages[RULE_USE_VARS].expected(['--border-radius-s'], '4px'),
233
234
  line: 3,
234
235
  column: 29,
235
- }
236
- ]
236
+ },
237
+ ],
237
238
  },
238
239
  ...Object.entries(vars.gaps).map(([value, vars]) => {
239
240
  const gapVar = vars[0];
@@ -472,6 +473,82 @@ testRule({
472
473
  ],
473
474
  });
474
475
 
476
+ testRule({
477
+ plugins: [RULE_DO_NOT_USE_OLD_VARS],
478
+ ruleName: RULE_DO_NOT_USE_OLD_VARS,
479
+ config: true,
480
+ fix: true,
481
+ accept: [
482
+ {
483
+ code: `.class {
484
+ color: #000;
485
+ }`,
486
+ description: 'custom value',
487
+ },
488
+ {
489
+ code: `.class {
490
+ background-color: var(--color-light-bg-primary);
491
+ background: var(--color-light-bg-primary);
492
+ color: var(--color-light-text-primary);
493
+ }`,
494
+ description: 'colors',
495
+ },
496
+ ],
497
+ reject: [
498
+ {
499
+ code: `.class {\n background-color: var(--color-dark-indigo-10-flat);\n}`,
500
+ fixed: `.class {\n background-color: var(--color-light-bg-tertiary);\n}`,
501
+ message: messages[RULE_DO_NOT_USE_OLD_VARS].expected(
502
+ ['--color-light-bg-tertiary'],
503
+ '--color-dark-indigo-10-flat'
504
+ ),
505
+ line: 2,
506
+ column: 27,
507
+ },
508
+ {
509
+ code: `.class {\n background-color: var(--color-red-brand-85);\n}`,
510
+ fixed: `.class {\n background-color: var(--color-red-brand-85);\n}`,
511
+ unfixable: true,
512
+ message: messages[RULE_DO_NOT_USE_OLD_VARS].expected([], ['--color-red-brand-85']),
513
+ line: 2,
514
+ column: 27,
515
+ },
516
+ {
517
+ code: `.class {
518
+ color: var(--color-red-brand-10-flat);
519
+ background: var(--color-red-dark);
520
+ fill: var(---color-black-10);
521
+ }`,
522
+ fixed: `.class {
523
+ color: var(--color-red-brand-10-flat);
524
+ background: var(--color-light-graphic-negative);
525
+ fill: var(---color-black-10);
526
+ }`,
527
+ description: 'multiple variants',
528
+ warnings: [
529
+ {
530
+ column: 28,
531
+ line: 2,
532
+ message: messages[RULE_DO_NOT_USE_OLD_VARS].expected(
533
+ ['--color-light-bg-negative-muted'],
534
+ '--color-red-brand-10-flat',
535
+ false
536
+ ),
537
+ },
538
+ {
539
+ column: 33,
540
+ line: 3,
541
+ message: messages[RULE_DO_NOT_USE_OLD_VARS].expected(
542
+ ['--color-light-graphic-negative'],
543
+ '--color-red-dark',
544
+ true
545
+ ),
546
+ },
547
+ ],
548
+ },
549
+ ],
550
+ });
551
+
475
552
  testRule({
476
553
  plugins: [RULE_USE_MIXINS],
477
554
  ruleName: RULE_USE_MIXINS,
@@ -619,8 +696,20 @@ testRule({
619
696
  name: 'paragraph_primary_small',
620
697
  props: mixins.typography['paragraph_primary_small'],
621
698
  },
699
+ {
700
+ name: 'paragraph_component_secondary',
701
+ props: mixins.typography['paragraph_component_secondary'],
702
+ },
622
703
  { name: 'accent_primary_small', props: mixins.typography['accent_primary_small'] },
704
+ {
705
+ name: 'accent_component_secondary',
706
+ props: mixins.typography['accent_component_secondary'],
707
+ },
623
708
  { name: 'action_primary_small', props: mixins.typography['action_primary_small'] },
709
+ {
710
+ name: 'action_component_secondary',
711
+ props: mixins.typography['action_component_secondary'],
712
+ },
624
713
  ]),
625
714
  line: 2,
626
715
  column: 17,
@@ -643,8 +732,20 @@ testRule({
643
732
  name: 'paragraph_primary_small',
644
733
  props: mixins.typography['paragraph_primary_small'],
645
734
  },
735
+ {
736
+ name: 'paragraph_component_secondary',
737
+ props: mixins.typography['paragraph_component_secondary'],
738
+ },
646
739
  { name: 'accent_primary_small', props: mixins.typography['accent_primary_small'] },
740
+ {
741
+ name: 'accent_component_secondary',
742
+ props: mixins.typography['accent_component_secondary'],
743
+ },
647
744
  { name: 'action_primary_small', props: mixins.typography['action_primary_small'] },
745
+ {
746
+ name: 'action_component_secondary',
747
+ props: mixins.typography['action_component_secondary'],
748
+ },
648
749
  ]),
649
750
  line: 3,
650
751
  column: 21,
package/old-new-map.js ADDED
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/stylelint-core-vars",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "core-components css linter",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "author": "reme3d2y",
10
10
  "license": "ISC",
11
11
  "devDependencies": {
12
- "@alfalab/core-components-vars": "^3.0.1",
12
+ "@alfalab/core-components-vars": "^7.0.0",
13
13
  "jest": "^26.6.3",
14
14
  "jest-preset-stylelint": "^3.0.0",
15
15
  "stylelint": "^13.8.0"
package/utils.js CHANGED
@@ -1,5 +1,6 @@
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';
5
6
  const CORE_COMPONENTS_VARS_PACKAGE = '@alfalab/core-components-vars';
@@ -20,7 +21,7 @@ const vars = {
20
21
  };
21
22
 
22
23
  const colorsSet = Object.values(vars.colors).reduce((acc, vars) => {
23
- vars.forEach(colorVar => acc.add(colorVar));
24
+ vars.forEach((colorVar) => acc.add(colorVar));
24
25
 
25
26
  return acc;
26
27
  }, new Set());
@@ -42,6 +43,7 @@ const varsByProperties = {
42
43
  'margin-left': vars.gaps,
43
44
  'box-shadow': vars.shadows,
44
45
  color: vars.colors,
46
+ fill: vars.colors,
45
47
  background: vars.colors,
46
48
  'background-color': vars.colors,
47
49
  border: vars.colors,
@@ -155,7 +157,7 @@ function loadMixins(file) {
155
157
  }
156
158
 
157
159
  function formatVar(variable) {
158
- return `var(${variable})`;
160
+ return variable.startsWith('var(') ? variable : `var(${variable})`;
159
161
  }
160
162
 
161
163
  function findInValue(haystack, needle, fromIndex) {
@@ -169,27 +171,27 @@ function findInValue(haystack, needle, fromIndex) {
169
171
  );
170
172
  }
171
173
 
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
+ }
191
+
172
192
  function choiceVars(variables, prop, group) {
173
193
  if (group === 'colors') {
174
- const colorVariants = () => {
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
- };
191
-
192
- const variants = colorVariants();
194
+ const variants = getColorVariants(prop);
193
195
 
194
196
  const condition = (variable) =>
195
197
  variants.some((variant) => variable.startsWith(`--color-light-${variant}`));
@@ -218,11 +220,40 @@ function findVars(cssValue, prop) {
218
220
  index,
219
221
  value,
220
222
  variables: chosen,
223
+ fixedValue: formatVar(chosen[0]),
224
+ fixable: chosen.length === 1,
221
225
  };
222
226
  }
223
227
  }
224
228
  }
225
229
 
230
+ function findOldVars(cssValue, prop) {
231
+ const matches = /var\(([^\),]+)/g.exec(cssValue);
232
+
233
+ if (matches) {
234
+ const oldVar = matches[1];
235
+ const replacements = oldNewMap[oldVar];
236
+ if (!replacements) return;
237
+
238
+ const variants = getColorVariants(prop);
239
+
240
+ let variables = replacements.filter((r) => variants.some((v) => r.includes(v)));
241
+ const fixable = variables.length === 1;
242
+
243
+ if (!variables.length) {
244
+ variables = replacements;
245
+ }
246
+
247
+ return {
248
+ index: cssValue.indexOf(oldVar),
249
+ value: oldVar,
250
+ variables,
251
+ fixedValue: variables.length ? variables[0] : 'NON_FIXABLE',
252
+ fixable,
253
+ };
254
+ }
255
+ }
256
+
226
257
  function findTypographyMixins(ruleProps) {
227
258
  const findMixin = (exact) => {
228
259
  return Object.entries(mixins.typography)
@@ -266,11 +297,14 @@ function sortVarsByUsage(arr, sortingArr) {
266
297
  });
267
298
  }
268
299
 
269
- module.exports.VARS_AVAILABLE = VARS_AVAILABLE;
270
- module.exports.vars = vars;
271
- module.exports.colorsSet = colorsSet;
272
- module.exports.mixins = mixins;
273
- module.exports.findVars = findVars;
274
- module.exports.formatVar = formatVar;
275
- module.exports.toOneLine = toOneLine;
276
- module.exports.findTypographyMixins = findTypographyMixins;
300
+ module.exports = {
301
+ VARS_AVAILABLE,
302
+ vars,
303
+ colorsSet,
304
+ mixins,
305
+ findVars,
306
+ formatVar,
307
+ toOneLine,
308
+ findTypographyMixins,
309
+ findOldVars,
310
+ };