@zohodesk/react-cli 1.0.1-exp.1 → 1.0.2

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.
Files changed (119) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/Changelog.md +1019 -1019
  5. package/README.md +1165 -1152
  6. package/bin/cli.js +483 -483
  7. package/docs/CustomChunks.md +26 -26
  8. package/docs/DevServerPort.md +39 -39
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/SelectorWeight.md +9 -6
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +729 -724
  16. package/docs/warnings_while_install.txt +35 -35
  17. package/files/eslintrc.js +62 -62
  18. package/files/prettierrc.js +3 -3
  19. package/lib/configs/webpack.css.umd.config.js +4 -4
  20. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  21. package/lib/loaderUtils/getCSSLoaders.js +1 -1
  22. package/lib/loaders/workerLoader.js +9 -9
  23. package/lib/pluginUtils/getDevPlugins.js +5 -5
  24. package/lib/pluginUtils/getProdPlugins.js +5 -5
  25. package/lib/plugins/EFCPlugin.md +6 -6
  26. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  27. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  28. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  29. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  30. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  31. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  32. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  33. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  34. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  35. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  36. package/lib/plugins/SelectorPlugin.js +15 -38
  37. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  38. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  39. package/lib/plugins/VariableConversionCollector.js +54 -54
  40. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
  41. package/lib/postcss-plugins/SelectorReplace.js +80 -0
  42. package/lib/postcss-plugins/__test__/selectorReplace.test.js +28 -0
  43. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  44. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  45. package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
  46. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -1
  47. package/lib/postcss-plugins/variableModificationPlugin/index.js +13 -13
  48. package/lib/sh/pre-commit.sh +34 -34
  49. package/lib/sh/reportPublish.sh +45 -45
  50. package/lib/utils/buildstats.html +148 -148
  51. package/lib/utils/resultSchema.json +73 -73
  52. package/npm8.md +9 -9
  53. package/package.json +120 -121
  54. package/postpublish.js +8 -8
  55. package/result.json +1 -0
  56. package/templates/app/.eslintrc.js +140 -140
  57. package/templates/app/README.md +12 -12
  58. package/templates/app/app/index.html +24 -24
  59. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  60. package/templates/app/app/properties/i18nkeys.json +3 -3
  61. package/templates/app/docs/all.html +69 -69
  62. package/templates/app/mockapi/index.js +18 -18
  63. package/templates/app/package.json +37 -37
  64. package/templates/app/src/actions/SampleActions/index.js +37 -37
  65. package/templates/app/src/actions/index.js +65 -65
  66. package/templates/app/src/appUrls.js +19 -19
  67. package/templates/app/src/components/Alert/Alert.js +134 -134
  68. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  69. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  70. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  71. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  72. package/templates/app/src/components/Sample/SampleList.js +61 -61
  73. package/templates/app/src/components/Slider/Slider.css +41 -41
  74. package/templates/app/src/components/Slider/Slider.js +55 -55
  75. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  76. package/templates/app/src/containers/AppContainer/index.js +96 -96
  77. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  78. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  79. package/templates/app/src/containers/DevTools/index.js +10 -10
  80. package/templates/app/src/containers/Header/index.js +67 -67
  81. package/templates/app/src/containers/Header/index.module.css +43 -43
  82. package/templates/app/src/containers/Redirect/index.js +63 -63
  83. package/templates/app/src/containers/Redirector/index.js +47 -47
  84. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  85. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  86. package/templates/app/src/historyChange.js +5 -5
  87. package/templates/app/src/index.html +10 -10
  88. package/templates/app/src/index.js +24 -24
  89. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  90. package/templates/app/src/reducers/alertData.js +11 -11
  91. package/templates/app/src/reducers/index.js +6 -6
  92. package/templates/app/src/reducers/samples.js +19 -19
  93. package/templates/app/src/store/configureStore.dev.js +51 -51
  94. package/templates/app/src/store/configureStore.js +5 -5
  95. package/templates/app/src/store/configureStore.prod.js +26 -26
  96. package/templates/app/src/util/Common.js +5 -5
  97. package/templates/app/src/util/RequestAPI.js +132 -132
  98. package/templates/docs/all.html +249 -249
  99. package/templates/docs/component.html +178 -178
  100. package/templates/docs/components.html +221 -221
  101. package/templates/docs/css/b.min.css +6 -6
  102. package/templates/docs/css/component.css +42 -42
  103. package/templates/docs/css/componentTest.css +6 -6
  104. package/templates/docs/css/hopscotch.css +585 -585
  105. package/templates/docs/css/style.css +1022 -1022
  106. package/templates/docs/impactReportTemplate.html +154 -154
  107. package/templates/docs/index.html +1501 -1501
  108. package/templates/docs/js/active-line.js +72 -72
  109. package/templates/docs/js/b.min.js +7 -7
  110. package/templates/docs/js/codemirror.js +9680 -9680
  111. package/templates/docs/js/designTokens.js +334 -334
  112. package/templates/docs/js/j.min.js +4 -4
  113. package/templates/docs/js/javascript.js +874 -874
  114. package/templates/docs/js/matchbrackets.js +145 -145
  115. package/unittest/index.html +37 -0
  116. package/lib/plugins/cssoPlugin.js +0 -37
  117. package/lib/plugins/utils/checkPattern.js +0 -57
  118. package/lib/plugins/utils/classHandling.js +0 -28
  119. package/lib/plugins/utils/fileHandling.js +0 -122
