@cherepanov.pavel/shareable-config 1.0.26 → 2.0.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.
Files changed (48) hide show
  1. package/.editorconfig-get.js +1 -1
  2. package/.gitattributes-get.js +1 -1
  3. package/.gitignore-get.js +14 -5
  4. package/.vscode/.code-snippets-get.js +7 -6
  5. package/.vscode/extensions.json-get.js +10 -9
  6. package/.vscode/settings.json-get.js +10 -9
  7. package/README.md +25 -16
  8. package/env.json5.set.js +8 -3
  9. package/{tools → modules}/eslint-config/configs/json.js +1 -1
  10. package/{tools → modules}/eslint-config/configs/vue.js +1 -1
  11. package/{tools → modules}/eslint-config/rules/javascript/possible-problems.js +1 -1
  12. package/{tools → modules}/eslint-config/rules/javascript/suggestions.js +1 -1
  13. package/{tools → modules}/eslint-config/rules/stylistic/jsFormatting.js +2 -2
  14. package/{tools → modules}/eslint-config/rules/stylistic/tsFormatting.js +1 -1
  15. package/{tools → modules}/eslint-config/rules/typescript/common.js +1 -1
  16. package/{tools → modules}/eslint-config/rules/typescript/compatibility.js +1 -1
  17. package/{tools → modules}/eslint-config/rules/typescript/extension.js +1 -1
  18. package/{tools → modules}/eslint-config/rules/vue/base.js +1 -1
  19. package/{tools → modules}/eslint-config/rules/vue/extension.js +2 -2
  20. package/{tools → modules}/eslint-config/rules/vue/formatting.js +2 -2
  21. package/{tools → modules}/eslint-config/rules/vue/index.js +1 -1
  22. package/{tools → modules}/eslint-config/rules/vue/options-api.js +1 -1
  23. package/{tools → modules}/eslint-config/rules/vue/possible-problems.js +1 -1
  24. package/{tools → modules}/eslint-config/rules/vue/suggestions.js +1 -1
  25. package/{utils → modules/shared/utils}/copy-with-override.js +1 -1
  26. package/{utils → modules/shared/utils}/env.js +1 -1
  27. package/{utils → modules/shared/utils}/file-header.js +10 -4
  28. package/{utils → modules/shared/utils}/file.js +5 -26
  29. package/{utils → modules/shared/utils}/lint.js +4 -0
  30. package/{tools/stylelint-config/config.js → modules/stylelint-config/index.js} +1 -1
  31. package/{tools → modules}/stylelint-config/rules/stylistic.js +1 -1
  32. package/modules/utils/index.js +51 -0
  33. package/package.json +9 -4
  34. /package/{tools → modules}/eslint-config/configs/global.js +0 -0
  35. /package/{tools → modules}/eslint-config/configs/javascript.js +0 -0
  36. /package/{tools → modules}/eslint-config/configs/typescript.js +0 -0
  37. /package/{tools/eslint-config/rules/constants.js → modules/eslint-config/constants/rules.js} +0 -0
  38. /package/{tools/eslint-config/rules → modules/eslint-config/constants}/severity.js +0 -0
  39. /package/{tools → modules}/eslint-config/index.js +0 -0
  40. /package/{tools → modules}/eslint-config/rules/javascript/index.js +0 -0
  41. /package/{tools → modules}/eslint-config/rules/stylistic/index.js +0 -0
  42. /package/{tools → modules}/eslint-config/rules/typescript/index.js +0 -0
  43. /package/{utils → modules/shared/utils}/communication.js +0 -0
  44. /package/{utils → modules/shared/utils}/merge.js +0 -0
  45. /package/{tools → modules}/stylelint-config/rules/base.js +0 -0
  46. /package/{tools → modules}/stylelint-config/rules/conflicts.js +0 -0
  47. /package/{tools → modules}/stylelint-config/rules/order.js +0 -0
  48. /package/{tools → modules}/stylelint-config/rules/property-groups.js +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  } from "url";
