@vida0905/eslint-config 2.9.0 → 2.10.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.
File without changes
@@ -6,7 +6,7 @@ import path from "node:path";
6
6
  import { styleText } from "node:util";
7
7
 
8
8
  //#region package.json
9
- var version = "2.9.0";
9
+ var version = "2.10.1";
10
10
 
11
11
  //#endregion
12
12
  //#region src/cli/constants.ts
@@ -64,6 +64,7 @@ const vscodeSettingsString = `
64
64
 
65
65
  //#endregion
66
66
  //#region src/cli/update/update-vscode-settings.ts
67
+ const CLOSING_BRACE_REGEX = /\s*\}$/;
67
68
  async function updateVSCodeSettings() {
68
69
  const cwd = process.cwd();
69
70
  const dotVscodePath = path.join(cwd, ".vscode");
@@ -74,7 +75,7 @@ async function updateVSCodeSettings() {
74
75
  console.log(styleText("green", "Created .vscode/settings.json"));
75
76
  } else {
76
77
  let settingsContent = await fsp.readFile(settingsPath, "utf8");
77
- settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
78
+ settingsContent = settingsContent.trim().replace(CLOSING_BRACE_REGEX, "");
78
79
  settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
79
80
  settingsContent += `${vscodeSettingsString}}\n`;
80
81
  await fsp.writeFile(settingsPath, settingsContent, "utf-8");
package/dist/index.d.mts CHANGED
@@ -36,6 +36,10 @@ interface RuleOptions {
36
36
  * Prefer Array.from(iterable, mapper) over [...iterable].map(mapper) to avoid intermediate array allocation
37
37
  */
38
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<[]>;
39
43
  /**
40
44
  * Prefer Array.prototype.toReversed() over copying and reversing arrays
41
45
  */
@@ -60,6 +64,10 @@ interface RuleOptions {
60
64
  * Prefer .includes() over indexOf() comparisons for arrays and strings
61
65
  */
62
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<[]>;
63
71
  /**
64
72
  * Prefer nullish coalescing operator (?? and ??=) over verbose null checks
65
73
  */
@@ -76,6 +84,10 @@ interface RuleOptions {
76
84
  * Prefer spread syntax over Array.concat(), Array.from(), Object.assign({}, ...), and Function.apply()
77
85
  */
78
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<[]>;
79
91
  /**
80
92
  * Prefer passing function and arguments directly to setTimeout/setInterval instead of wrapping in an arrow function or using bind
81
93
  */
@@ -101,8 +113,7 @@ type E18EBanDependencies = [] | [{
101
113
  presets?: string[];
102
114
  modules?: string[];
103
115
  allowed?: string[];
104
- }];
105
- // Names of all the configs
116
+ }]; // Names of all the configs
106
117
  //#endregion
107
118
  //#region src/types.d.ts
108
119
  interface Rules extends RuleOptions {}
package/dist/index.mjs CHANGED
@@ -1,25 +1,17 @@
1
1
  import antfu, { GLOB_SRC, ensurePackages, interopDefault } from "@antfu/eslint-config";
2
2
  import { isPackageExists } from "local-pkg";
3
-
4
- export * from "@antfu/eslint-config"
5
-
6
- //#region node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
3
+ export * from "@antfu/eslint-config";
7
4
  function isPrimitive(value) {
8
5
  return value == null || typeof value !== "object" && typeof value !== "function";
9
6
  }
10
-
11
- //#endregion
12
- //#region node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
13
7
  function isTypedArray(x) {
14
8
  return ArrayBuffer.isView(x) && !(x instanceof DataView);
15
9
  }
16
-
17
- //#endregion
18
- //#region node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/object/clone.mjs
19
10
  function clone(obj) {
20
11
  if (isPrimitive(obj)) return obj;
21
12
  if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0);
22
13
  const prototype = Object.getPrototypeOf(obj);
14
+ if (prototype == null) return Object.assign(Object.create(prototype), obj);
23
15
  const Constructor = prototype.constructor;
24
16
  if (obj instanceof Date || obj instanceof Map || obj instanceof Set) return new Constructor(obj);
25
17
  if (obj instanceof RegExp) {
@@ -29,10 +21,11 @@ function clone(obj) {
29
21
  }
30
22
  if (obj instanceof DataView) return new Constructor(obj.buffer.slice(0));
31
23
  if (obj instanceof Error) {
32
- const newError = new Constructor(obj.message);
24
+ let newError;
25
+ if (obj instanceof AggregateError) newError = new Constructor(obj.errors, obj.message, { cause: obj.cause });
26
+ else newError = new Constructor(obj.message, { cause: obj.cause });
33
27
  newError.stack = obj.stack;
34
- newError.name = obj.name;
35
- newError.cause = obj.cause;
28
+ Object.assign(newError, obj);
36
29
  return newError;
37
30
  }
38
31
  if (typeof File !== "undefined" && obj instanceof File) return new Constructor([obj], obj.name, {
@@ -45,24 +38,15 @@ function clone(obj) {
45
38
  }
46
39
  return obj;
47
40
  }
48
-
49
- //#endregion
50
- //#region node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
51
41
  function isPlainObject(value) {
52
42
  if (!value || typeof value !== "object") return false;
53
43
  const proto = Object.getPrototypeOf(value);
54
44
  if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
55
45
  return Object.prototype.toString.call(value) === "[object Object]";
56
46
  }
57
-
58
- //#endregion
59
- //#region node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
60
47
  function isUnsafeProperty(key) {
61
48
  return key === "__proto__";
62
49
  }
63
-
64
- //#endregion
65
- //#region node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/object/mergeWith.mjs
66
50
  function mergeWith(target, source, merge) {
67
51
  const sourceKeys = Object.keys(source);
68
52
  for (let i = 0; i < sourceKeys.length; i++) {
@@ -80,9 +64,6 @@ function mergeWith(target, source, merge) {
80
64
  }
81
65
  return target;
82
66
  }
83
-
84
- //#endregion
85
- //#region node_modules/.pnpm/es-toolkit@1.43.0/node_modules/es-toolkit/dist/object/toMerged.mjs
86
67
  function toMerged(target, source) {
87
68
  return mergeWith(clone(target), source, function mergeRecursively(targetValue, sourceValue) {
88
69
  if (Array.isArray(sourceValue)) if (Array.isArray(targetValue)) return mergeWith(clone(targetValue), sourceValue, mergeRecursively);
@@ -91,9 +72,6 @@ function toMerged(target, source) {
91
72
  else return mergeWith({}, sourceValue, mergeRecursively);
92
73
  });
93
74
  }
94
-
95
- //#endregion
96
- //#region src/configs/de-morgan.ts
97
75
  async function deMorgan(options = {}) {
98
76
  const { files = [GLOB_SRC] } = options;
99
77
  return [{
@@ -102,9 +80,6 @@ async function deMorgan(options = {}) {
102
80
  ...(await interopDefault(import("eslint-plugin-de-morgan"))).configs.recommended
103
81
  }];
104
82
  }
105
-
106
- //#endregion
107
- //#region src/configs/e18e.ts
108
83
  async function e18e(options = {}) {
109
84
  const { files = [GLOB_SRC], overrides } = options;
110
85
  const recommendedConfig = (await interopDefault(import("@e18e/eslint-plugin"))).configs.recommended;
@@ -118,9 +93,6 @@ async function e18e(options = {}) {
118
93
  }
119
94
  }];
120
95
  }
121
-
122
- //#endregion
123
- //#region src/configs/nuxt.ts
124
96
  async function nuxt(options = {}) {
125
97
  const { files = [GLOB_SRC], overrides = {} } = options;
126
98
  await ensurePackages(["@nuxt/eslint-plugin"]);
@@ -138,88 +110,66 @@ async function nuxt(options = {}) {
138
110
  }
139
111
  }];
140
112
  }
141
-
142
- //#endregion
143
- //#region src/overrides/javascript.ts
144
- const javascript = { overrides: {
145
- "arrow-body-style": ["error", "as-needed"],
146
- "no-unused-private-class-members": "error",
147
- "require-atomic-updates": ["error", { allowProperties: true }]
148
- } };
149
-
150
- //#endregion
151
- //#region src/overrides/stylistic.ts
152
- const stylistic = {
153
- indent: 2,
154
- quotes: "single",
155
- semi: false,
156
- overrides: {
157
- "style/indent": [
158
- "error",
159
- 2,
160
- {
161
- SwitchCase: 1,
162
- VariableDeclarator: "first",
163
- outerIIFEBody: 1,
164
- MemberExpression: 1,
165
- FunctionDeclaration: {
166
- parameters: 1,
167
- body: 1
168
- },
169
- FunctionExpression: {
170
- parameters: 1,
171
- body: 1
172
- },
173
- StaticBlock: { body: 1 },
174
- CallExpression: { arguments: 1 },
175
- ArrayExpression: 1,
176
- ObjectExpression: 1,
177
- ImportDeclaration: 1,
178
- flatTernaryExpressions: true,
179
- offsetTernaryExpressions: true,
180
- ignoreComments: false,
181
- tabLength: 2
182
- }
183
- ],
184
- "style/quotes": [
185
- "error",
186
- "single",
187
- {
188
- avoidEscape: true,
189
- allowTemplateLiterals: "avoidEscape"
190
- }
191
- ],
192
- "style/arrow-parens": ["error", "always"],
193
- "style/brace-style": [
194
- "error",
195
- "1tbs",
196
- { allowSingleLine: true }
197
- ]
198
- }
199
- };
200
-
201
- //#endregion
202
- //#region src/overrides/typescript.ts
203
- const typescript = { overrides: { "ts/array-type": "error" } };
204
-
205
- //#endregion
206
- //#region src/overrides/vue.ts
207
- const vue = { overrides: {
208
- "vue/max-attributes-per-line": ["error", { multiline: 1 }],
209
- "vue/prefer-use-template-ref": ["error"]
210
- } };
211
-
212
- //#endregion
213
- //#region src/overrides/index.ts
214
113
  const antfuOverrides = Object.freeze({
215
- javascript,
216
- stylistic,
217
- typescript,
218
- vue
114
+ javascript: { overrides: {
115
+ "arrow-body-style": ["error", "as-needed"],
116
+ "no-unused-private-class-members": "error",
117
+ "require-atomic-updates": ["error", { allowProperties: true }]
118
+ } },
119
+ stylistic: {
120
+ indent: 2,
121
+ quotes: "single",
122
+ semi: false,
123
+ overrides: {
124
+ "style/indent": [
125
+ "error",
126
+ 2,
127
+ {
128
+ SwitchCase: 1,
129
+ VariableDeclarator: "first",
130
+ outerIIFEBody: 1,
131
+ MemberExpression: 1,
132
+ FunctionDeclaration: {
133
+ parameters: 1,
134
+ body: 1
135
+ },
136
+ FunctionExpression: {
137
+ parameters: 1,
138
+ body: 1
139
+ },
140
+ StaticBlock: { body: 1 },
141
+ CallExpression: { arguments: 1 },
142
+ ArrayExpression: 1,
143
+ ObjectExpression: 1,
144
+ ImportDeclaration: 1,
145
+ flatTernaryExpressions: true,
146
+ offsetTernaryExpressions: true,
147
+ ignoreComments: false,
148
+ tabLength: 2
149
+ }
150
+ ],
151
+ "style/quotes": [
152
+ "error",
153
+ "single",
154
+ {
155
+ avoidEscape: true,
156
+ allowTemplateLiterals: "avoidEscape"
157
+ }
158
+ ],
159
+ "style/arrow-parens": ["error", "always"],
160
+ "style/brace-style": [
161
+ "error",
162
+ "1tbs",
163
+ { allowSingleLine: true }
164
+ ]
165
+ }
166
+ },
167
+ typescript: { overrides: { "ts/array-type": "error" } },
168
+ vue: { overrides: {
169
+ "vue/max-attributes-per-line": ["error", { multiline: 1 }],
170
+ "vue/prefer-use-template-ref": ["error"]
171
+ } }
219
172
  });
220
-
221
- //#endregion
222
- //#region src/index.ts
223
173
  const defaultOptions = {
224
174
  deMorgan: true,
225
175
  e18e: true,
@@ -250,7 +200,4 @@ function applyOptions(options) {
250
200
  }
251
201
  return options;
252
202
  }
253
- var src_default = defineConfig;
254
-
255
- //#endregion
256
- export { applyOptions, src_default as default, defineConfig };
203
+ 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.9.0",
4
+ "version": "2.10.1",
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",
@@ -17,9 +17,9 @@
17
17
  "eslint-config"
18
18
  ],
19
19
  "exports": {
20
- ".": "./dist/index.mjs"
20
+ ".": "./dist/index.mjs",
21
+ "./package.json": "./package.json"
21
22
  },
22
- "main": "./dits/index.mjs",
23
23
  "types": "./dist/index.d.mts",
24
24
  "bin": "./bin/index.mjs",
25
25
  "files": [
@@ -40,24 +40,26 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
- "@antfu/eslint-config": "^6.7.3",
44
- "@e18e/eslint-plugin": "^0.1.3",
43
+ "@antfu/eslint-config": "^7.4.3",
44
+ "@e18e/eslint-plugin": "^0.2.0",
45
45
  "cac": "^6.7.14",
46
- "eslint-flat-config-utils": "^2.1.4",
46
+ "eslint-flat-config-utils": "^3.0.1",
47
47
  "eslint-plugin-de-morgan": "^2.0.0",
48
48
  "local-pkg": "^1.1.2"
49
49
  },
50
50
  "devDependencies": {
51
- "@types/node": "^25.0.3",
52
- "es-toolkit": "^1.43.0",
53
- "eslint": "^9.39.2",
54
- "eslint-typegen": "^2.3.0",
51
+ "@arethetypeswrong/core": "^0.18.2",
52
+ "@types/node": "^25.3.0",
53
+ "es-toolkit": "^1.44.0",
54
+ "eslint": "^10.0.1",
55
+ "eslint-typegen": "^2.3.1",
55
56
  "husky": "^9.1.7",
56
57
  "nano-staged": "^0.9.0",
57
- "tsdown": "^0.18.3",
58
+ "publint": "^0.3.17",
59
+ "tsdown": "^0.20.3",
58
60
  "tsx": "^4.21.0",
59
61
  "typescript": "^5.9.3",
60
- "vitest": "^4.0.16"
62
+ "vitest": "^4.0.18"
61
63
  },
62
64
  "nano-staged": {
63
65
  "*": "eslint --fix"
@@ -70,6 +72,7 @@
70
72
  "test": "vitest",
71
73
  "lint": "eslint .",
72
74
  "check": "npm run typecheck && npm run lint",
73
- "inspect": "npx eslint --inspect-config --config eslint-inspector.config.ts"
75
+ "inspect": "npx eslint --inspect-config --config eslint-inspector.config.ts",
76
+ "release": "npx bumpp"
74
77
  }
75
78
  }