@@ -26,15 +26,15 @@ const {
26
26
  const supportedProps = ['font-size', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', '^top', '^right', '^bottom', '^left', '^width', 'min-width', 'max-width', '^height', 'min-height', 'max-height', 'text-indent', 'clip', 'flex-basis', 'row-gap', 'gap', 'column-gap', 'flex']; // const avoidProps = [];
27
27
  // -- is issue IO --
28
28
 
29
- /*
30
- issues eg :
31
- issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
32
- input :
33
- --zd_size
34
- output :
35
- true
36
- comment :
37
- do not execute when --zd_size comes as prop
29
+ /*
30
+ issues eg :
31
+ issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
32
+ input :
33
+ --zd_size
34
+ output :
35
+ true
36
+ comment :
37
+ do not execute when --zd_size comes as prop
38
38
  */
39
39
 
40
40
  function isIgnoreValuePresent(ignoreVals, prop) {
@@ -47,14 +47,14 @@ function isIgnoreValuePresent(ignoreVals, prop) {
47
47
  return present;
48
48
  } // -- to convert the hyphen values to values --
49
49
 
50
- /*
51
- input :
52
- var(--zdt_uploadlist_default_width)
53
- output :
54
- --zdt_uploadlist_default_width
55
-
56
- comment :
57
- to make the variable object using the output as key and decl.prop such as font-size as value
50
+ /*
51
+ input :
52
+ var(--zdt_uploadlist_default_width)
53
+ output :
54
+ --zdt_uploadlist_default_width
55
+
56
+ comment :
57
+ to make the variable object using the output as key and decl.prop such as font-size as value
58
58
  */
59
59
 
60
60
 
@@ -154,13 +154,13 @@ class VariableConversionCollector {
154
154
  }
155
155
  };
156
156
  }
157
- /*
158
- purpose of tap : to create a variable object such as:
159
- {
160
- --zdt_uploadlist_default_width : width,
161
- --zdt_uploadlist_default_height : height,
162
- }
163
- which will help in the conversion further
157
+ /*
158
+ purpose of tap : to create a variable object such as:
159
+ {
160
+ --zdt_uploadlist_default_width : width,
161
+ --zdt_uploadlist_default_height : height,
162
+ }
163
+ which will help in the conversion further
164
164
  */
165
165
 
166
166
 
@@ -216,19 +216,19 @@ class VariableConversionCollector {
216
216
  });
217
217
  });
218
218
  });
219
- /*
220
- current value example:
221
- {
222
- --zdt_uploadlist_default_width : --zd_upload_width,
223
- --zd_upload_width : width
224
- }
225
- expected value :
226
- {
227
- --zdt_uploadlist_default_width : width,
228
- --zd_upload_width : width
229
- }
230
-
231
- conversion is done in the while loop below
219
+ /*
220
+ current value example:
221
+ {
222
+ --zdt_uploadlist_default_width : --zd_upload_width,
223
+ --zd_upload_width : width
224
+ }
225
+ expected value :
226
+ {
227
+ --zdt_uploadlist_default_width : width,
228
+ --zd_upload_width : width
229
+ }
230
+
231
+ conversion is done in the while loop below
232
232
  */