7
7
  import {
8
8
  copyWithOverride,
9
- } from "./utils/copy-with-override.js";
9
+ } from "./modules/shared/utils/copy-with-override.js";
10
10
  import {
11
11
  readFile,
12
12
  } from "fs/promises";
@@ -6,7 +6,7 @@ import {
6
6
  } from "url";
7
7
  import {
8
8
  copyWithOverride,
9
- } from "./utils/copy-with-override.js";
9
+ } from "./modules/shared/utils/copy-with-override.js";
10
10
  import {
11
11
  readFile,
12
12
  } from "fs/promises";
package/.gitignore-get.js CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  } from "fs/promises";
10
10
  import {
11
11
  copyWithOverride,
12
- } from "./utils/copy-with-override.js";
12
+ } from "./modules/shared/utils/copy-with-override.js";
13
13
  import {
14
14
  getEnvs,
15
- } from "./utils/env.js";
15
+ } from "./modules/shared/utils/env.js";
16
16
 
17
17
  const fileName = ".gitignore";
18
18
  const destFile = path.join(process.cwd(), fileName);
@@ -30,12 +30,17 @@ async function getGitignoreFileData(framework) {
30
30
  return commonData.trim();
31
31
  }
32
32
 
33
- const sections = srcFileData.split(/^#\s*/mu).slice(1);
33
+ const sections = srcFileData.split(/^#\s*/mu)
34
+ .slice(1);
34
35
  const matchedSection = sections.find((section) => {
35
36
  const [
36
37
  header,
37
38
  ] = section.split("\n");
38
- return header.trim().toLowerCase() === framework;
39
+ return (
40
+ header
41
+ .trim()
42
+ .toLowerCase()
43
+ ) === framework;
39
44
  });
40
45
 
41
46
  if (matchedSection) {
@@ -43,7 +48,11 @@ async function getGitignoreFileData(framework) {
43
48
  header,
44
49
  ...body
45
50
  ] = matchedSection.split("\n");
46
- return `${commonData.trim()}\n\n# ${header}\n${body.join("\n").trim()}`.trim();
51
+ return `${commonData.trim()}\n\n# ${header}\n${
52
+ body
53
+ .join("\n")
54
+ .trim()
55
+ }`.trim();
47
56
  }
48
57
  // Если не найдено — только общий контент
49
58
  return commonData.trim();
@@ -9,19 +9,19 @@ import {
9
9
  } from "fs-extra";
10
10
  import {
11
11
  mergeWithOverride,
12
- } from "../utils/merge.js";
12
+ } from "../modules/shared/utils/merge.js";
13
13
  import {
14
14
  getHeader,
15
- } from "../utils/file-header.js";
15
+ } from "../modules/shared/utils/file-header.js";
16
16
  import {
17
17
  getSrcJSONFileData,
18
- } from "../utils/file.js";
18
+ } from "../modules/shared/utils/file.js";
19
19
  import {
20
20
  getEnvs,
21
- } from "../utils/env.js";
21
+ } from "../modules/shared/utils/env.js";
22
22
  import {
23
23
  eslintFiles,
24
- } from "../utils/lint.js";
24
+ } from "../modules/shared/utils/lint.js";
25
25
 
26
26
  const fileNames = [
27
27
  "vue.code-snippets",
@@ -34,8 +34,9 @@ try {
34
34
  } = await getEnvs();
35
35
 
36
36
  fileNames.forEach(async (fileName) => {
37
+ const srcFile = path.join(import.meta.dirname, fileName);
37
38
  const srcFileData = await getSrcJSONFileData({
38
- fileName,
39
+ fileData: await readFile(srcFile, "utf8"),
39
40
  isTs,
40
41
  removeDuplicateKeys: fileName === "vue.code-snippets",
41
42
  });
@@ -6,22 +6,22 @@ import {
6
6
  } from "fs/promises";
7
7
  import {
8
8
  getSrcJSONFileData,
9
- } from "../utils/file.js";
9
+ } from "../modules/shared/utils/file.js";
10
10
  import {
11
11
  mergeWithOverride,
12
- } from "../utils/merge.js";
12
+ } from "../modules/shared/utils/merge.js";
13
13
  import {
14
14
  getHeader,
15
- } from "../utils/file-header.js";
15
+ } from "../modules/shared/utils/file-header.js";
16
16
  import {
17
17
  getEnvs,
18
- } from "../utils/env.js";
18
+ } from "../modules/shared/utils/env.js";
19
19
  import {
20
20
  outputFile,
21
21
  } from "fs-extra";
