@cherepanov.pavel/shareable-config 1.0.2 → 1.0.4

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 (49) hide show
  1. package/.editorconfig +2 -3
  2. package/.editorconfig-get.js +3 -3
  3. package/.get-all.js +16 -12
  4. package/.gitattributes-get.js +3 -3
  5. package/.gitignore-get.js +33 -30
  6. package/.vscode/.code-snippets-get.js +34 -31
  7. package/.vscode/extensions.json +17 -17
  8. package/.vscode/extensions.json-get.js +25 -25
  9. package/.vscode/settings.json +36 -27
  10. package/.vscode/settings.json-get.js +25 -25
  11. package/README.md +13 -3
  12. package/env.json5.set.js +1 -1
  13. package/jsconfig.json +4 -7
  14. package/package.json +11 -1
  15. package/tools/eslint-config/configs/global.js +21 -18
  16. package/tools/eslint-config/configs/javascript.js +14 -14
  17. package/tools/eslint-config/configs/json.js +93 -0
  18. package/tools/eslint-config/configs/typescript.js +17 -17
  19. package/tools/eslint-config/configs/vue.js +22 -22
  20. package/tools/eslint-config/index.js +1 -0
  21. package/tools/eslint-config/rules/constants.js +10 -9
  22. package/tools/eslint-config/rules/javascript/index.js +2 -2
  23. package/tools/eslint-config/rules/javascript/possible-problems.js +76 -58
  24. package/tools/eslint-config/rules/javascript/suggestions.js +405 -249
  25. package/tools/eslint-config/rules/stylistic/jsFormatting.js +321 -167
  26. package/tools/eslint-config/rules/stylistic/tsFormatting.js +4 -4
  27. package/tools/eslint-config/rules/typescript/common.js +135 -126
  28. package/tools/eslint-config/rules/typescript/compatibility.js +20 -20
  29. package/tools/eslint-config/rules/typescript/extension.js +44 -44
  30. package/tools/eslint-config/rules/typescript/index.js +3 -3
  31. package/tools/eslint-config/rules/vue/base.js +2 -2
  32. package/tools/eslint-config/rules/vue/extension.js +47 -44
  33. package/tools/eslint-config/rules/vue/formatting.js +66 -36
  34. package/tools/eslint-config/rules/vue/index.js +5 -5
  35. package/tools/eslint-config/rules/vue/possibleProblems.js +182 -109
  36. package/tools/eslint-config/rules/vue/suggestions.js +82 -79
  37. package/tools/stylelint-config/config.js +18 -20
  38. package/tools/stylelint-config/rules/base.js +30 -24
  39. package/tools/stylelint-config/rules/conflicts.js +5 -5
  40. package/tools/stylelint-config/rules/order.js +38 -38
  41. package/tools/stylelint-config/rules/property-groups.js +392 -389
  42. package/tools/stylelint-config/rules/scss.js +9 -6
  43. package/tools/stylelint-config/rules/stylistic.js +110 -109
  44. package/utils/communication.js +26 -26
  45. package/utils/copy-with-override.js +35 -33
  46. package/utils/env.js +4 -4
  47. package/utils/file-header.js +9 -9
  48. package/utils/file.js +46 -46
  49. package/utils/merge.js +161 -155
package/utils/merge.js CHANGED
@@ -1,180 +1,186 @@
1
+ // whole file should be rewrite
2
+ /* eslint-disable no-param-reassign */
3
+ /* eslint-disable no-negated-condition */
4
+ /* eslint-disable max-statements */
5
+ /* eslint-disable no-continue */
6
+ /* eslint-disable max-depth */
1
7
  export async function mergeWithOverride(baseContent, overrideContent) {
2
- let result = baseContent;
8
+ let result = baseContent;
3
9
 
4
- if (!overrideContent.includes('// override')) {
5
- return result;
6
- }
10
+ if (!overrideContent.includes('// override')) {
11
+ return result;
12
+ }
7
13
 
8
- const overrideBlocks = findOverrideBlocks(overrideContent);
9
- for (const block of overrideBlocks) {
10
- result = pasteOverrideInsideEndOfPath(block, result);
11
- if (!block.isObjectOverride) {
12
- // удалить элементы массива при необходимости
13
- result = processArrayOverride(result, block);
14
- }
15
- }
16
- return result;
14
+ const overrideBlocks = findOverrideBlocks(overrideContent);
15
+ for (const block of overrideBlocks) {
16
+ result = pasteOverrideInsideEndOfPath(block, result);
17
+ if (!block.isObjectOverride) {
18
+ // удалить элементы массива при необходимости
19
+ result = processArrayOverride(result, block);
20
+ }
21
+ }
22
+ return result;
17
23
  }
18
24
 