233
233
 
234
234
  Object.keys(variables).forEach(key => {
@@ -240,17 +240,17 @@ class VariableConversionCollector {
240
240
  });
241
241
  }); // -- conversion for the root using rootConvertor --
242
242
 
243
- /*
244
- input :
245
- .a{
246
- padding : 20px
247
- }
248
- output :
249
- // on settingObject file :
250
- { padding : { replacements : { px : 'zd_size$$' }}}
251
- .a{
252
- padding : zd_size20;
253
- }
243
+ /*
244
+ input :
245
+ .a{
246
+ padding : 20px
247
+ }
248
+ output :
249
+ // on settingObject file :
250
+ { padding : { replacements : { px : 'zd_size$$' }}}
251
+ .a{
252
+ padding : zd_size20;
253
+ }
254
254
  */
255
255
 
256
256
  compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
@@ -262,12 +262,12 @@ class VariableConversionCollector {
262
262
  });
263
263
  });
264
264
  });
265
- /*
266
- purpose of tap : to display the errors encountered so far
267
- input :
268
- all css files
269
- output :
270
- all errors that are present in the errTable arr
265
+ /*
266
+ purpose of tap : to display the errors encountered so far
267
+ input :
268
+ all css files
269
+ output :
270
+ all errors that are present in the errTable arr
271
271
  */
272
272
 