22
22
  import {
23
23
  eslintFiles,
24
- } from "../utils/lint.js";
24
+ } from "../modules/shared/utils/lint.js";
25
25
 
26
26
  const fileName = "extensions.json";
27
27
  const destFile = path.join(process.cwd(), `.vscode/${fileName}`);
@@ -30,8 +30,9 @@ try {
30
30
  const {
31
31
  isRepositoryUseTypescript: isTs,
32
32
  } = await getEnvs();
33
- const baseContent = await getSrcJSONFileData({
34
- fileName,
33
+ const srcFile = path.join(import.meta.dirname, fileName);
34
+ const srcFileData = await getSrcJSONFileData({
35
+ fileData: await readFile(srcFile, "utf8"),
35
36
  isTs,
36
37
  });
37
38
  let overrideContent;
@@ -42,9 +43,9 @@ try {
42
43
 
43
44
  let result;
44
45
  if (overrideContent) {
45
- result = await mergeWithOverride(baseContent, overrideContent);
46
+ result = await mergeWithOverride(srcFileData, overrideContent);
46
47
  } else {
47
- result = baseContent;
48
+ result = srcFileData;
48
49
  }
49
50
 
50
51
  await outputFile(destFile, `${getHeader()}${result}`);
@@ -6,22 +6,22 @@ import {
6
6
  } from "fs/promises";
7
7
  import {
8
8
  getSrcJSONFileData,
9
- } from "../utils/file.js";
9
+ } from "../modules/shared/utils/file.js";
10
10
  import {
11
11
  mergeWithOverride,
12
- } from "../utils/merge.js";
12
+ } from "../modules/shared/utils/merge.js";
13
13
  import {
14
14
  getHeader,
15
- } from "../utils/file-header.js";
15
+ } from "../modules/shared/utils/file-header.js";
16
16
  import {
17
17
  getEnvs,
18
- } from "../utils/env.js";
18
+ } from "../modules/shared/utils/env.js";
19
19
  import {
20
20
  outputFile,
21
21
  } from "fs-extra";
22
22
  import {
23
23
  eslintFiles,
24
- } from "../utils/lint.js";
24
+ } from "../modules/shared/utils/lint.js";
25
25
 
26
26
  const fileName = "settings.json";
27
27
  const destFile = path.join(process.cwd(), `.vscode/${fileName}`);
