@vida0905/eslint-config 2.10.1 → 2.12.0
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.
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +3 -0
- package/dist/index.d.mts +0 -102
- package/dist/index.mjs +27 -26
- package/package.json +19 -15
- package/bin/index.mjs +0 -2
- package/dist/cli/index.mjs +0 -108
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/cli.mjs
ADDED
package/dist/index.d.mts
CHANGED
|
@@ -15,87 +15,6 @@ interface RuleOptions {
|
|
|
15
15
|
* @see https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-disjunction.md
|
|
16
16
|
*/
|
|
17
17
|
'de-morgan/no-negated-disjunction'?: Linter.RuleEntry<[]>;
|
|
18
|
-
/**
|
|
19
|
-
* Bans a list of dependencies from being used
|
|
20
|
-
* @see https://github.com/es-tooling/eslint-plugin-depend/blob/main/docs/rules/ban-dependencies.md
|
|
21
|
-
*/
|
|
22
|
-
'e18e/ban-dependencies'?: Linter.RuleEntry<E18EBanDependencies>;
|
|
23
|
-
/**
|
|
24
|
-
* Prefer optimized alternatives to `indexOf()` equality checks
|
|
25
|
-
*/
|
|
26
|
-
'e18e/no-indexof-equality'?: Linter.RuleEntry<[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Prefer Array.prototype.at() over length-based indexing
|
|
29
|
-
*/
|
|
30
|
-
'e18e/prefer-array-at'?: Linter.RuleEntry<[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Prefer Array.prototype.fill() over Array.from or map with constant values
|
|
33
|
-
*/
|
|
34
|
-
'e18e/prefer-array-fill'?: Linter.RuleEntry<[]>;
|
|
35
|
-
/**
|
|
36
|
-
* Prefer Array.from(iterable, mapper) over [...iterable].map(mapper) to avoid intermediate array allocation
|
|
37
|
-
*/
|
|
38
|
-
'e18e/prefer-array-from-map'?: Linter.RuleEntry<[]>;
|
|
39
|
-
/**
|
|
40
|
-
* Prefer Array.some() over Array.find() when checking for element existence
|
|
41
|
-
*/
|
|
42
|
-
'e18e/prefer-array-some'?: Linter.RuleEntry<[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Prefer Array.prototype.toReversed() over copying and reversing arrays
|
|
45
|
-
*/
|
|
46
|
-
'e18e/prefer-array-to-reversed'?: Linter.RuleEntry<[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Prefer Array.prototype.toSorted() over copying and sorting arrays
|
|
49
|
-
*/
|
|
50
|
-
'e18e/prefer-array-to-sorted'?: Linter.RuleEntry<[]>;
|
|
51
|
-
/**
|
|
52
|
-
* Prefer Array.prototype.toSpliced() over copying and splicing arrays
|
|
53
|
-
*/
|
|
54
|
-
'e18e/prefer-array-to-spliced'?: Linter.RuleEntry<[]>;
|
|
55
|
-
/**
|
|
56
|
-
* Prefer Date.now() over new Date().getTime() and +new Date()
|
|
57
|
-
*/
|
|
58
|
-
'e18e/prefer-date-now'?: Linter.RuleEntry<[]>;
|
|
59
|
-
/**
|
|
60
|
-
* Prefer the exponentiation operator ** over Math.pow()
|
|
61
|
-
*/
|
|
62
|
-
'e18e/prefer-exponentiation-operator'?: Linter.RuleEntry<[]>;
|
|
63
|
-
/**
|
|
64
|
-
* Prefer .includes() over indexOf() comparisons for arrays and strings
|
|
65
|
-
*/
|
|
66
|
-
'e18e/prefer-includes'?: Linter.RuleEntry<[]>;
|
|
67
|
-
/**
|
|
68
|
-
* Prefer inline equality checks over temporary object creation for simple comparisons
|
|
69
|
-
*/
|
|
70
|
-
'e18e/prefer-inline-equality'?: Linter.RuleEntry<[]>;
|
|
71
|
-
/**
|
|
72
|
-
* Prefer nullish coalescing operator (?? and ??=) over verbose null checks
|
|
73
|
-
*/
|
|
74
|
-
'e18e/prefer-nullish-coalescing'?: Linter.RuleEntry<[]>;
|
|
75
|
-
/**
|
|
76
|
-
* Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call() and obj.hasOwnProperty()
|
|
77
|
-
*/
|
|
78
|
-
'e18e/prefer-object-has-own'?: Linter.RuleEntry<[]>;
|
|
79
|
-
/**
|
|
80
|
-
* prefer `RegExp.test()` over `String.match()` and `RegExp.exec()` when only checking for match existence
|
|
81
|
-
*/
|
|
82
|
-
'e18e/prefer-regex-test'?: Linter.RuleEntry<[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Prefer spread syntax over Array.concat(), Array.from(), Object.assign({}, ...), and Function.apply()
|
|
85
|
-
*/
|
|
86
|
-
'e18e/prefer-spread-syntax'?: Linter.RuleEntry<[]>;
|
|
87
|
-
/**
|
|
88
|
-
* Prefer defining regular expressions at module scope to avoid re-compilation on every function call
|
|
89
|
-
*/
|
|
90
|
-
'e18e/prefer-static-regex'?: Linter.RuleEntry<[]>;
|
|
91
|
-
/**
|
|
92
|
-
* Prefer passing function and arguments directly to setTimeout/setInterval instead of wrapping in an arrow function or using bind
|
|
93
|
-
*/
|
|
94
|
-
'e18e/prefer-timer-args'?: Linter.RuleEntry<[]>;
|
|
95
|
-
/**
|
|
96
|
-
* Prefer URL.canParse() over try-catch blocks for URL validation
|
|
97
|
-
*/
|
|
98
|
-
'e18e/prefer-url-canparse'?: Linter.RuleEntry<[]>;
|
|
99
18
|
/**
|
|
100
19
|
* Prefer recommended order of Nuxt config properties
|
|
101
20
|
* @see https://eslint.nuxt.com/packages/plugin#nuxtnuxt-config-keys-order
|
|
@@ -107,13 +26,6 @@ interface RuleOptions {
|
|
|
107
26
|
*/
|
|
108
27
|
'nuxt/prefer-import-meta'?: Linter.RuleEntry<[]>;
|
|
109
28
|
}
|
|
110
|
-
/* ======= Declarations ======= */
|
|
111
|
-
// ----- e18e/ban-dependencies -----
|
|
112
|
-
type E18EBanDependencies = [] | [{
|
|
113
|
-
presets?: string[];
|
|
114
|
-
modules?: string[];
|
|
115
|
-
allowed?: string[];
|
|
116
|
-
}]; // Names of all the configs
|
|
117
29
|
//#endregion
|
|
118
30
|
//#region src/types.d.ts
|
|
119
31
|
interface Rules extends RuleOptions {}
|
|
@@ -129,20 +41,6 @@ interface OptionsOverrides {
|
|
|
129
41
|
overrides?: TypedFlatConfigItem$1["rules"];
|
|
130
42
|
}
|
|
131
43
|
type OptionsConfig$1 = Omit<OptionsConfig, "overrides"> & {
|
|
132
|
-
/**
|
|
133
|
-
* Enable de-morgan rules.
|
|
134
|
-
*
|
|
135
|
-
* @see https://github.com/azat-io/eslint-plugin-de-morgan
|
|
136
|
-
* @default true
|
|
137
|
-
*/
|
|
138
|
-
deMorgan?: boolean | OptionsFiles;
|
|
139
|
-
/**
|
|
140
|
-
* Enable e18e rules.
|
|
141
|
-
*
|
|
142
|
-
* @see https://github.com/e18e/eslint-plugin
|
|
143
|
-
* @default true
|
|
144
|
-
*/
|
|
145
|
-
e18e?: boolean | OptionsOverrides & OptionsFiles;
|
|
146
44
|
/**
|
|
147
45
|
* Enable Nuxt.js rules.
|
|
148
46
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import antfu, { GLOB_SRC, ensurePackages, interopDefault } from "@antfu/eslint-config";
|
|
2
2
|
import { isPackageExists } from "local-pkg";
|
|
3
3
|
export * from "@antfu/eslint-config";
|
|
4
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
|
|
4
5
|
function isPrimitive(value) {
|
|
5
6
|
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
6
7
|
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
|
|
7
10
|
function isTypedArray(x) {
|
|
8
11
|
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
9
12
|
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/clone.mjs
|
|
10
15
|
function clone(obj) {
|
|
11
16
|
if (isPrimitive(obj)) return obj;
|
|
12
17
|
if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0);
|
|
@@ -32,21 +37,24 @@ function clone(obj) {
|
|
|
32
37
|
type: obj.type,
|
|
33
38
|
lastModified: obj.lastModified
|
|
34
39
|
});
|
|
35
|
-
if (typeof obj === "object")
|
|
36
|
-
const newObject = Object.create(prototype);
|
|
37
|
-
return Object.assign(newObject, obj);
|
|
38
|
-
}
|
|
40
|
+
if (typeof obj === "object") return Object.assign(Object.create(prototype), obj);
|
|
39
41
|
return obj;
|
|
40
42
|
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
41
45
|
function isPlainObject(value) {
|
|
42
46
|
if (!value || typeof value !== "object") return false;
|
|
43
47
|
const proto = Object.getPrototypeOf(value);
|
|
44
48
|
if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
|
|
45
49
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
46
50
|
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
|
|
47
53
|
function isUnsafeProperty(key) {
|
|
48
54
|
return key === "__proto__";
|
|
49
55
|
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/mergeWith.mjs
|
|
50
58
|
function mergeWith(target, source, merge) {
|
|
51
59
|
const sourceKeys = Object.keys(source);
|
|
52
60
|
for (let i = 0; i < sourceKeys.length; i++) {
|
|
@@ -64,6 +72,8 @@ function mergeWith(target, source, merge) {
|
|
|
64
72
|
}
|
|
65
73
|
return target;
|
|
66
74
|
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/object/toMerged.mjs
|
|
67
77
|
function toMerged(target, source) {
|
|
68
78
|
return mergeWith(clone(target), source, function mergeRecursively(targetValue, sourceValue) {
|
|
69
79
|
if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) return mergeWith(clone(targetValue), sourceValue, mergeRecursively);
|
|
@@ -72,27 +82,16 @@ function toMerged(target, source) {
|
|
|
72
82
|
else return mergeWith({}, sourceValue, mergeRecursively);
|
|
73
83
|
});
|
|
74
84
|
}
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/configs/de-morgan.ts
|
|
87
|
+
async function deMorgan() {
|
|
77
88
|
return [{
|
|
78
89
|
name: "vida/de-morgan/rules",
|
|
79
|
-
files,
|
|
80
90
|
...(await interopDefault(import("eslint-plugin-de-morgan"))).configs.recommended
|
|
81
91
|
}];
|
|
82
92
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const recommendedConfig = (await interopDefault(import("@e18e/eslint-plugin"))).configs.recommended;
|
|
86
|
-
return [{
|
|
87
|
-
name: "vida/e18e/rules",
|
|
88
|
-
files,
|
|
89
|
-
...recommendedConfig,
|
|
90
|
-
rules: {
|
|
91
|
-
...recommendedConfig.rules,
|
|
92
|
-
...overrides
|
|
93
|
-
}
|
|
94
|
-
}];
|
|
95
|
-
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/configs/nuxt.ts
|
|
96
95
|
async function nuxt(options = {}) {
|
|
97
96
|
const { files = [GLOB_SRC], overrides = {} } = options;
|
|
98
97
|
await ensurePackages(["@nuxt/eslint-plugin"]);
|
|
@@ -110,6 +109,8 @@ async function nuxt(options = {}) {
|
|
|
110
109
|
}
|
|
111
110
|
}];
|
|
112
111
|
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/overrides/index.ts
|
|
113
114
|
const antfuOverrides = Object.freeze({
|
|
114
115
|
javascript: { overrides: {
|
|
115
116
|
"arrow-body-style": ["error", "as-needed"],
|
|
@@ -170,11 +171,11 @@ const antfuOverrides = Object.freeze({
|
|
|
170
171
|
"vue/prefer-use-template-ref": ["error"]
|
|
171
172
|
} }
|
|
172
173
|
});
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/index.ts
|
|
173
176
|
const defaultOptions = {
|
|
174
|
-
deMorgan: true,
|
|
175
|
-
e18e: true,
|
|
176
177
|
nuxt: isPackageExists("nuxt"),
|
|
177
|
-
typescript: isPackageExists("typescript"),
|
|
178
|
+
typescript: isPackageExists("typescript") || isPackageExists("@typescript/native-preview"),
|
|
178
179
|
vue: [
|
|
179
180
|
"vue",
|
|
180
181
|
"nuxt",
|
|
@@ -184,10 +185,9 @@ const defaultOptions = {
|
|
|
184
185
|
};
|
|
185
186
|
function defineConfig(options = {}, ...userConfigs) {
|
|
186
187
|
options = toMerged(defaultOptions, options);
|
|
187
|
-
const {
|
|
188
|
+
const { nuxt: enableNuxt } = options;
|
|
188
189
|
const configs = [];
|
|
189
|
-
|
|
190
|
-
if (enableE18e) configs.push(e18e());
|
|
190
|
+
configs.push(deMorgan());
|
|
191
191
|
if (enableNuxt) configs.push(nuxt());
|
|
192
192
|
return antfu(applyOptions(options), ...configs, ...userConfigs);
|
|
193
193
|
}
|
|
@@ -200,4 +200,5 @@ function applyOptions(options) {
|
|
|
200
200
|
}
|
|
201
201
|
return options;
|
|
202
202
|
}
|
|
203
|
+
//#endregion
|
|
203
204
|
export { applyOptions, defineConfig as default, defineConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vida0905/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.12.0",
|
|
5
5
|
"description": "Vida Xie's ESLint Config",
|
|
6
6
|
"author": "Vida Xie <vida_2020@163.com> (https://github.com/9romise/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,10 +18,13 @@
|
|
|
18
18
|
],
|
|
19
19
|
"exports": {
|
|
20
20
|
".": "./dist/index.mjs",
|
|
21
|
+
"./cli": "./dist/cli.mjs",
|
|
21
22
|
"./package.json": "./package.json"
|
|
22
23
|
},
|
|
23
24
|
"types": "./dist/index.d.mts",
|
|
24
|
-
"bin":
|
|
25
|
+
"bin": {
|
|
26
|
+
"eslint-config": "./dist/cli.mjs"
|
|
27
|
+
},
|
|
25
28
|
"files": [
|
|
26
29
|
"bin",
|
|
27
30
|
"dist"
|
|
@@ -40,35 +43,36 @@
|
|
|
40
43
|
}
|
|
41
44
|
},
|
|
42
45
|
"dependencies": {
|
|
43
|
-
"@antfu/eslint-config": "^
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"eslint-flat-config-utils": "^3.0.1",
|
|
47
|
-
"eslint-plugin-de-morgan": "^2.0.0",
|
|
46
|
+
"@antfu/eslint-config": "^8.0.0",
|
|
47
|
+
"eslint-flat-config-utils": "^3.1.0",
|
|
48
|
+
"eslint-plugin-de-morgan": "^2.1.1",
|
|
48
49
|
"local-pkg": "^1.1.2"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@arethetypeswrong/core": "^0.18.2",
|
|
52
|
-
"@types/node": "^25.
|
|
53
|
-
"es-toolkit": "^1.
|
|
54
|
-
"eslint": "^10.0
|
|
53
|
+
"@types/node": "^25.5.0",
|
|
54
|
+
"es-toolkit": "^1.45.1",
|
|
55
|
+
"eslint": "^10.1.0",
|
|
55
56
|
"eslint-typegen": "^2.3.1",
|
|
56
57
|
"husky": "^9.1.7",
|
|
57
58
|
"nano-staged": "^0.9.0",
|
|
58
|
-
"publint": "^0.3.
|
|
59
|
-
"tsdown": "^0.
|
|
59
|
+
"publint": "^0.3.18",
|
|
60
|
+
"tsdown": "^0.21.7",
|
|
60
61
|
"tsx": "^4.21.0",
|
|
61
|
-
"typescript": "^
|
|
62
|
-
"vitest": "^4.
|
|
62
|
+
"typescript": "^6.0.2",
|
|
63
|
+
"vitest": "^4.1.2"
|
|
63
64
|
},
|
|
64
65
|
"nano-staged": {
|
|
65
66
|
"*": "eslint --fix"
|
|
66
67
|
},
|
|
68
|
+
"inlinedDependencies": {
|
|
69
|
+
"es-toolkit": "1.45.1"
|
|
70
|
+
},
|
|
67
71
|
"scripts": {
|
|
68
72
|
"dev": "tsdown --watch",
|
|
69
73
|
"build": "tsdown",
|
|
70
74
|
"typegen": "tsx scripts/typegen",
|
|
71
|
-
"typecheck": "tsc --noEmit",
|
|
75
|
+
"typecheck": "tsc -b --noEmit",
|
|
72
76
|
"test": "vitest",
|
|
73
77
|
"lint": "eslint .",
|
|
74
78
|
"check": "npm run typecheck && npm run lint",
|
package/bin/index.mjs
DELETED
package/dist/cli/index.mjs
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import { cac } from "cac";
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import fsp from "node:fs/promises";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { styleText } from "node:util";
|
|
7
|
-
|
|
8
|
-
//#region package.json
|
|
9
|
-
var version = "2.10.1";
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/cli/constants.ts
|
|
13
|
-
const vscodeSettingsString = `
|
|
14
|
-
// Disable the default formatter, use eslint instead
|
|
15
|
-
"prettier.enable": false,
|
|
16
|
-
"editor.formatOnSave": false,
|
|
17
|
-
|
|
18
|
-
// Auto fix
|
|
19
|
-
"editor.codeActionsOnSave": {
|
|
20
|
-
"source.fixAll.eslint": "explicit",
|
|
21
|
-
"source.organizeImports": "never"
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
25
|
-
"eslint.rules.customizations": [
|
|
26
|
-
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
27
|
-
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
28
|
-
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
29
|
-
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
30
|
-
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
31
|
-
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
32
|
-
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
33
|
-
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
34
|
-
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
35
|
-
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
36
|
-
],
|
|
37
|
-
|
|
38
|
-
// Enable eslint for all supported languages
|
|
39
|
-
"eslint.validate": [
|
|
40
|
-
"javascript",
|
|
41
|
-
"javascriptreact",
|
|
42
|
-
"typescript",
|
|
43
|
-
"typescriptreact",
|
|
44
|
-
"vue",
|
|
45
|
-
"html",
|
|
46
|
-
"markdown",
|
|
47
|
-
"json",
|
|
48
|
-
"json5",
|
|
49
|
-
"jsonc",
|
|
50
|
-
"yaml",
|
|
51
|
-
"toml",
|
|
52
|
-
"xml",
|
|
53
|
-
"gql",
|
|
54
|
-
"graphql",
|
|
55
|
-
"astro",
|
|
56
|
-
"svelte",
|
|
57
|
-
"css",
|
|
58
|
-
"less",
|
|
59
|
-
"scss",
|
|
60
|
-
"pcss",
|
|
61
|
-
"postcss"
|
|
62
|
-
]
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/cli/update/update-vscode-settings.ts
|
|
67
|
-
const CLOSING_BRACE_REGEX = /\s*\}$/;
|
|
68
|
-
async function updateVSCodeSettings() {
|
|
69
|
-
const cwd = process.cwd();
|
|
70
|
-
const dotVscodePath = path.join(cwd, ".vscode");
|
|
71
|
-
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
72
|
-
if (!fs.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
|
|
73
|
-
if (!fs.existsSync(settingsPath)) {
|
|
74
|
-
await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
|
|
75
|
-
console.log(styleText("green", "Created .vscode/settings.json"));
|
|
76
|
-
} else {
|
|
77
|
-
let settingsContent = await fsp.readFile(settingsPath, "utf8");
|
|
78
|
-
settingsContent = settingsContent.trim().replace(CLOSING_BRACE_REGEX, "");
|
|
79
|
-
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
80
|
-
settingsContent += `${vscodeSettingsString}}\n`;
|
|
81
|
-
await fsp.writeFile(settingsPath, settingsContent, "utf-8");
|
|
82
|
-
console.log(styleText("green", "Updated .vscode/settings.json"));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/cli/update/index.ts
|
|
88
|
-
async function update(files = []) {
|
|
89
|
-
if (files.includes("vscode")) await updateVSCodeSettings();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/cli/index.ts
|
|
94
|
-
const cli = cac("@vida0905/eslint-config");
|
|
95
|
-
cli.command("update [...files]", "Update configuration files for specified files").alias("up").option("vscode", "Update .vscode/settings.json").action(async (files) => {
|
|
96
|
-
try {
|
|
97
|
-
await update(files);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error(`✘ ${String(error)}`);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
cli.help();
|
|
104
|
-
cli.version(version);
|
|
105
|
-
cli.parse();
|
|
106
|
-
|
|
107
|
-
//#endregion
|
|
108
|
-
export { };
|