@cherepanov.pavel/shareable-config 1.0.13 → 1.0.15

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 (50) hide show
  1. package/.editorconfig-get.js +12 -6
  2. package/.get-all.js +18 -12
  3. package/.gitattributes-get.js +12 -6
  4. package/.gitignore-get.js +28 -14
  5. package/.vscode/.code-snippets-get.js +28 -14
  6. package/.vscode/all-files.code-snippets +3 -1
  7. package/.vscode/extensions.json-get.js +26 -12
  8. package/.vscode/settings.json-get.js +26 -12
  9. package/.vscode/vue.code-snippets +1 -1
  10. package/env.json5.set.js +6 -2
  11. package/jsconfig.json +3 -1
  12. package/package.json +3 -3
  13. package/tools/eslint-config/configs/global.js +15 -9
  14. package/tools/eslint-config/configs/javascript.js +13 -7
  15. package/tools/eslint-config/configs/json.js +115 -57
  16. package/tools/eslint-config/configs/typescript.js +17 -9
  17. package/tools/eslint-config/configs/vue.js +41 -17
  18. package/tools/eslint-config/index.js +15 -5
  19. package/tools/eslint-config/rules/constants.js +1 -1
  20. package/tools/eslint-config/rules/javascript/index.js +6 -2
  21. package/tools/eslint-config/rules/javascript/possible-problems.js +193 -75
  22. package/tools/eslint-config/rules/javascript/suggestions.js +450 -225
  23. package/tools/eslint-config/rules/severity.js +3 -3
  24. package/tools/eslint-config/rules/stylistic/index.js +6 -2
  25. package/tools/eslint-config/rules/stylistic/jsFormatting.js +230 -148
  26. package/tools/eslint-config/rules/stylistic/tsFormatting.js +15 -5
  27. package/tools/eslint-config/rules/typescript/common.js +107 -103
  28. package/tools/eslint-config/rules/typescript/compatibility.js +23 -21
  29. package/tools/eslint-config/rules/typescript/extension.js +52 -46
  30. package/tools/eslint-config/rules/typescript/index.js +9 -3
  31. package/tools/eslint-config/rules/vue/base.js +9 -3
  32. package/tools/eslint-config/rules/vue/extension.js +60 -45
  33. package/tools/eslint-config/rules/vue/formatting.js +63 -35
  34. package/tools/eslint-config/rules/vue/index.js +15 -5
  35. package/tools/eslint-config/rules/vue/possibleProblems.js +272 -124
  36. package/tools/eslint-config/rules/vue/suggestions.js +228 -78
  37. package/tools/stylelint-config/config.js +17 -11
  38. package/tools/stylelint-config/rules/base.js +21 -19
  39. package/tools/stylelint-config/rules/conflicts.js +2 -2
  40. package/tools/stylelint-config/rules/order.js +25 -19
  41. package/tools/stylelint-config/rules/property-groups.js +339 -337
  42. package/tools/stylelint-config/rules/scss.js +6 -4
  43. package/tools/stylelint-config/rules/stylistic.js +84 -82
  44. package/utils/communication.js +3 -3
  45. package/utils/copy-with-override.js +31 -12
  46. package/utils/env.js +10 -6
  47. package/utils/file-header.js +10 -8
  48. package/utils/file.js +22 -14
  49. package/utils/lint.js +11 -3
  50. package/utils/merge.js +14 -12