@@ -30,8 +30,9 @@ try {
30
30
  const {
31
31
  isRepositoryUseTypescript: isTs,
32
32
  } = await getEnvs();
33
- const baseContent = await getSrcJSONFileData({
34
- fileName,
33
+ const srcFile = path.join(import.meta.dirname, fileName);
34
+ const srcFileData = await getSrcJSONFileData({
35
+ fileData: await readFile(srcFile, "utf8"),
35
36
  isTs,
36
37
  });
37
38
  let overrideContent;
@@ -42,9 +43,9 @@ try {
42
43
 
43
44
  let result;
44
45
  if (overrideContent) {
45
- result = await mergeWithOverride(baseContent, overrideContent);
46
+ result = await mergeWithOverride(srcFileData, overrideContent);
46
47
  } else {
47
- result = baseContent;
48
+ result = srcFileData;
48
49
  }
49
50
 
50
51
  await outputFile(destFile, `${getHeader()}${result}`);
package/README.md CHANGED
@@ -2,18 +2,18 @@
2
2
 
3
3
  👉 **If you want to integrate these configs into Quasar, be sure to read the [Quasar integration specifics](#quasar-integration-notes) section below!**
4
4
 
5
- **This repository is intended to standardize and centralize formatting and linting across all of my projects.**
5
+ **This repository is intended to standardize and centralize formatting and linting across all of my projects.**
6
6
  You can always override any rules to suit a specific project's needs.
7
7
 
8
8
  ---
9
9
 
10
10
  ## Quick Start
11
11
 
12
- **IMPORTANT!**
13
- Before installing this package, remove `eslint`, `stylelint`, `@stylistic/*`, `@typescript-eslint/*` and any other linting/formatting-related packages from your project.
12
+ **IMPORTANT!**
13
+ Before installing this package, remove `eslint`, `stylelint`, `@stylistic/*`, `@typescript-eslint/*` and any other linting/formatting-related packages from your project.
14
14
  The correct versions of those dependencies will be installed automatically when you install this package.
15
15
 
16
- **IMPORTANT!**
16
+ **IMPORTANT!**
17
17
  As you'll see further down in this README, the project is flexible and supports overrides at every level.
18
18
 
19
19
  1. **Open the target project.**
@@ -37,11 +37,11 @@ As you'll see further down in this README, the project is flexible and supports
37
37
  Before:
38
38
  ```js
39
39
  import {
40
- globalConfig,
41
- jsConfig,
42
- tsConfig,
43
- vueConfig,
44
- } from './tools/eslint-config/index.js';
40
+ ...
41
+ } from "./modules/eslint-config";
42
+ import {
43
+ ...
44
+ } from "./modules/eslint-config/constants/severity.js";
45
45
  ```
46
46
 
47
47
  After:
@@ -51,17 +51,26 @@ import {
51
51
  jsConfig,
52
52
  tsConfig,
53
53
  vueConfig,
54
- } from '@cherepanov.pavel/shareable-config/tools/eslint-config/index.js';
54
+ } from '@cherepanov.pavel/shareable-config/eslint-config';
55
+ import {
56
+ OFF,
57
+ WARN,
58
+ ERROR,
59
+ } from '@cherepanov.pavel/shareable-config/eslint-config/constants/severity.js';
55
60
  ```
56
61
 
57
62
  Before:
58
63
  ```js
59
- import baseConfig from './tools/stylelint-config/config.js';
64
+ import {
65
+ baseConfig,
66
+ } from "./modules/stylelint-config";
60
67
  ```
61
68
 
62
69
  After:
63
70
  ```js
64
- import baseConfig from '@cherepanov.pavel/shareable-config/tools/stylelint-config/config.js';
71
+ import {
72
+ baseConfig
73
+ } from '@cherepanov.pavel/shareable-config/stylelint-config';
65
74
  ```
66
75
 
67
76
  5. **Override rules via the `override` function in your own configs where needed.**
@@ -78,7 +87,7 @@ import baseConfig from '@cherepanov.pavel/shareable-config/tools/stylelint-confi
78
87
  - `extensions.json`
79
88
  - `settings.json`
80
89
 
81
- After installing the package, run:
90
+ Once you have completed the Quick Start steps, run:
82
91
  ```sh
83
92
  npx -p "@cherepanov.pavel/shareable-config" set-env
84
93
  ```
@@ -177,8 +186,8 @@ After:
177
186
 
178
187
  ## Summary
179
188
 
180
- Use this repository as a single source for configs.
181
- Only override what you need using the override mechanism.
189
+ Use this repository as a single source for configs.
190
+ Only override what you need using the override mechanism.
182
191
  Receive updates without losing your custom changes.
183
192
 
184
193
  ---
@@ -230,4 +239,4 @@ Quasar projects typically don't have `type: "module"` in `package.json` by defau
230
239
  - `stylelint.config.js` → `stylelint.config.mjs`
231
240
  - `eslint.config.js` → `eslint.config.mjs`
232
241
 
233
- or use the `.mts` extension for TypeScript-based configs.
242
+ or use the `.mts` extension for TypeScript-based configs.
package/env.json5.set.js CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  import {
4
4
  askFramework, askOptionsApi, askTypescript,
5
- } from "./utils/communication.js";
5
+ } from "./modules/shared/utils/communication.js";
6
6
  import {
7
- getEnvs, setEnvs,
8
- } from "./utils/env.js";
7
+ getEnvs, setEnvs, envFileSrc,
8
+ } from "./modules/shared/utils/env.js";
9
+ import {
10
+ eslintFiles,
11
+ } from "./modules/shared/utils/lint.js";
9
12
 
10
13
  let envs = {};
11
14
  try {
@@ -17,3 +20,5 @@ envs.repositoryFramework = await askFramework();
17
20
  envs.isRepositoryUseOptionsApi = await askOptionsApi();
18
21
 
19
22
  await setEnvs(envs);
23
+
24
+ await eslintFiles(envFileSrc);
@@ -4,7 +4,7 @@ import {
4
4
  import jsonc from "eslint-plugin-jsonc";
5
5
  import {
6
6
  ERROR,
7
- } from "../rules/severity.js";
7
+ } from "../constants/severity.js";
8
8
  import {
9
9
  jsFormatting,
10
10
  } from "../rules/stylistic/index.js";
@@ -20,7 +20,7 @@ import vueParser from "vue-eslint-parser";
20
20
  import tsParser from "@typescript-eslint/parser";
21
21
  import {
22
22
  getEnvs,
23
- } from "../../../utils/env.js";
23
+ } from "../../shared/utils/env.js";
24
24
 
25
25
  // https://github.com/sveltejs/eslint-plugin-svelte/issues/152#issuecomment-1150803175
26
26
  const {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ERROR, WARN,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  export const possibleProblemRules = {
6
6
  "array-callback-return": [
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ERROR, OFF, WARN,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  export const suggestionRules = {
6
6
  "accessor-pairs": [
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  TAB_WIDTH, MAX_LEN, INDENT_SIZE,
3
- } from "../constants.js";
3
+ } from "../../constants/rules.js";
4
4
  import {
5
5
  ERROR, OFF,
6
- } from "../severity.js";
6
+ } from "../../constants/severity.js";
7
7
 
8
8
  /* == formatting rules for javascript == */
9
9
  export default {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ERROR,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  /* == formatting rules for typescript == */
6
6
  export default {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ERROR, OFF, WARN,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  export const commonRules = {
6
6
  "@typescript-eslint/adjacent-overload-signatures": ERROR,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ERROR, OFF,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  export const compatibilityRules = {
6
6
  "constructor-super": OFF, // ts(2335) & ts(2377)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OFF,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  import {
6
6
  suggestionRules,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ERROR, OFF,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  export const baseRules = {
6
6
  "vue/comment-directive": [
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ERROR, OFF,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
  import {
5
5
  MAX_LEN,
6
- } from "../constants.js";
6
+ } from "../../constants/rules.js";
7
7
 
8
8
  import {
9
9
  possibleProblemRules,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  INDENT_SIZE,
3
- } from "../constants.js";
3
+ } from "../../constants/rules.js";
4
4
  import {
5
5
  ERROR, OFF,
6
- } from "../severity.js";
6
+ } from "../../constants/severity.js";
7
7
 
8
8
  export const formattingRules = {
9
9
  "vue/block-tag-newline": [
@@ -15,7 +15,7 @@ import {
15
15
  } from "./formatting.js";
16
16
  import {
17
17
  getEnvs,
18
- } from "../../../../utils/env.js";
18
+ } from "../../../shared/utils/env.js";
19
19
  import {
20
20
  optionsApiRules,
21
21
  } from "./options-api.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ERROR,
3
3
  OFF,
4
- } from "../severity.js";
4
+ } from "../../constants/severity.js";
5
5
 
6
6
  export const optionsApiRules = {
7
7
  "vue/component-api-style": [
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ERROR, OFF, WARN,
3
- } from "../severity.js";
3
+ } from "../../constants/severity.js";
4
4
 
5
5
  export const possibleProblemRules = {
6
6
  "vue/attribute-hyphenation": [
@@ -3,7 +3,7 @@ import {
3
3
  } from "../javascript/possible-problems.js";
4
4
  import {
5
5
  ERROR, OFF,
6
- } from "../severity.js";
6
+ } from "../../constants/severity.js";
7
7
 
8
8
  export const suggestionRules = {
9
9
  "vue/match-component-import-name": [
@@ -3,7 +3,7 @@ import {
3
3
  } from "fs/promises";
4
4
  import {
5
5
  getHeader,
6
- } from "../utils/file-header.js";
6
+ } from "./file-header.js";
7
7
  import {
8
8
  outputFile,
9
9
  } from "fs-extra";
@@ -7,7 +7,7 @@ import {
7
7
  outputFile,
8
8
  } from "fs-extra";
9
9
 
10
- const envFileSrc = path.join(process.cwd(), "frontend-configs.env.json5");
10
+ export const envFileSrc = path.join(process.cwd(), "frontend-configs.env.json5");
11
11
 
12
12
  export async function getEnvs() {
13
13
  const srcFileData = await readFile(envFileSrc, "utf8");
@@ -1,8 +1,10 @@
1
+ /* eslint-disable prefer-template */
1
2
  import {
2
3
  readFile,
3
4
  } from "fs/promises";
4
5
 
5
- const pkg = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
6
+ const pkgJsonFileUrl = new URL("../../../package.json", import.meta.url);
7
+ const pkg = JSON.parse(await readFile(pkgJsonFileUrl, "utf8"));
6
8
 
7
9
  export function getHeader(comment = "//") {
8
10
  const lines = [
@@ -12,7 +14,11 @@ export function getHeader(comment = "//") {
12
14
  "File may contain override sections, see project README for more details",
13
15
  ];
14
16
 
15
- return `${lines.map((line) => {
16
- return `${comment} ${line}`.trim();
17
- }).join("\n")}\n`;
17
+ return (
18
+ lines.map((line) => {
19
+ return `${comment} ${line}`.trim();
20
+ })
21
+ .join("\n")
22
+ + "\n"
23
+ );
18
24
  }
@@ -1,37 +1,16 @@
1
- import {
2
- fileURLToPath,
3
- } from "url";
4
- import path from "path";
5
- import {
6
- readFile,
7
- } from "fs/promises";
8
1
  import JSON5 from "json5";
9
2
 
10
- export async function getSrcFileData({
11
- fileName,
12
- }) {
13
- const dirname = path.dirname(fileURLToPath(import.meta.url));
14
- const src = path.join(dirname, "..", ".vscode", fileName);
15
- const srcFileData = await readFile(src, "utf8");
16
-
17
- return srcFileData;
18
- }
19
-
20
3
  export async function getSrcJSONFileData({
21
- fileName,
4
+ fileData,
22
5
  isTs = false,
23
6
  removeDuplicateKeys = false,
24
7
  }) {
25
- const srcFileData = await getSrcFileData({
26
- fileName,
27
- });
28
-
29
- // Если есть нет typescript, нет лишних проблем, возвращаем
30
- if (!srcFileData.includes("// typescript")) {
31
- return srcFileData;
8
+ // Если нет typescript, нет лишних проблем, возвращаем
9
+ if (!fileData.includes("// typescript")) {
10
+ return fileData;
32
11
  }
33
12
 
34
- const lines = srcFileData.split("\n");
13
+ const lines = fileData.split("\n");
35
14
  const result = [];
36
15
  let nextLineIsTypescript = false;
37
16
  let nextLineIsTypescriptMultiline = false;
@@ -1,3 +1,6 @@
1
+ /*
2
+ change with execFile carefully later. Cover with tests
3
+ */
1
4
  import {
2
5
  exec,
3
6
  } from "node:child_process";
@@ -6,6 +9,7 @@ import {
6
9
  } from "node:util";
7
10
 
8
11
  const execAsync = promisify(exec);
12
+
9
13
  // filePaths: string | string[]
10
14
  export async function eslintFiles(filePaths) {
11
15
  const paths = Array.isArray(filePaths)
@@ -10,7 +10,7 @@ const concat = (...arrays) => {
10
10
  return [].concat(...arrays);
11
11
  };
12
12
 
13
- export default {
13
+ export const baseConfig = {
14
14
  extends: concat(
15
15
  [
16
16
  "stylelint-config-standard",
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  INDENT_SIZE,
3
- } from "../../eslint-config/rules/constants.js";
3
+ } from "../../eslint-config/constants/rules.js";
4
4
 
5
5
  const MAX_EMPTY_LINES = 1;
6
6
  // const MAX_LINE_LENGTH = 80;
@@ -0,0 +1,51 @@
1
+ import {
2
+ WARN,
3
+ OFF,
4
+ } from "../eslint-config/constants/severity.js";
5
+
6
+
7
+ // Returns overrides that disable all warning-level rules in the provided ESLint configuration.
8
+ //
9
+ // Usage example:
10
+ // eslintConfig.push({
11
+ // files: [
12
+ // "test/**/*",
13
+ // ],
14
+ // rules: getDisabledWarningRules(eslintConfig),
15
+ // });
16
+ export function getDisabledWarningRules(eslintConfig) {
17
+ const warningRules = new Set();
18
+ eslintConfig.forEach((config) => {
19
+ if (!config.rules) {
20
+ return;
21
+ }
22
+ (
23
+ Object.entries(config.rules)
24
+ .forEach(([
25
+ ruleName,
26
+ ruleConfig,
27
+ ]) => {
28
+ const severity = (() => {
29
+ if (Array.isArray(ruleConfig)) {
30
+ return ruleConfig[0];
31
+ }
32
+ return ruleConfig;
33
+ })();
34
+ if (severity === WARN) {
35
+ warningRules.add(ruleName);
36
+ }
37
+ })
38
+ );
39
+ });
40
+ return Object.fromEntries(
41
+ [
42
+ ...warningRules,
43
+ ]
44
+ .map((ruleName) => {
45
+ return [
46
+ ruleName,
47
+ OFF,
48
+ ];
49
+ }),
50
+ );
51
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cherepanov.pavel/shareable-config",
3
3
  "description": "setup for new repositories",
4
- "version": "1.0.26",
4
+ "version": "2.0.1",
5
5
  "type": "module",
6
6
  "devEngines": {
7
7
  "packageManager": {
@@ -27,9 +27,8 @@
27
27
  ".gitignore",
28
28
  ".gitignore-get.js",
29
29
  ".vscode/",
30
- "tools/",
31
- "utils/",
32
- "jsconfig.json"
30
+ "jsconfig.json",
31
+ "modules/"
33
32
  ],
34
33
  "bin": {
35
34
  "set-env": "./env.json5.set.js",
@@ -41,6 +40,12 @@
41
40
  "get-settings": "./.vscode/settings.json-get.js",
42
41
  "get-code-snippets": "./.vscode/.code-snippets-get.js"
43
42
  },
43
+ "exports": {
44
+ "./eslint-config": "./modules/eslint-config/index.js",
45
+ "./eslint-config/constants/*": "./modules/eslint-config/constants/*",
46
+ "./stylelint-config": "./modules/stylelint-config/index.js",
47
+ "./utils": "./modules/utils/index.js"
48
+ },
44
49
  "scripts": {
45
50
  "lint": "run-p -lc lint:js lint:css",
46
51
  "lint:fix": "run-p -lc lint:js:fix lint:css:fix",
File without changes
File without changes