@cherepanov.pavel/shareable-config 1.0.10 → 1.0.12

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.
@@ -7,6 +7,7 @@ import { mergeWithOverride } from '../utils/merge.js';
7
7
  import { getHeader } from '../utils/file-header.js';
8
8
  import { getSrcJSONFileData } from '../utils/file.js';
9
9
  import { getEnvs } from '../utils/env.js';
10
+ import { eslintFiles } from '../utils/lint.js';
10
11
 
11
12
  const fileNames = [
12
13
  'vue.code-snippets',
@@ -41,6 +42,7 @@ try {
41
42
  }
42
43
 
43
44
  await outputFile(destFile, `${getHeader()}${result}`);
45
+ await eslintFiles(destFile);
44
46
  if (isDestFileHaveOverride) {
45
47
  console.info(`${fileName} обновлён с учётом override`);
46
48
  } else {
@@ -22,4 +22,4 @@
22
22
  // need to check that it's working well
23
23
  // iulian-radu-at.find-unused-exports
24
24
  ],
25
- }
25
+ }
@@ -7,6 +7,7 @@ import { mergeWithOverride } from '../utils/merge.js';
7
7
  import { getHeader } from '../utils/file-header.js';
8
8
  import { getEnvs } from '../utils/env.js';
9
9
  import { outputFile } from 'fs-extra';
10
+ import { eslintFiles } from '../utils/lint.js';
10
11
 
11
12
  const fileName = 'extensions.json';
12
13
  const destFile = path.join(process.cwd(), `.vscode/${fileName}`);
@@ -33,6 +34,7 @@ try {
33
34
  }
34
35
 
35
36
  await outputFile(destFile, `${getHeader()}${result}`);
37
+ await eslintFiles(destFile);
36
38
  if (overrideContent) {
37
39
  console.info(`${fileName} обновлён с учётом override`);
38
40
  } else {
@@ -7,6 +7,7 @@ import { mergeWithOverride } from '../utils/merge.js';
7
7
  import { getHeader } from '../utils/file-header.js';
8
8
  import { getEnvs } from '../utils/env.js';
9
9
  import { outputFile } from 'fs-extra';
10
+ import { eslintFiles } from '../utils/lint.js';
10
11
 
11
12
  const fileName = 'settings.json';
12
13
  const destFile = path.join(process.cwd(), `.vscode/${fileName}`);
@@ -33,6 +34,7 @@ try {
33
34
  }
34
35
 
35
36
  await outputFile(destFile, `${getHeader()}${result}`);
37
+ await eslintFiles(destFile);
36
38
  if (overrideContent) {
37
39
  console.info(`${fileName} обновлён с учётом override`);
38
40
  } else {
@@ -25,4 +25,4 @@
25
25
  ],
26
26
  // typescript multiline end
27
27
  },
28
- }
28
+ }
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.10",
4
+ "version": "1.0.12",
5
5
  "type": "module",