273
273
  compiler.hooks.afterEmit.tap('error-display', () => {
@@ -38,11 +38,11 @@ function selectorMinifySameDir(selector, direction) {
38
38
  const regex = getRegex(direction);
39
39
  return selector.replace(regex, '').trim();
40
40
  }
41
- /**
42
- * this funtion will remove given rule,
43
- * if given selector and it's previous sibiling rule selector are same
44
- * current rule properties will move to previous sibiling rule.
45
- * @param {Rule} rule current rule
41
+ /**
42
+ * this funtion will remove given rule,
43
+ * if given selector and it's previous sibiling rule selector are same
44
+ * current rule properties will move to previous sibiling rule.
45
+ * @param {Rule} rule current rule
46
46
  */
47
47
 
48
48
 
@@ -57,11 +57,11 @@ function mergeIfSameSelector(rule) {
57
57
  rule.remove();
58
58
  }
59
59
  }
60
- /**
61
- * this funtion will remove given rule,
62
- * if given selector and it's previous sibiling rule selector are same
63
- * current rule properties will move to previous sibiling rule.
64
- * @param {Rule} rule current rule
60
+ /**
61
+ * this funtion will remove given rule,
62
+ * if given selector and it's previous sibiling rule selector are same
63
+ * current rule properties will move to previous sibiling rule.
64
+ * @param {Rule} rule current rule
65
65
  */
66
66
 
67
67
 
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var _postcss = _interopRequireDefault(require("postcss"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ function validator(opts) {
8
+ if (!opts || typeof opts !== 'object') {
9
+ throw new Error('Always requires argment');
10
+ }
11
+
12
+ const {
13
+ before,
14
+ after
15
+ } = opts;
16
+
17
+ if (!before || !after) {
18
+ throw new Error('Be sure to have "before" and "after" object names');
19
+ }
20
+
21
+ if (!Array.isArray(before) || !Array.isArray(after)) {
22
+ throw new Error('Objects "before" and "after" must be of type Array');
23
+ }
24
+
25
+ if (before.length !== after.length) {
26
+ throw new Error('Length of before and after options must be the same');
27
+ }
28
+
29
+ if (before.length === 0) {
30
+ throw new Error('Array length is 1 or more');
31
+ }
32
+
33
+ before.forEach((beforeOpt, idx) => {
34
+ const afterOpt = after[idx];
35
+
36
+ switch (true) {
37
+ case typeof beforeOpt === 'string':
38
+ {
39
+ if (!typeof afterOpt === 'string') {
40
+ throw new Error(`The after option ${afterOpt} must be a string. If you want to apply the replace callback function, then use a RegExp for the before option`);
41
+ }
42
+
43
+ break;
44
+ }
45
+
46
+ case beforeOpt instanceof RegExp:
47
+ {
48
+ if (!typeof afterOpt === 'string' && !typeof afterOpt === 'function') {
49
+ throw new Error(`The after option ${afterOpt} must be either a string, or a function`);
50
+ }
51
+
52
+ break;
53
+ }
54
+
55
+ default:
56
+ throw new Error(`The before option ${beforeOpt} must be either a string, or a RegExp`);
57
+ }
58
+ });
59
+ }
60
+
61
+ module.exports = _postcss.default.plugin('postcss-selector-replace-new', opts => {
62
+ validator(opts);
63
+ const {
64
+ before,
65
+ after
66
+ } = opts;
67
+ return root => {
68
+ root.walkRules(rule => {
69
+ before.forEach((beforeOpt, idx) => {
70
+ const afterOpt = after[idx];
71
+
72
+ if (typeof beforeOpt === 'string') {
73
+ rule.selector = rule.selector.split(beforeOpt).join(afterOpt);
74
+ } else {
75
+ rule.selector = rule.selector.replace(beforeOpt, afterOpt);
76
+ }
77
+ });
78
+ });
79
+ };
80
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ let settings1 = {
4
+ selectorReplace: {
5
+ before: [':root', 'data-mode', 'data-theme'],
6
+ after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'data-desk-mode', 'data-desk-theme']
7
+ }
8
+ };
9
+ let settings2 = {
10
+ selectorReplace: {
11
+ before: [':root', 'data-'],
12
+ after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'test-']
13
+ }
14
+ }; //error case
15
+
16
+ let settings3 = {
17
+ selectorReplace: {
18
+ before: [':root', 'data-'],
19
+ after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__']
20
+ }
21
+ }; //error case
22
+
23
+ let settings4 = {
24
+ selectorReplace: {
25
+ before: [':root'],
26
+ after: [':global .zohodesk_controlpanel,:global .wms-mainui,:global .wms-hysearch, :global .mcf1ee8b17_overlay,:global .wms-hvalign, :global .KB_Editor_UploadImage,:global .zdeskEditor_popup, :global .ze_dd, :global .__baseZC_Container__', 'test-']
27
+ }
28
+ }; // here conversion happens for data from one index to another
@@ -1,39 +1,39 @@
1
- /*Hover_active:ignore*/
2
- g,a:hover{
3
- color : red
4
- }
5
- /*Hover:ignore*/
6
- h:hover{
7
- background : yellow
8
- }
9
-
10
- /* Hover_active:ignore */
11
- g,d+e:hover{
12
- color : black
13
- }
14
-
15
- g,d e:hover{
16
- color : black
17
- }
18
-
19
- @media screen and (max-width:61.25em){
20
- /* Hover_active:ignore */
21
- a,b,a:hover, b:hover{
22
- background-color : blue
23
- }
24
- a + b,a:hover + b:hover{
25
- background-color : blue
26
- }
27
- a b:hover{
28
- background-color : blue
29
- }
30
-
31
- .cc:hover {
32
- color: red;
33
- }
34
-
35
- c:hover{
36
- color : red
37
- }
38
-
1
+ /*Hover_active:ignore*/
2
+ g,a:hover{
3
+ color : red
4
+ }
5
+ /*Hover:ignore*/
6
+ h:hover{
7
+ background : yellow
8
+ }
9
+
10
+ /* Hover_active:ignore */
11
+ g,d+e:hover{
12
+ color : black
13
+ }
14
+
15
+ g,d e:hover{
16
+ color : black
17
+ }
18
+
19
+ @media screen and (max-width:61.25em){
20
+ /* Hover_active:ignore */
21
+ a,b,a:hover, b:hover{
22
+ background-color : blue
23
+ }
24
+ a + b,a:hover + b:hover{
25
+ background-color : blue
26
+ }
27
+ a b:hover{
28
+ background-color : blue
29
+ }
30
+
31
+ .cc:hover {
32
+ color: red;
33
+ }
34
+
35
+ c:hover{
36
+ color : red
37
+ }
38
+
39
39
  }
@@ -1,39 +1,39 @@
1
- /*Hover_active:ignore*/
2
- g,a:hover{
3
- color : red
4
- }
5
- /*Hover:ignore*/
6
- h:hover{
7
- background : yellow
8
- }
9
-
10
- /* Hover_active:ignore */
11
- g,d+e:hover{
12
- color : black
13
- }
14
-
15
- g,d e:hover{
16
- color : black
17
- }
18
-
19
- @media screen and (max-width:61.25em){
20
- /* Hover_active:ignore */
21
- a,b,a:hover, b:hover{
22
- background-color : blue
23
- }
24
- a + b,a:hover + b:hover{
25
- background-color : blue
26
- }
27
- a b:hover{
28
- background-color : blue
29
- }
30
-
31
- .cc:hover {
32
- color: red;
33
- }
34
-
35
- c:hover{
36
- color : red
37
- }
38
-
1
+ /*Hover_active:ignore*/
2
+ g,a:hover{
3
+ color : red
4
+ }
5
+ /*Hover:ignore*/
6
+ h:hover{
7
+ background : yellow
8
+ }
9
+
10
+ /* Hover_active:ignore */
11
+ g,d+e:hover{
12
+ color : black
13
+ }
14
+
15
+ g,d e:hover{
16
+ color : black
17
+ }
18
+
19
+ @media screen and (max-width:61.25em){
20
+ /* Hover_active:ignore */
21
+ a,b,a:hover, b:hover{
22
+ background-color : blue
23
+ }
24
+ a + b,a:hover + b:hover{
25
+ background-color : blue
26
+ }
27
+ a b:hover{
28
+ background-color : blue
29
+ }
30
+
31
+ .cc:hover {
32
+ color: red;
33
+ }
34
+
35
+ c:hover{
36
+ color : red
37
+ }
38
+
39
39
  }
@@ -4,9 +4,9 @@ var _postcss = _interopRequireDefault(require("postcss"));
4
4
 
5
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
6
 
7
- /**
8
- * we have give support for ignore(exclude) comments
9
- * These are the comments' keyword
7
+ /**
8
+ * we have give support for ignore(exclude) comments
9
+ * These are the comments' keyword
10
10
  */
11
11
  const hoverIgnoreQuery = 'Hover:ignore',
12
12
  activeIgnoreQuery = 'Active:ignore',
@@ -36,7 +36,6 @@ class ErrorHandler {
36
36
 
37
37
  errorFunction(errObj) {
38
38
  if (errObj.type && this.allowedErrs[errObj.type] && errObj.decl.prop && errObj.decl.value) {
39
- console.log(this.allowedErrs[errObj.type]);
40
39
  this[errObj.type](errObj);
41
40
  }
42
41
  }
@@ -10,8 +10,6 @@ const {
10
10
  ErrorHandler
11
11
  } = require('./ErrorHandler');
12
12
 
13
- const errors = [];
14
- const errorTable = [];
15
13
  const errHandler = new ErrorHandler();
16
14
  const convertableProps = {
17
15
  'font-size': true,
@@ -121,7 +119,7 @@ const singleConvertor = (value, changeVal, details, range) => {
121
119
  // console.log(value, 'not within range')
122
120
 
123
121
 
124
- let errObj = {
122
+ const errObj = {
125
123
  decl,
126
124
  type: 'RANGE_ERROR',
127
125
  filename,
@@ -195,7 +193,7 @@ module.exports = {
195
193
  // }
196
194
 
197
195
  if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase().includes(commentStr)) {
198
- let errObj = {
196
+ const errObj = {
199
197
  decl,
200
198
  type: 'DECLARATION_IGNORED',
201
199
  filename,
@@ -258,7 +256,7 @@ module.exports = {
258
256
  } else {
259
257
  if (!decl.value.includes('calc')) {
260
258
  // addError(` prop: ${decl.prop} ,\n value : ${decl.value} ,\n filename : ${filename} ,\n filepath : ${path} ,\n line : ${decl.source.start.line} ,\n unit : ${unitErrorVal} ,\n message : ${unitErrorVal} (Unit) Not Allowed \r`);
261
- let errObj = {
259
+ const errObj = {
262
260
  decl,
263
261
  filename,
264
262
  unitErrorVal: unitErrorVal,
@@ -288,27 +286,29 @@ module.exports = {
288
286
  }
289
287
  }
290
288
  } else {
291
- if (decl.value && decl.value.includes('px') && decl.value.includes('var(--') && settingsObject[decl.prop]) {
292
- let valArr = decl.value.split(' ');
293
- let settings = settingsObject[decl.prop];
289
+ if (settingsObject[decl.prop] && decl.value && decl.value.includes('px') && decl.value.includes('var(--')) {
290
+ const valArr = decl.value.split(' ');
291
+ const settings = settingsObject[decl.prop];
294
292
  const {
295
293
  range
296
294
  } = settings;
297
- valArr.forEach((val, index) => {
295
+ const convertedVals = valArr.map(val => {
298
296
  if (val.includes('px')) {
299
- let convertedVal = singleConvertor(val, settings.replacements.px, {
297
+ const convertedVal = singleConvertor(val, settings.replacements.px, {
300
298
  decl,
301
299
  filename,
302
300
  path: fromPath
303
301
  }, range);
304
- valArr[index] = convertedVal ? convertedVal : val;
302
+ return convertedVal ? convertedVal : val;
305
303
  }
304
+
305
+ return val;
306
306
  });
307
- decl.value = valArr.join(' ');
307
+ decl.value = convertedVals.join(' ');
308
308
  }
309
309
 
310
310
  if (decl.prop && decl.value && !decl.prop.includes('--') && valRegex.test(decl.value) && (settingsObject[decl.prop] || convertableProps[decl.prop]) && decl.value.includes('var') && !decl.value.includes('calc')) {
311
- let errObj = {
311
+ const errObj = {
312
312
  decl,
313
313
  type: 'VARIABLE_PRESENT',
314
314
  filename,
@@ -1,34 +1,34 @@
1
- #!/bin/sh
2
-
3
- STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "\.(js)$") # Get staged files
4
-
5
- CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') # Get branch name
6
-
7
- echo "Branch Name - $CURRENT_BRANCH"
8
-
9
- if [[ "$STAGED_FILES" = "" ]]; then
10
- exit 0
11
- fi
12
-
13
- IS_FAILED=false
14
- FILES=""
15
-
16
- for FILE in $STAGED_FILES # Add files with space separation
17
- do
18
- FILES+="$FILE "
19
- done
20
-
21
- npm run lint --prefix ${PREFIX_PATH} $FILES # Run ESLint
22
-
23
- if [[ "$?" != 0 ]]; then
24
- IS_FAILED=true
25
- fi
26
-
27
- if $IS_FAILED; then
28
- echo "\033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n"
29
- exit 1
30
- else
31
- echo "\033[42mCOMMIT SUCCEEDED\033[0m\n"
32
- fi
33
-
34
- exit $?
1
+ #!/bin/sh
2
+
3
+ STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "\.(js)$") # Get staged files
4
+
5
+ CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') # Get branch name
6
+
7
+ echo "Branch Name - $CURRENT_BRANCH"
8
+
9
+ if [[ "$STAGED_FILES" = "" ]]; then
10
+ exit 0
11
+ fi
12
+
13
+ IS_FAILED=false
14
+ FILES=""
15
+
16
+ for FILE in $STAGED_FILES # Add files with space separation
17
+ do
18
+ FILES+="$FILE "
19
+ done
20
+
21
+ npm run lint --prefix ${PREFIX_PATH} $FILES # Run ESLint
22
+
23
+ if [[ "$?" != 0 ]]; then
24
+ IS_FAILED=true
25
+ fi
26
+
27
+ if $IS_FAILED; then
28
+ echo "\033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n"
29
+ exit 1
30
+ else
31
+ echo "\033[42mCOMMIT SUCCEEDED\033[0m\n"
32
+ fi
33
+
34
+ exit $?