19
25
  function findOverrideBlocks(overrideContent) {
20
- const lines = overrideContent.split('\n');
21
- const overrideBlocks = [];
22
- let currentBlock = null;
23
- let braceCount = 0;
26
+ const lines = overrideContent.split('\n');
27
+ const overrideBlocks = [];
28
+ let currentBlock = null;
29
+ let braceCount = 0;
24
30
 
25
- for (let i = 0; i < lines.length; i++) {
26
- const line = lines[i];
31
+ for (let i = 0; i < lines.length; i++) {
32
+ const line = lines[i];
27
33
 
28
- if (line.includes('// override')) {
29
- currentBlock = {
30
- startLine: i,
31
- lines: [line],
32
- path: [],
33
- isObjectOverride: false,
34
- };
35
- let braceCount2 = 0;
36
- // ищем полный path до override поля
37
- for (let j = i; j !== 0; j--) {
38
- const line2 = lines[j];
39
- braceCount2 += (
40
- line2.match(/{/g)?.length
41
- || line2.match(/\[/g)?.length
42
- || 0
43
- );
44
- braceCount2 -= (
45
- line2.match(/}/g)?.length
46
- || line2.match(/]/g)?.length
47
- || 0
48
- );
49
- if (braceCount2 > 0) {
50
- const fieldName = line2.match(/"([^"]+)"\s*:/)?.[1];
51
- if (fieldName) {
52
- currentBlock.path.unshift(fieldName);
53
- }
54
- braceCount2 = 0;
55
- }
56
- }
57
- continue;
58
- }
34
+ if (line.includes('// override')) {
35
+ currentBlock = {
36
+ startLine: i,
37
+ lines: [line],
38
+ path: [],
39
+ isObjectOverride: false,
40
+ };
41
+ let braceCount2 = 0;
42
+ // ищем полный path до override поля
43
+ for (let j = i; j !== 0; j--) {
44
+ const line2 = lines[j];
45
+ braceCount2 += (
46
+ line2.match(/\{/gu)?.length
47
+ || line2.match(/\[/gu)?.length
48
+ || 0
49
+ );
50
+ braceCount2 -= (
51
+ line2.match(/\}/gu)?.length
52
+ || line2.match(/\]/gu)?.length
53
+ || 0
54
+ );
55
+ if (braceCount2 > 0) {
56
+ const fieldName = line2.match(/"([^"]+)"\s*:/u)?.[1];
57
+ if (fieldName) {
58
+ currentBlock.path.unshift(fieldName);
59
+ }
60
+ braceCount2 = 0;
61
+ }
62
+ }
63
+ continue;
64
+ }
59
65
 
60
- if (currentBlock) {
61
- braceCount += (
62
- line.match(/{/g)?.length
63
- || line.match(/\[/g)?.length
64
- || 0
65
- );
66
- braceCount -= (
67
- line.match(/}/g)?.length
68
- || line.match(/]/g)?.length
69
- || 0
70
- );
71
- if (braceCount < 0) {
72
- if (line.match(/}/g)) {
73
- currentBlock.isObjectOverride = true;
74
- }
75
- // currentBlock.endLine = i + 1
76
- // currentBlock.path = lines.slice(startLine, endLine).join()
77
- overrideBlocks.push(currentBlock);
78
- currentBlock = null;
79
- braceCount = 0;
80
- } else {
81
- currentBlock.lines.push(line);
82
- }
83
- }
84
- }
66
+ if (currentBlock) {
67
+ braceCount += (
68
+ line.match(/\{/gu)?.length
69
+ || line.match(/\[/gu)?.length
70
+ || 0
71
+ );
72
+ braceCount -= (
73
+ line.match(/\}/gu)?.length
74
+ || line.match(/\]/gu)?.length
75
+ || 0
76
+ );
77
+ if (braceCount < 0) {
78
+ if (line.match(/\}/gu)) {
79
+ currentBlock.isObjectOverride = true;
80
+ }
81
+ // currentBlock.endLine = i + 1
82
+ // currentBlock.path = lines.slice(startLine, endLine).join()
83
+ overrideBlocks.push(currentBlock);
84
+ currentBlock = null;
85
+ braceCount = 0;
86
+ } else {
87
+ currentBlock.lines.push(line);
88
+ }
89
+ }
90
+ }
85
91
 
86
- if (currentBlock) {
87
- overrideBlocks.push(currentBlock);
88
- }
92
+ if (currentBlock) {
93
+ overrideBlocks.push(currentBlock);
94
+ }
89
95
 
90
- return overrideBlocks;
96
+ return overrideBlocks;
91
97
  }
92
98
 