@@ -1,11 +1,13 @@
1
1
  export default {
2
2
  rules: {
3
3
  /* $-variables */
4
- 'scss/dollar-variable-empty-line-before': [
5
- 'never',
6
- { ignore: 'after-dollar-variable' },
4
+ "scss/dollar-variable-empty-line-before": [
5
+ "never",
6
+ {
7
+ ignore: "after-dollar-variable",
8
+ },
7
9
  ],
8
10
  // https://gitlab.kadnk.ru/frontend/configs/-/issues/1
9
- 'scss/load-partial-extension': 'always',
11
+ "scss/load-partial-extension": "always",
10
12
  },
11
13
  };
@@ -1,125 +1,127 @@
1
- import { INDENT_SIZE } from '../../eslint-config/rules/constants.js';
1
+ import {
2
+ INDENT_SIZE,
3
+ } from "../../eslint-config/rules/constants.js";
2
4
 
3
5
  const MAX_EMPTY_LINES = 1;
4
6
  // const MAX_LINE_LENGTH = 80;
5
7
 
6
- const ALWAYS = 'always';
7
- const ALWAYS_MULTI_LINE = 'always-multi-line';
8
- const ALWAYS_SINGLE_LINE = 'always-single-line';
8
+ const ALWAYS = "always";
9
+ const ALWAYS_MULTI_LINE = "always-multi-line";
10
+ const ALWAYS_SINGLE_LINE = "always-single-line";
9
11
 
10
- const NEVER = 'never';
11
- const NEVER_MULTI_LINE = 'never-multi-line';
12
- const NEVER_SINGLE_LINE = 'never-single-line';
12
+ const NEVER = "never";
13
+ const NEVER_MULTI_LINE = "never-multi-line";
14
+ const NEVER_SINGLE_LINE = "never-single-line";
13
15
 
14
- const LOWER_CASE = 'lower';
16
+ const LOWER_CASE = "lower";
15
17
 
16
18
  export default {
17
19
  rules: {
18
20
  /* == common == */
19
- '@stylistic/indentation': INDENT_SIZE,
20
- '@stylistic/linebreaks': 'unix',
21
- '@stylistic/max-empty-lines': MAX_EMPTY_LINES,
21
+ "@stylistic/indentation": INDENT_SIZE,
22
+ "@stylistic/linebreaks": "unix",
23
+ "@stylistic/max-empty-lines": MAX_EMPTY_LINES,
22
24
  // '@stylistic/max-line-length': [MAX_LINE_LENGTH, { ignorePattern: '/^@(import|use)\\s+/' }],
23
- '@stylistic/no-empty-first-line': true,
24
- '@stylistic/no-eol-whitespace': true,
25
- '@stylistic/no-extra-semicolons': true,
26
- '@stylistic/no-missing-end-of-source-newline': true,
27
- '@stylistic/unicode-bom': NEVER,
25
+ "@stylistic/no-empty-first-line": true,
26
+ "@stylistic/no-eol-whitespace": true,
27
+ "@stylistic/no-extra-semicolons": true,
28
+ "@stylistic/no-missing-end-of-source-newline": true,
29
+ "@stylistic/unicode-bom": NEVER,
28
30
 
29
31
  /* == color == */
30
- '@stylistic/color-hex-case': LOWER_CASE,
32
+ "@stylistic/color-hex-case": LOWER_CASE,
31
33
 
32
34
  /* == function == */
33
- '@stylistic/function-comma-newline-after': ALWAYS_MULTI_LINE,
34
- '@stylistic/function-comma-newline-before': NEVER_MULTI_LINE,
35
- '@stylistic/function-comma-space-after': ALWAYS_SINGLE_LINE,
36
- '@stylistic/function-comma-space-before': NEVER,
37
- '@stylistic/function-max-empty-lines': 0,
38
- '@stylistic/function-parentheses-space-inside': NEVER_SINGLE_LINE,
39
- '@stylistic/function-whitespace-after': ALWAYS,
35
+ "@stylistic/function-comma-newline-after": ALWAYS_MULTI_LINE,
36
+ "@stylistic/function-comma-newline-before": NEVER_MULTI_LINE,
37
+ "@stylistic/function-comma-space-after": ALWAYS_SINGLE_LINE,
38
+ "@stylistic/function-comma-space-before": NEVER,
39
+ "@stylistic/function-max-empty-lines": 0,
40
+ "@stylistic/function-parentheses-space-inside": NEVER_SINGLE_LINE,
41
+ "@stylistic/function-whitespace-after": ALWAYS,
40
42
 
41
43
  /* == number == */
42
- '@stylistic/number-leading-zero': ALWAYS,
43
- '@stylistic/number-no-trailing-zeros': true,
44
+ "@stylistic/number-leading-zero": ALWAYS,
45
+ "@stylistic/number-no-trailing-zeros": true,
44
46
 
45
47
  /* == string == */
46
- '@stylistic/string-quotes': 'double',
48
+ "@stylistic/string-quotes": "double",
47
49
 
48
50
  /* == unit == */
49
- '@stylistic/unit-case': LOWER_CASE,
51
+ "@stylistic/unit-case": LOWER_CASE,
50
52
 
51
53
  /* == value list == */
52
- '@stylistic/value-list-comma-newline-after': ALWAYS_MULTI_LINE,
53
- '@stylistic/value-list-comma-newline-before': NEVER_MULTI_LINE,
54
- '@stylistic/value-list-comma-space-after': ALWAYS_SINGLE_LINE,
55
- '@stylistic/value-list-comma-space-before': NEVER,
56
- '@stylistic/value-list-max-empty-lines': 0,
54
+ "@stylistic/value-list-comma-newline-after": ALWAYS_MULTI_LINE,
55
+ "@stylistic/value-list-comma-newline-before": NEVER_MULTI_LINE,
56
+ "@stylistic/value-list-comma-space-after": ALWAYS_SINGLE_LINE,
57
+ "@stylistic/value-list-comma-space-before": NEVER,
58
+ "@stylistic/value-list-max-empty-lines": 0,
57
59
 
58
60
  /* == property == */
59
- '@stylistic/property-case': LOWER_CASE,
61
+ "@stylistic/property-case": LOWER_CASE,
60
62
 
61
63
  /* == declaration == */
62
- '@stylistic/declaration-bang-space-after': NEVER,
63
- '@stylistic/declaration-bang-space-before': ALWAYS,
64
- '@stylistic/declaration-colon-newline-after': ALWAYS_MULTI_LINE,
65
- '@stylistic/declaration-colon-space-after': ALWAYS_SINGLE_LINE,
66
- '@stylistic/declaration-colon-space-before': NEVER,
64
+ "@stylistic/declaration-bang-space-after": NEVER,
65
+ "@stylistic/declaration-bang-space-before": ALWAYS,
66
+ "@stylistic/declaration-colon-newline-after": ALWAYS_MULTI_LINE,
67
+ "@stylistic/declaration-colon-space-after": ALWAYS_SINGLE_LINE,
68
+ "@stylistic/declaration-colon-space-before": NEVER,
67
69
 
68
70
  /* == declaration block == */
69
- '@stylistic/declaration-block-semicolon-newline-after': ALWAYS,
70
- '@stylistic/declaration-block-semicolon-newline-before': NEVER_MULTI_LINE,
71
- '@stylistic/declaration-block-semicolon-space-after': ALWAYS_SINGLE_LINE,
72
- '@stylistic/declaration-block-semicolon-space-before': NEVER,
73
- '@stylistic/declaration-block-trailing-semicolon': ALWAYS,
71
+ "@stylistic/declaration-block-semicolon-newline-after": ALWAYS,
72
+ "@stylistic/declaration-block-semicolon-newline-before": NEVER_MULTI_LINE,
73
+ "@stylistic/declaration-block-semicolon-space-after": ALWAYS_SINGLE_LINE,
74
+ "@stylistic/declaration-block-semicolon-space-before": NEVER,
75
+ "@stylistic/declaration-block-trailing-semicolon": ALWAYS,
74
76
 
75
77
  /* == block == */
76
- '@stylistic/block-closing-brace-empty-line-before': NEVER,
77
- '@stylistic/block-closing-brace-newline-after': ALWAYS,
78
- '@stylistic/block-closing-brace-newline-before': ALWAYS,
79
- '@stylistic/block-closing-brace-space-after': ALWAYS_SINGLE_LINE,
80
- '@stylistic/block-closing-brace-space-before': ALWAYS_SINGLE_LINE,
81
- '@stylistic/block-opening-brace-newline-after': ALWAYS,
82
- '@stylistic/block-opening-brace-newline-before': null,
83
- '@stylistic/block-opening-brace-space-after': ALWAYS_SINGLE_LINE,
84
- '@stylistic/block-opening-brace-space-before': ALWAYS,
78
+ "@stylistic/block-closing-brace-empty-line-before": NEVER,
79
+ "@stylistic/block-closing-brace-newline-after": ALWAYS,
80
+ "@stylistic/block-closing-brace-newline-before": ALWAYS,
81
+ "@stylistic/block-closing-brace-space-after": ALWAYS_SINGLE_LINE,
82
+ "@stylistic/block-closing-brace-space-before": ALWAYS_SINGLE_LINE,
83
+ "@stylistic/block-opening-brace-newline-after": ALWAYS,
84
+ "@stylistic/block-opening-brace-newline-before": null,
85
+ "@stylistic/block-opening-brace-space-after": ALWAYS_SINGLE_LINE,
86
+ "@stylistic/block-opening-brace-space-before": ALWAYS,
85
87
 
86
88
  /* == selector == */
87
- '@stylistic/selector-attribute-brackets-space-inside': NEVER,
88
- '@stylistic/selector-attribute-operator-space-after': NEVER,
89
- '@stylistic/selector-attribute-operator-space-before': NEVER,
90
- '@stylistic/selector-combinator-space-after': ALWAYS,
91
- '@stylistic/selector-combinator-space-before': ALWAYS,
92
- '@stylistic/selector-descendant-combinator-no-non-space': true,
93
- '@stylistic/selector-max-empty-lines': 0,
94
- '@stylistic/selector-pseudo-class-case': LOWER_CASE,
95
- '@stylistic/selector-pseudo-class-parentheses-space-inside': NEVER,
96
- '@stylistic/selector-pseudo-element-case': LOWER_CASE,
89
+ "@stylistic/selector-attribute-brackets-space-inside": NEVER,
90
+ "@stylistic/selector-attribute-operator-space-after": NEVER,
91
+ "@stylistic/selector-attribute-operator-space-before": NEVER,
92
+ "@stylistic/selector-combinator-space-after": ALWAYS,
93
+ "@stylistic/selector-combinator-space-before": ALWAYS,
94
+ "@stylistic/selector-descendant-combinator-no-non-space": true,
95
+ "@stylistic/selector-max-empty-lines": 0,
96
+ "@stylistic/selector-pseudo-class-case": LOWER_CASE,
97
+ "@stylistic/selector-pseudo-class-parentheses-space-inside": NEVER,
98
+ "@stylistic/selector-pseudo-element-case": LOWER_CASE,
97
99
 
98
100
  /* == selector list == */
99
- '@stylistic/selector-list-comma-newline-after': ALWAYS,
100
- '@stylistic/selector-list-comma-newline-before': NEVER_MULTI_LINE,
101
- '@stylistic/selector-list-comma-space-after': ALWAYS_SINGLE_LINE,
102
- '@stylistic/selector-list-comma-space-before': NEVER,
101
+ "@stylistic/selector-list-comma-newline-after": ALWAYS,
102
+ "@stylistic/selector-list-comma-newline-before": NEVER_MULTI_LINE,
103
+ "@stylistic/selector-list-comma-space-after": ALWAYS_SINGLE_LINE,
104
+ "@stylistic/selector-list-comma-space-before": NEVER,
103
105
 
104
106
  /* == media features == */
105
- '@stylistic/media-feature-colon-space-after': ALWAYS,
106
- '@stylistic/media-feature-colon-space-before': NEVER,
107
- '@stylistic/media-feature-name-case': LOWER_CASE,
108
- '@stylistic/media-feature-parentheses-space-inside': NEVER,
109
- '@stylistic/media-feature-range-operator-space-after': ALWAYS,
110
- '@stylistic/media-feature-range-operator-space-before': ALWAYS,
107
+ "@stylistic/media-feature-colon-space-after": ALWAYS,
108
+ "@stylistic/media-feature-colon-space-before": NEVER,
109
+ "@stylistic/media-feature-name-case": LOWER_CASE,
110
+ "@stylistic/media-feature-parentheses-space-inside": NEVER,
111
+ "@stylistic/media-feature-range-operator-space-after": ALWAYS,
112
+ "@stylistic/media-feature-range-operator-space-before": ALWAYS,
111
113
 
112
114
  /* == media query list == */
113
- '@stylistic/media-query-list-comma-newline-after': ALWAYS_MULTI_LINE,
114
- '@stylistic/media-query-list-comma-newline-before': NEVER_MULTI_LINE,
115
- '@stylistic/media-query-list-comma-space-after': ALWAYS_SINGLE_LINE,
116
- '@stylistic/media-query-list-comma-space-before': NEVER_SINGLE_LINE,
115
+ "@stylistic/media-query-list-comma-newline-after": ALWAYS_MULTI_LINE,
116
+ "@stylistic/media-query-list-comma-newline-before": NEVER_MULTI_LINE,
117
+ "@stylistic/media-query-list-comma-space-after": ALWAYS_SINGLE_LINE,
118
+ "@stylistic/media-query-list-comma-space-before": NEVER_SINGLE_LINE,
117
119
 
118
120
  /* == at rule == */
119
- '@stylistic/at-rule-name-case': LOWER_CASE,
120
- '@stylistic/at-rule-name-newline-after': ALWAYS_MULTI_LINE,
121
- '@stylistic/at-rule-name-space-after': ALWAYS,
122
- '@stylistic/at-rule-semicolon-newline-after': ALWAYS,
123
- '@stylistic/at-rule-semicolon-space-before': NEVER,
121
+ "@stylistic/at-rule-name-case": LOWER_CASE,
122
+ "@stylistic/at-rule-name-newline-after": ALWAYS_MULTI_LINE,
123
+ "@stylistic/at-rule-name-space-after": ALWAYS,
124
+ "@stylistic/at-rule-semicolon-newline-after": ALWAYS,
125
+ "@stylistic/at-rule-semicolon-space-before": NEVER,
124
126
  },
125
127
  };
@@ -1,4 +1,4 @@
1
- import readline from 'readline';
1
+ import readline from "readline";
2
2
 
3
3
  export async function askTypescript() {
4
4
  return new Promise((resolve) => {
@@ -7,7 +7,7 @@ export async function askTypescript() {
7
7
  output: process.stdout,
8
8
  });
9
9
  rl.question(
10
- 'Вы используете typescript? (Enter - нет, любые символы + Enter - да):',
10
+ "Вы используете typescript? (Enter - нет, любые символы + Enter - да):",
11
11
  (answer) => {
12
12
  rl.close();
13
13
  resolve(Boolean(answer.trim().toLowerCase()));
@@ -23,7 +23,7 @@ export async function askFramework() {
23
23
  output: process.stdout,
24
24
  });
25
25
  rl.question(
26
- 'Какой фреймворк вы используете? (vue/nuxt/quasar, нажмите Enter, чтобы скопировать только framework-less): ',
26
+ "Какой фреймворк вы используете? (vue/nuxt/quasar, нажмите Enter, чтобы скопировать только framework-less): ",
27
27
  (answer) => {
28
28
  rl.close();
29
29
  resolve(answer.trim().toLowerCase());
@@ -1,34 +1,53 @@
1
- import { readFile } from 'fs/promises';
2
- import { getHeader } from '../utils/file-header.js';
3
- import { outputFile } from 'fs-extra';
1
+ import {
2
+ readFile,
3
+ } from "fs/promises";
4
+ import {
5
+ getHeader,
6
+ } from "../utils/file-header.js";
7
+ import {
8
+ outputFile,
9
+ } from "fs-extra";
4
10
 
5
- export async function copyFile({ destFile, srcFileData, fileLabel }) {
11
+ export async function copyFile({
12
+ destFile, srcFileData, fileLabel,
13
+ }) {
6
14
  // Если файла нет — просто создаём его
7
15
  try {
8
- await readFile(destFile, 'utf8');
16
+ await readFile(destFile, "utf8");
9
17
  } catch {
10
- await outputFile(destFile, `${getHeader('#')}${srcFileData}`);
18
+ await outputFile(destFile, `${getHeader("#")}${srcFileData}`);
11
19
  console.info(`${fileLabel} пересоздан`);
12
20
  return {};
13
21
  }
14
22
 
15
23
  // Если файл есть — разбираем оба файла
16
- const destFileData = await readFile(destFile, 'utf8');
24
+ const destFileData = await readFile(destFile, "utf8");
17
25
  // Ищем строку override (без учёта регистра)
18
26
  const overrideRegex = /^# override.*$/imu;
19
27
  const match = destFileData.match(overrideRegex);
20
28
  if (!match) {
21
- await outputFile(destFile, `${getHeader('#')}${srcFileData}`);
29
+ await outputFile(destFile, `${getHeader("#")}${srcFileData}`);
22
30
  console.info(`${fileLabel} пересоздан`);
23
31
  return {};
24
32
  }
25
33
 
26
- return { destFileData, match };
34
+ return {
35
+ destFileData,
36
+ match,
37
+ };
27
38
  }
28
39
 
29
- export async function copyWithOverride({ destFile, srcFileData, fileLabel = '' }) {
40
+ export async function copyWithOverride({
41
+ destFile, srcFileData, fileLabel = "",
42
+ }) {
30
43
  try {
31
- const { destFileData, match } = await copyFile({ destFile, srcFileData, fileLabel });
44
+ const {
45
+ destFileData, match,
46
+ } = await copyFile({
47
+ destFile,
48
+ srcFileData,
49
+ fileLabel,
50
+ });
32
51
  if (!destFileData) {
33
52
  return;
34
53
  }
@@ -37,7 +56,7 @@ export async function copyWithOverride({ destFile, srcFileData, fileLabel = '' }
37
56
  const preserved = destFileData.slice(overrideIndex);
38
57
  const newContent = `${srcFileData.trimEnd()}\n\n${preserved.trimStart()}`;
39
58
 
40
- await outputFile(destFile, `${getHeader('#')}${newContent}`);
59
+ await outputFile(destFile, `${getHeader("#")}${newContent}`);
41
60
  console.info(`${fileLabel} обновлён с учётом override`);
42
61
  } catch (err) {
43
62
  console.error(`Ошибка копирования ${fileLabel}:`, err.message);
package/utils/env.js CHANGED
@@ -1,12 +1,16 @@
1
- import { readFile } from 'fs/promises';
2
- import path from 'path';
3
- import JSON5 from 'json5';
4
- import { outputFile } from 'fs-extra';
1
+ import {
2
+ readFile,
3
+ } from "fs/promises";
4
+ import path from "path";
5
+ import JSON5 from "json5";
6
+ import {
7
+ outputFile,
8
+ } from "fs-extra";
5
9
 
6
- const envFileSrc = path.join(process.cwd(), 'frontend-configs.env.json5');
10
+ const envFileSrc = path.join(process.cwd(), "frontend-configs.env.json5");
7
11
 
8
12
  export async function getEnvs() {
9
- const srcFileData = await readFile(envFileSrc, 'utf8');
13
+ const srcFileData = await readFile(envFileSrc, "utf8");
10
14
  const parsedSrcFileData = JSON5.parse(srcFileData);
11
15
  return parsedSrcFileData;
12
16
  }
@@ -1,16 +1,18 @@
1
- import { readFile } from 'fs/promises';
1
+ import {
2
+ readFile,
3
+ } from "fs/promises";
2
4
 
3
- const pkg = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
5
+ const pkg = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
4
6
 
5
- export function getHeader(comment = '//') {
7
+ export function getHeader(comment = "//") {
6
8
  const lines = [
7
- 'This file is generated with',
8
- `${pkg.repository?.url || ''}`,
9
- `Version: ${pkg.version || ''}`,
10
- 'File may contain override sections, see project README for more details',
9
+ "This file is generated with",
10
+ `${pkg.repository?.url || ""}`,
11
+ `Version: ${pkg.version || ""}`,
12
+ "File may contain override sections, see project README for more details",
11
13
  ];
12
14
 
13
15
  return `${lines.map((line) => {
14
16
  return `${comment} ${line}`.trim();
15
- }).join('\n')}\n`;
17
+ }).join("\n")}\n`;
16
18
  }
package/utils/file.js CHANGED
@@ -1,12 +1,18 @@
1
- import { fileURLToPath } from 'url';
2
- import path from 'path';
3
- import { readFile } from 'fs/promises';
4
- import JSON5 from 'json5';
1
+ import {
2
+ fileURLToPath,
3
+ } from "url";
4
+ import path from "path";
5
+ import {
6
+ readFile,
7
+ } from "fs/promises";
8
+ import JSON5 from "json5";
5
9
 
6
- export async function getSrcFileData({ fileName }) {
10
+ export async function getSrcFileData({
11
+ fileName,
12
+ }) {
7
13
  const dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const src = path.join(dirname, '..', '.vscode', fileName);
9
- const srcFileData = await readFile(src, 'utf8');
14
+ const src = path.join(dirname, "..", ".vscode", fileName);
15
+ const srcFileData = await readFile(src, "utf8");
10
16
 
11
17
  return srcFileData;
12
18
  }
@@ -16,26 +22,28 @@ export async function getSrcJSONFileData({
16
22
  isTs = false,
17
23
  removeDuplicateKeys = false,
18
24
  }) {
19
- const srcFileData = await getSrcFileData({ fileName });
25
+ const srcFileData = await getSrcFileData({
26
+ fileName,
27
+ });
20
28
 
21
29
  // Если есть нет typescript, нет лишних проблем, возвращаем
22
- if (!srcFileData.includes('// typescript')) {
30
+ if (!srcFileData.includes("// typescript")) {
23
31
  return srcFileData;
24
32
  }
25
33
 
26
- const lines = srcFileData.split('\n');
34
+ const lines = srcFileData.split("\n");
27
35
  const result = [];
28
36
  let nextLineIsTypescript = false;
29
37
  let nextLineIsTypescriptMultiline = false;
30
38
 
31
39
  lines.forEach((line) => {
32
40
  // если следующая строка typescript only
33
- if (line.includes('// typescript')) {
41
+ if (line.includes("// typescript")) {
34
42
  // если несколько следующих строк typescript only
35
- if (line.includes('// typescript multiline')) {
43
+ if (line.includes("// typescript multiline")) {
36
44
  // проверяем это конец multiline typescript комментария, или начало, и в соответствии
37
45
  // с этим ставим флаг
38
- nextLineIsTypescriptMultiline = !(line.includes('// typescript multiline end'));
46
+ nextLineIsTypescriptMultiline = !(line.includes("// typescript multiline end"));
39
47
  } else {
40
48
  nextLineIsTypescript = true; // Следующая строка будет typescript-only
41
49
  }
@@ -55,7 +63,7 @@ export async function getSrcJSONFileData({
55
63
  }
56
64
  });
57
65
 
58
- const stringResult = result.join('\n');
66
+ const stringResult = result.join("\n");
59
67
  if (removeDuplicateKeys) {
60
68
  return JSON.stringify(JSON5.parse(stringResult), null, 2);
61
69
  }
package/utils/lint.js CHANGED
@@ -1,10 +1,18 @@
1
- import { exec } from 'node:child_process';
2
- import { promisify } from 'node:util';
1
+ import {
2
+ exec,
3
+ } from "node:child_process";
4
+ import {
5
+ promisify,
6
+ } from "node:util";
3
7
 
4
8
  const execAsync = promisify(exec);
5
9
  // filePaths: string | string[]
6
10
  export async function eslintFiles(filePaths) {
7
- const paths = Array.isArray(filePaths) ? filePaths : [filePaths];
11
+ const paths = Array.isArray(filePaths)
12
+ ? filePaths
13
+ : [
14
+ filePaths,
15
+ ];
8
16
 
9
17
  const promises = paths.map(async (path) => {
10
18
  return execAsync(`eslint ${path} --fix`);
package/utils/merge.js CHANGED
@@ -7,7 +7,7 @@
7
7
  export async function mergeWithOverride(baseContent, overrideContent) {
8
8
  let result = baseContent;
9
9
 
10
- if (!overrideContent.includes('// override')) {
10
+ if (!overrideContent.includes("// override")) {
11
11
  return result;
12
12
  }
13
13
 
@@ -23,7 +23,7 @@ export async function mergeWithOverride(baseContent, overrideContent) {
23
23
  }
24
24
 
25
25
  function findOverrideBlocks(overrideContent) {
26
- const lines = overrideContent.split('\n');
26
+ const lines = overrideContent.split("\n");
27
27
  const overrideBlocks = [];
28
28
  let currentBlock = null;
29
29
  let braceCount = 0;
@@ -31,10 +31,12 @@ function findOverrideBlocks(overrideContent) {
31
31
  for (let i = 0; i < lines.length; i++) {
32
32
  const line = lines[i];
33
33
 
34
- if (line.includes('// override')) {
34
+ if (line.includes("// override")) {
35
35
  currentBlock = {
36
36
  startLine: i,
37
- lines: [line],
37
+ lines: [
38
+ line,
39
+ ],
38
40
  path: [],
39
41
  isObjectOverride: false,
40
42
  };
@@ -98,7 +100,7 @@ function findOverrideBlocks(overrideContent) {
98
100
 
99
101
  function processArrayOverride(baseContent, block) {
100
102
  // Разбиваем на строки
101
- const lines = baseContent.split('\n');
103
+ const lines = baseContent.split("\n");
102
104
  // Копируем только нужный диапазон
103
105
  const overrideLines = lines.slice(block.startIdx, block.endIdx);
104
106
 
@@ -106,7 +108,7 @@ function processArrayOverride(baseContent, block) {
106
108
  let processed = overrideLines;
107
109
  for (const line of block.lines) {
108
110
  const trimmed = line.trim();
109
- if (trimmed.startsWith('//')) {
111
+ if (trimmed.startsWith("//")) {
110
112
  const match = trimmed.match(/^\/\/\s*"([^"]+)"/u);
111
113
  if (match) {
112
114
  const elementToRemove = match[1];
@@ -125,7 +127,7 @@ function processArrayOverride(baseContent, block) {
125
127
  ...lines.slice(block.endIdx),
126
128
  ];
127
129
 
128
- return resultLines.join('\n');
130
+ return resultLines.join("\n");
129
131
  }
130
132
 
131
133
  function findEndOfArrOrObj(startIdx, lines, block) {
@@ -152,7 +154,7 @@ function findEndOfArrOrObj(startIdx, lines, block) {
152
154
  function pasteOverrideInsideEndOfPath(block, result) {
153
155
  if (block.path.length) {
154
156
  const resultArr = [];
155
- const lines = result.split('\n');
157
+ const lines = result.split("\n");
156
158
  let pathCount = 0;
157
159
  for (let i = 0; i < lines.length; i++) {
158
160
  if (lines[i].includes(block.path[pathCount])) {
@@ -164,21 +166,21 @@ function pasteOverrideInsideEndOfPath(block, result) {
164
166
  }
165
167
  }
166
168
  if (i === block.endIdx) {
167
- resultArr.push('');
169
+ resultArr.push("");
168
170
  resultArr.push(...block.lines);
169
171
  }
170
172
  resultArr.push(lines[i]);
171
173
  }
172
174
 
173
- return resultArr.join('\n');
175
+ return resultArr.join("\n");
174
176
  }
175
- const lastBraceIndex = result.lastIndexOf('}');
177
+ const lastBraceIndex = result.lastIndexOf("}");
176
178
  if (lastBraceIndex !== -1) {
177
179
  const beforeBrace = result.substring(0, lastBraceIndex);
178
180
  const afterBrace = result.substring(lastBraceIndex);
179
181
  result = (
180
182
  `${beforeBrace
181
- }\n${block.lines.join('\n')}\n${
183
+ }\n${block.lines.join("\n")}\n${
182
184
  afterBrace}`
183
185
  );
184
186
  }