6
6
  "devEngines": {
7
7
  "packageManager": {
@@ -47,7 +47,7 @@
47
47
  "lint:js": "eslint",
48
48
  "lint:js:fix": "npm run lint:js -- --fix",
49
49
  "lint:css": "stylelint \"./**/*.{css,vue}\" --ignore-path .gitignore --formatter verbose",
50
- "lint:css:fix": "npm run lint:css:files -- --fix"
50
+ "lint:css:fix": "npm run lint:css -- --fix"
51
51
  },
52
52
  "dependencies": {
53
53
  "@eslint/compat": "2.1.0",
@@ -2,6 +2,9 @@ import { defineConfig } from 'eslint/config';
2
2
  import jsonc from 'eslint-plugin-jsonc';
3
3
  import { ERROR } from '../rules/severity.js';
4
4
  import { jsFormatting } from '../rules/stylistic/index.js';
5
+ import { possibleProblemRules } from '../rules/javascript/possible-problems.js';
6
+ import { suggestionRules } from '../rules/javascript/suggestions.js';
7
+ import stylisticPlugin from '@stylistic/eslint-plugin';
5
8
 
6
9
  const JSON_BUT_JSONC_FILES = [
7
10
  '**/.vscode/*.json',
@@ -9,6 +12,7 @@ const JSON_BUT_JSONC_FILES = [
9
12
  '**/tsconfig*.json',
10
13
  ];
11
14
  const COMMON_RULES = {
15
+ '@stylistic/eol-last': jsFormatting['@stylistic/eol-last'],
12
16
  'jsonc/no-bigint-literals': ERROR,
13
17
  'jsonc/no-binary-expression': ERROR,
14
18
  'jsonc/no-binary-numeric-literals': ERROR,
@@ -27,11 +31,20 @@ const COMMON_RULES = {
27
31
  'jsonc/array-bracket-newline': jsFormatting['@stylistic/array-bracket-newline'],
28
32
  'jsonc/array-bracket-spacing': jsFormatting['@stylistic/array-bracket-spacing'],
29
33
  'jsonc/array-element-newline': jsFormatting['@stylistic/array-element-newline'],
34
+ 'jsonc/comma-dangle': jsFormatting['@stylistic/comma-dangle'],
35
+ 'jsonc/comma-style': jsFormatting['@stylistic/comma-style'],
30
36
  'jsonc/indent': [
31
37
  jsFormatting['@stylistic/indent'][0],
32
38
  jsFormatting['@stylistic/indent'][1],
33
39
  ],
34
- 'jsonc/comma-dangle': jsFormatting['@stylistic/comma-dangle'],
40
+ 'jsonc/key-spacing': jsFormatting['@stylistic/key-spacing'],
41
+ 'jsonc/no-dupe-keys': possibleProblemRules['no-dupe-keys'],
42
+ 'jsonc/no-floating-decimal': jsFormatting['@stylistic/no-floating-decimal'],
43
+ 'jsonc/no-irregular-whitespace': possibleProblemRules['no-irregular-whitespace'],
44
+ 'jsonc/no-octal-escape': suggestionRules['no-octal-escape'],
45
+ 'jsonc/no-octal': suggestionRules['no-octal'],
46
+ 'jsonc/no-sparse-arrays': ERROR,
47
+ 'jsonc/no-useless-escape': suggestionRules['no-useless-escape'],
35
48
  };
36
49
  const JSON_RULES = {
37
50
  'jsonc/no-comments': ERROR,
@@ -42,12 +55,14 @@ const JSON_RULES = {
42
55
  };
43
56
  const JSON_JSONC_RULES = {
44
57
  'jsonc/no-infinity': ERROR,
58
+ 'jsonc/no-multi-str': suggestionRules['no-multi-str'],
45
59
  };
46
60
 
47
61
 
48
62
  export default defineConfig([
49
63
  {
50
64
  plugins: {
65
+ '@stylistic': stylisticPlugin,
51
66
  jsonc,
52
67
  },
53
68
  },
@@ -28,7 +28,7 @@ export const possibleProblemRules = {
28
28
  'no-dupe-args': [ERROR],
29
29
  'no-dupe-class-members': [ERROR],
30
30
  'no-dupe-else-if': [ERROR],
31
- 'no-dupe-keys': [ERROR],
31
+ 'no-dupe-keys': [WARN],
32
32
  'no-duplicate-case': [ERROR],
33
33
  'no-duplicate-imports': [ERROR],
34
34
  'no-empty-character-class': [ERROR],
@@ -43,21 +43,6 @@ export default {
43
43
  '@stylistic/comma-style': [
44
44
  ERROR,
45
45
  'last',
46
- {
47
- exceptions: {
48
- ArrayExpression: false,
49
- ArrayPattern: false,
50
- ArrowFunctionExpression: false,
51
- CallExpression: false,
52
- FunctionDeclaration: false,
53
- FunctionExpression: false,
54
- ImportDeclaration: false,
55
- NewExpression: false,
56
- ObjectExpression: false,
57
- ObjectPattern: false,
58
- VariableDeclaration: false,
59
- },
60
- },
61
46
  ],
62
47
  '@stylistic/computed-property-spacing': [
63
48
  ERROR,
@@ -101,7 +86,11 @@ export default {
101
86
  ],
102
87
  '@stylistic/key-spacing': [
103
88
  ERROR,
104
- { beforeColon: false, afterColon: true },
89
+ {
90
+ beforeColon: false,
91
+ afterColon: true,
92
+ mode: 'strict',
93
+ },
105
94
  ],
106
95
  '@stylistic/keyword-spacing': [
107
96
  ERROR,
@@ -1,3 +1,4 @@
1
+ import { possibleProblemRules } from '../javascript/possible-problems.js';
1
2
  import { ERROR, OFF } from '../severity.js';
2
3
 
3
4
  export const suggestionRules = {
@@ -31,7 +32,7 @@ export const suggestionRules = {
31
32
  'vue/no-deprecated-v-on-native-modifier': [ERROR],
32
33
  'vue/no-deprecated-v-on-number-modifiers': [ERROR],
33
34
  'vue/no-deprecated-vue-config-keycodes': [ERROR],
34
- 'vue/no-dupe-keys': [ERROR],
35
+ 'vue/no-dupe-keys': possibleProblemRules['no-dupe-keys'],
35
36
  'vue/no-dupe-v-else-if': [ERROR],
36
37
  'vue/no-duplicate-attributes': [ERROR],
37
38
  'vue/no-export-in-script-setup': [ERROR],
package/utils/file.js CHANGED
@@ -57,7 +57,7 @@ export async function getSrcJSONFileData({
57
57
 
58
58
  const stringResult = result.join('\n');
59
59
  if (removeDuplicateKeys) {
60
- return JSON.stringify(JSON5.parse(stringResult), null, 2);
60
+ return JSON.stringify(JSON5.parse(stringResult));
61
61
  }
62
62
 
63
63
  return stringResult;
package/utils/lint.js ADDED
@@ -0,0 +1,14 @@
1
+ import { exec } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+
4
+ const execAsync = promisify(exec);
5
+ // filePaths: string | string[]
6
+ export async function eslintFiles(filePaths) {
7
+ const paths = Array.isArray(filePaths) ? filePaths : [filePaths];
8
+
9
+ const promises = paths.map(async (path) => {
10
+ return execAsync(`eslint ${path} --fix`);
11
+ });
12
+
13
+ return Promise.all(promises);
14
+ }