93
99
  function processArrayOverride(baseContent, block) {
94
- // Разбиваем на строки
95
- const lines = baseContent.split('\n');
96
- // Копируем только нужный диапазон
97
- const overrideLines = lines.slice(block.startIdx, block.endIdx);
100
+ // Разбиваем на строки
101
+ const lines = baseContent.split('\n');
102
+ // Копируем только нужный диапазон
103
+ const overrideLines = lines.slice(block.startIdx, block.endIdx);
98
104
 
99
- // Обрабатываем override-блок только в этом диапазоне
100
- let processed = overrideLines;
101
- for (const line of block.lines) {
102
- const trimmed = line.trim();
103
- if (trimmed.startsWith('//')) {
104
- const match = trimmed.match(/^\/\/\s*"([^"]+)"/);
105
- if (match) {
106
- const elementToRemove = match[1];
107
- // Удаляем строку с этим элементом только в overrideLines
108
- processed = processed.filter((l) => {
109
- return !l.includes(`"${elementToRemove}"`);
110
- });
111
- }
112
- }
113
- }
105
+ // Обрабатываем override-блок только в этом диапазоне
106
+ let processed = overrideLines;
107
+ for (const line of block.lines) {
108
+ const trimmed = line.trim();
109
+ if (trimmed.startsWith('//')) {
110
+ const match = trimmed.match(/^\/\/\s*"([^"]+)"/u);
111
+ if (match) {
112
+ const elementToRemove = match[1];
113
+ // Удаляем строку с этим элементом только в overrideLines
114
+ processed = processed.filter((line) => {
115
+ return !line.includes(`"${elementToRemove}"`);
116
+ });
117
+ }
118
+ }
119
+ }
114
120
 
115
- // Собираем итоговый массив строк:
116
- const resultLines = [
117
- ...lines.slice(0, block.startIdx),
118
- ...processed,
119
- ...lines.slice(block.endIdx),
120
- ];
121
+ // Собираем итоговый массив строк:
122
+ const resultLines = [
123
+ ...lines.slice(0, block.startIdx),
124
+ ...processed,
125
+ ...lines.slice(block.endIdx),
126
+ ];
121
127
 
122
- return resultLines.join('\n');
128
+ return resultLines.join('\n');
123
129
  }
124
130
 
125
131
  function findEndOfArrOrObj(startIdx, lines, block) {
126
- let braceCount = 0;
127
- for (let i = startIdx; i < lines.length; i++) {
128
- const line = lines[i];
129
- braceCount += (
130
- line.match(/{/g)?.length
131
- || line.match(/\[/g)?.length
132
- || 0
133
- );
134
- braceCount -= (
135
- line.match(/}/g)?.length
136
- || line.match(/]/g)?.length
137
- || 0
138
- );
139
- if (braceCount < 0) {
140
- block.endIdx = i;
141
- return;
142
- }
143
- }
132
+ let braceCount = 0;
133
+ for (let i = startIdx; i < lines.length; i++) {
134
+ const line = lines[i];
135
+ braceCount += (
136
+ line.match(/\{/gu)?.length
137
+ || line.match(/\[/gu)?.length
138
+ || 0
139
+ );
140
+ braceCount -= (
141
+ line.match(/\}/gu)?.length
142
+ || line.match(/\]/gu)?.length
143
+ || 0
144
+ );
145
+ if (braceCount < 0) {
146
+ block.endIdx = i;
147
+ return;
148
+ }
149
+ }
144
150
  }
145
151
 
146
152
  function pasteOverrideInsideEndOfPath(block, result) {
147
- if (block.path.length) {
148
- const resultArr = [];
149
- const lines = result.split('\n');
150
- let pathCount = 0;
151
- for (let i = 0; i < lines.length; i++) {
152
- if (lines[i].includes(block.path[pathCount])) {
153
- if (pathCount !== block.path.length - 1) {
154
- pathCount += 1;
155
- } else {
156
- block.startIdx = i;
157
- findEndOfArrOrObj(i + 1, lines, block);
158
- }
159
- }
160
- if (i === block.endIdx) {
161
- resultArr.push('');
162
- resultArr.push(...block.lines);
163
- }
164
- resultArr.push(lines[i]);
165
- }
153
+ if (block.path.length) {
154
+ const resultArr = [];
155
+ const lines = result.split('\n');
156
+ let pathCount = 0;
157
+ for (let i = 0; i < lines.length; i++) {
158
+ if (lines[i].includes(block.path[pathCount])) {
159
+ if (pathCount !== block.path.length - 1) {
160
+ pathCount += 1;
161
+ } else {
162
+ block.startIdx = i;
163
+ findEndOfArrOrObj(i + 1, lines, block);
164
+ }
165
+ }
166
+ if (i === block.endIdx) {
167
+ resultArr.push('');
168
+ resultArr.push(...block.lines);
169
+ }
170
+ resultArr.push(lines[i]);
171
+ }
166
172
 
167
- return resultArr.join('\n');
168
- }
169
- const lastBraceIndex = result.lastIndexOf('}');
170
- if (lastBraceIndex !== -1) {
171
- const beforeBrace = result.substring(0, lastBraceIndex);
172
- const afterBrace = result.substring(lastBraceIndex);
173
- result = (
174
- `${beforeBrace
175
- }\n${block.lines.join('\n')}\n${
176
- afterBrace}`
177
- );
178
- }
179
- return result;
173
+ return resultArr.join('\n');
174
+ }
175
+ const lastBraceIndex = result.lastIndexOf('}');
176
+ if (lastBraceIndex !== -1) {
177
+ const beforeBrace = result.substring(0, lastBraceIndex);
178
+ const afterBrace = result.substring(lastBraceIndex);
179
+ result = (
180
+ `${beforeBrace
181
+ }\n${block.lines.join('\n')}\n${
182
+ afterBrace}`
183
+ );
184
+ }
185
+ return result;
180
186
  }