@2030/eslint-config 1.0.0 → 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019-PRESENT Dai Jun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  - 单引号,无分
15
15
  - 使用ESLint Stylistic
16
16
  - 默认遵守.gitignore
17
- - 支持 ESLint v9 或 v8.50.0+
17
+ - 要求ESLint v9.5.0+
18
18
 
19
19
  ## 用法
20
20
 
package/dist/cli.cjs CHANGED
@@ -29,17 +29,10 @@ module.exports = __toCommonJS(cli_exports);
29
29
 
30
30
  // src/cli/index.ts
31
31
  var import_node_process5 = __toESM(require("process"), 1);
32
+ var p5 = __toESM(require("@clack/prompts"), 1);
32
33
  var import_picocolors6 = __toESM(require("picocolors"), 1);
33
- var import_helpers = require("yargs/helpers");
34
34
  var import_yargs = __toESM(require("yargs"), 1);
35
- var p5 = __toESM(require("@clack/prompts"), 1);
36
-
37
- // src/cli/run.ts
38
- var import_node_fs3 = __toESM(require("fs"), 1);
39
- var import_node_path4 = __toESM(require("path"), 1);
40
- var import_node_process4 = __toESM(require("process"), 1);
41
- var import_picocolors5 = __toESM(require("picocolors"), 1);
42
- var p4 = __toESM(require("@clack/prompts"), 1);
35
+ var import_helpers = require("yargs/helpers");
43
36
 
44
37
  // src/cli/constants.ts
45
38
  var import_picocolors = __toESM(require("picocolors"), 1);
@@ -48,7 +41,7 @@ var import_picocolors = __toESM(require("picocolors"), 1);
48
41
  var package_default = {
49
42
  name: "@2030/eslint-config",
50
43
  type: "module",
51
- version: "1.0.0",
44
+ version: "2.0.1",
52
45
  description: "Shareable ESLint config for conventional coding style",
53
46
  author: "Dai Jun <zijun2030@163.com>",
54
47
  license: "MIT",
@@ -84,20 +77,20 @@ var package_default = {
84
77
  prepare: "simple-git-hooks"
85
78
  },
86
79
  peerDependencies: {
87
- "@eslint-react/eslint-plugin": "^1.12.1",
80
+ "@eslint-react/eslint-plugin": "^1.5.8",
88
81
  "@prettier/plugin-xml": "^3.4.1",
89
- "@unocss/eslint-plugin": "^0.62.3",
82
+ "@unocss/eslint-plugin": ">=0.50.0",
90
83
  "astro-eslint-parser": "^1.0.2",
91
- eslint: "^9.9.1",
92
- "eslint-plugin-astro": "^1.2.3",
93
- "eslint-plugin-format": "^0.1.2",
94
- "eslint-plugin-react-hooks": "^4.6.2",
95
- "eslint-plugin-react-refresh": "^0.4.11",
96
- "eslint-plugin-solid": "^0.14.2",
97
- "eslint-plugin-svelte": "^2.43.0",
98
- "prettier-plugin-astro": "^0.14.1",
84
+ eslint: "^9.10.0",
85
+ "eslint-plugin-astro": "^1.2.0",
86
+ "eslint-plugin-format": ">=0.1.0",
87
+ "eslint-plugin-react-hooks": "^4.6.0",
88
+ "eslint-plugin-react-refresh": "^0.4.4",
89
+ "eslint-plugin-solid": "^0.14.3",
90
+ "eslint-plugin-svelte": ">=2.35.1",
91
+ "prettier-plugin-astro": "^0.13.0",
99
92
  "prettier-plugin-slidev": "^1.0.5",
100
- "svelte-eslint-parser": "^0.41.0"
93
+ "svelte-eslint-parser": ">=0.37.0"
101
94
  },
102
95
  peerDependenciesMeta: {
103
96
  "@eslint-react/eslint-plugin": {
@@ -144,34 +137,34 @@ var package_default = {
144
137
  "@antfu/install-pkg": "^0.4.1",
145
138
  "@clack/prompts": "^0.7.0",
146
139
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
147
- "@stylistic/eslint-plugin": "^2.6.4",
148
- "@typescript-eslint/eslint-plugin": "^8.3.0",
149
- "@typescript-eslint/parser": "^8.3.0",
150
- "@vitest/eslint-plugin": "^1.0.5",
151
- "eslint-config-flat-gitignore": "^0.1.8",
152
- "eslint-flat-config-utils": "^0.3.1",
140
+ "@eslint/markdown": "^6.1.0",
141
+ "@stylistic/eslint-plugin": "^2.8.0",
142
+ "@typescript-eslint/eslint-plugin": "^8.7.0",
143
+ "@typescript-eslint/parser": "^8.7.0",
144
+ "@vitest/eslint-plugin": "^1.1.4",
145
+ "eslint-config-flat-gitignore": "^0.3.0",
146
+ "eslint-flat-config-utils": "^0.4.0",
153
147
  "eslint-merge-processors": "^0.1.0",
154
- "eslint-plugin-antfu": "^2.3.6",
155
- "eslint-plugin-command": "^0.2.3",
156
- "eslint-plugin-import-x": "^4.0.0",
157
- "eslint-plugin-jsdoc": "^50.2.2",
148
+ "eslint-plugin-antfu": "^2.7.0",
149
+ "eslint-plugin-command": "^0.2.6",
150
+ "eslint-plugin-import-x": "^4.3.0",
151
+ "eslint-plugin-jsdoc": "^50.3.0",
158
152
  "eslint-plugin-jsonc": "^2.16.0",
159
- "eslint-plugin-markdown": "^5.1.0",
160
- "eslint-plugin-n": "^17.10.2",
153
+ "eslint-plugin-n": "^17.10.3",
161
154
  "eslint-plugin-no-only-tests": "^3.3.0",
162
- "eslint-plugin-perfectionist": "^3.2.0",
155
+ "eslint-plugin-perfectionist": "^3.7.0",
163
156
  "eslint-plugin-regexp": "^2.6.0",
164
157
  "eslint-plugin-toml": "^0.11.1",
165
158
  "eslint-plugin-unicorn": "^55.0.0",
166
- "eslint-plugin-unused-imports": "^4.1.3",
167
- "eslint-plugin-vue": "^9.27.0",
159
+ "eslint-plugin-unused-imports": "^4.1.4",
160
+ "eslint-plugin-vue": "^9.28.0",
168
161
  "eslint-plugin-yml": "^1.14.0",
169
162
  "eslint-processor-vue-blocks": "^0.1.2",
170
163
  globals: "^15.9.0",
171
164
  "jsonc-eslint-parser": "^2.4.0",
172
165
  "local-pkg": "^0.5.0",
173
166
  "parse-gitignore": "^2.0.0",
174
- picocolors: "^1.0.1",
167
+ picocolors: "^1.1.0",
175
168
  "toml-eslint-parser": "^0.10.0",
176
169
  "vue-eslint-parser": "^9.4.3",
177
170
  "yaml-eslint-parser": "^1.2.3",
@@ -179,50 +172,49 @@ var package_default = {
179
172
  },
180
173
  devDependencies: {
181
174
  "@2030/eslint-config": "workspace:*",
182
- "@antfu/ni": "^0.22.4",
183
- "@eslint-react/eslint-plugin": "^1.12.1",
175
+ "@antfu/ni": "^0.23.0",
176
+ "@eslint-react/eslint-plugin": "^1.14.2",
184
177
  "@eslint/config-inspector": "^0.5.4",
185
178
  "@prettier/plugin-xml": "^3.4.1",
186
- "@stylistic/eslint-plugin-migrate": "^2.6.4",
187
- "@types/eslint": "^9.6.1",
179
+ "@stylistic/eslint-plugin-migrate": "^2.8.0",
188
180
  "@types/fs-extra": "^11.0.4",
189
- "@types/node": "^22.5.0",
181
+ "@types/node": "^22.7.3",
190
182
  "@types/prompts": "^2.4.9",
191
183
  "@types/yargs": "^17.0.33",
192
- "@unocss/eslint-plugin": "^0.62.3",
193
- "astro-eslint-parser": "^1.0.2",
184
+ "@unocss/eslint-plugin": "^0.62.4",
185
+ "astro-eslint-parser": "^1.0.3",
194
186
  bumpp: "^9.5.2",
195
- eslint: "^9.9.1",
196
- "eslint-plugin-astro": "^1.2.3",
187
+ eslint: "^9.11.1",
188
+ "eslint-plugin-astro": "^1.2.4",
197
189
  "eslint-plugin-format": "^0.1.2",
198
190
  "eslint-plugin-react-hooks": "^4.6.2",
199
- "eslint-plugin-react-refresh": "^0.4.11",
200
- "eslint-plugin-solid": "^0.14.2",
201
- "eslint-plugin-svelte": "^2.43.0",
202
- "eslint-typegen": "^0.3.1",
191
+ "eslint-plugin-react-refresh": "^0.4.12",
192
+ "eslint-plugin-solid": "^0.14.3",
193
+ "eslint-plugin-svelte": "^2.44.0",
194
+ "eslint-typegen": "^0.3.2",
203
195
  esno: "^4.7.0",
204
- execa: "^9.3.1",
196
+ execa: "^9.4.0",
205
197
  "fast-glob": "^3.3.2",
206
198
  "fs-extra": "^11.2.0",
207
- jiti: "^1.21.6",
208
- "lint-staged": "^15.2.9",
199
+ jiti: "^2.0.0",
200
+ "lint-staged": "^15.2.10",
209
201
  "prettier-plugin-astro": "^0.14.1",
210
202
  "prettier-plugin-slidev": "^1.0.5",
211
203
  rimraf: "^6.0.1",
212
204
  "simple-git-hooks": "^2.11.1",
213
205
  svelte: "^4.2.19",
214
- "svelte-eslint-parser": "^0.41.0",
215
- tsup: "^8.2.4",
216
- tsx: "^4.18.0",
217
- typescript: "^5.5.4",
218
- vitest: "^2.0.5",
219
- vue: "^3.4.38"
206
+ "svelte-eslint-parser": "^0.41.1",
207
+ tsup: "^8.3.0",
208
+ tsx: "^4.19.1",
209
+ typescript: "^5.6.2",
210
+ vitest: "^2.1.1",
211
+ vue: "^3.5.9"
220
212
  },
221
213
  resolutions: {
222
214
  "@eslint-community/eslint-utils": "^4.4.0",
223
- "@typescript-eslint/utils": "^8.3.0",
224
- eslint: "^9.9.1",
225
- tsx: "^4.18.0"
215
+ "@typescript-eslint/utils": "^8.7.0",
216
+ eslint: "^9.11.1",
217
+ tsx: "^4.19.1"
226
218
  },
227
219
  "simple-git-hooks": {
228
220
  "pre-commit": "npx lint-staged"
@@ -344,6 +336,22 @@ var dependenciesMap = {
344
336
  vue: []
345
337
  };
346
338
 
339
+ // src/cli/run.ts
340
+ var import_node_fs3 = __toESM(require("fs"), 1);
341
+ var import_node_path4 = __toESM(require("path"), 1);
342
+ var import_node_process4 = __toESM(require("process"), 1);
343
+ var p4 = __toESM(require("@clack/prompts"), 1);
344
+ var import_picocolors5 = __toESM(require("picocolors"), 1);
345
+
346
+ // src/cli/stages/update-eslint-files.ts
347
+ var import_node_fs = __toESM(require("fs"), 1);
348
+ var import_promises = __toESM(require("fs/promises"), 1);
349
+ var import_node_path = __toESM(require("path"), 1);
350
+ var import_node_process = __toESM(require("process"), 1);
351
+ var p = __toESM(require("@clack/prompts"), 1);
352
+ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
353
+ var import_picocolors2 = __toESM(require("picocolors"), 1);
354
+
347
355
  // src/cli/utils.ts
348
356
  var import_node_child_process = require("child_process");
349
357
  function isGitClean() {
@@ -356,7 +364,7 @@ function isGitClean() {
356
364
  }
357
365
  function getEslintConfigContent(mainConfig, additionalConfigs) {
358
366
  return `
359
- import jun from '@2030/eslint-config'
367
+ import jun from '@jun2030/eslint-config'
360
368
 
361
369
  export default jun({
362
370
  ${mainConfig}
@@ -366,20 +374,66 @@ ${config}
366
374
  `.trimStart();
367
375
  }
368
376
 
369
- // src/cli/stages/update-package-json.ts
370
- var import_node_path = __toESM(require("path"), 1);
371
- var import_promises = __toESM(require("fs/promises"), 1);
372
- var import_node_process = __toESM(require("process"), 1);
373
- var import_picocolors2 = __toESM(require("picocolors"), 1);
374
- var p = __toESM(require("@clack/prompts"), 1);
375
- async function updatePackageJson(result) {
377
+ // src/cli/stages/update-eslint-files.ts
378
+ async function updateEslintFiles(result) {
376
379
  const cwd = import_node_process.default.cwd();
380
+ const pathESLintIgnore = import_node_path.default.join(cwd, ".eslintignore");
377
381
  const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
378
- p.log.step(import_picocolors2.default.cyan(`Bumping @2030/eslint-config to v${package_default.version}`));
379
382
  const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
380
383
  const pkg = JSON.parse(pkgContent);
384
+ const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
385
+ const pathFlatConfig = import_node_path.default.join(cwd, configFileName);
386
+ const eslintIgnores = [];
387
+ if (import_node_fs.default.existsSync(pathESLintIgnore)) {
388
+ p.log.step(import_picocolors2.default.cyan(`Migrating existing .eslintignore`));
389
+ const content = await import_promises.default.readFile(pathESLintIgnore, "utf-8");
390
+ const parsed = (0, import_parse_gitignore.default)(content);
391
+ const globs = parsed.globs();
392
+ for (const glob of globs) {
393
+ if (glob.type === "ignore")
394
+ eslintIgnores.push(...glob.patterns);
395
+ else if (glob.type === "unignore")
396
+ eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
397
+ }
398
+ }
399
+ const configLines = [];
400
+ if (eslintIgnores.length)
401
+ configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
402
+ if (result.extra.includes("formatter"))
403
+ configLines.push(`formatters: true,`);
404
+ if (result.extra.includes("unocss"))
405
+ configLines.push(`unocss: true,`);
406
+ for (const framework of result.frameworks)
407
+ configLines.push(`${framework}: true,`);
408
+ const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
409
+ const additionalConfig = [];
410
+ const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
411
+ await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent);
412
+ p.log.success(import_picocolors2.default.green(`Created ${configFileName}`));
413
+ const files = import_node_fs.default.readdirSync(cwd);
414
+ const legacyConfig = [];
415
+ files.forEach((file) => {
416
+ if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
417
+ legacyConfig.push(file);
418
+ });
419
+ if (legacyConfig.length)
420
+ p.note(`${import_picocolors2.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
421
+ }
422
+
423
+ // src/cli/stages/update-package-json.ts
424
+ var import_promises2 = __toESM(require("fs/promises"), 1);
425
+ var import_node_path2 = __toESM(require("path"), 1);
426
+ var import_node_process2 = __toESM(require("process"), 1);
427
+ var p2 = __toESM(require("@clack/prompts"), 1);
428
+ var import_picocolors3 = __toESM(require("picocolors"), 1);
429
+ async function updatePackageJson(result) {
430
+ const cwd = import_node_process2.default.cwd();
431
+ const pathPackageJSON = import_node_path2.default.join(cwd, "package.json");
432
+ p2.log.step(import_picocolors3.default.cyan(`Bumping @jun2030/eslint-config to v${package_default.version}`));
433
+ const pkgContent = await import_promises2.default.readFile(pathPackageJSON, "utf-8");
434
+ const pkg = JSON.parse(pkgContent);
381
435
  pkg.devDependencies ??= {};
382
- pkg.devDependencies["@2030/eslint-config"] = `^${package_default.version}`;
436
+ pkg.devDependencies["@jun2030/eslint-config"] = `^${package_default.version}`;
383
437
  pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
384
438
  const addedPackages = [];
385
439
  if (result.extra.length) {
@@ -417,71 +471,18 @@ async function updatePackageJson(result) {
417
471
  }
418
472
  }
419
473
  if (addedPackages.length)
420
- p.note(`${import_picocolors2.default.dim(addedPackages.join(", "))}`, "Added packages");
421
- await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
422
- p.log.success(import_picocolors2.default.green(`Changes wrote to package.json`));
423
- }
424
-
425
- // src/cli/stages/update-eslint-files.ts
426
- var import_node_fs = __toESM(require("fs"), 1);
427
- var import_promises2 = __toESM(require("fs/promises"), 1);
428
- var import_node_process2 = __toESM(require("process"), 1);
429
- var import_node_path2 = __toESM(require("path"), 1);
430
- var import_picocolors3 = __toESM(require("picocolors"), 1);
431
- var p2 = __toESM(require("@clack/prompts"), 1);
432
- var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
433
- async function updateEslintFiles(result) {
434
- const cwd = import_node_process2.default.cwd();
435
- const pathESLintIgnore = import_node_path2.default.join(cwd, ".eslintignore");
436
- const pathPackageJSON = import_node_path2.default.join(cwd, "package.json");
437
- const pkgContent = await import_promises2.default.readFile(pathPackageJSON, "utf-8");
438
- const pkg = JSON.parse(pkgContent);
439
- const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
440
- const pathFlatConfig = import_node_path2.default.join(cwd, configFileName);
441
- const eslintIgnores = [];
442
- if (import_node_fs.default.existsSync(pathESLintIgnore)) {
443
- p2.log.step(import_picocolors3.default.cyan(`Migrating existing .eslintignore`));
444
- const content = await import_promises2.default.readFile(pathESLintIgnore, "utf-8");
445
- const parsed = (0, import_parse_gitignore.default)(content);
446
- const globs = parsed.globs();
447
- for (const glob of globs) {
448
- if (glob.type === "ignore")
449
- eslintIgnores.push(...glob.patterns);
450
- else if (glob.type === "unignore")
451
- eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
452
- }
453
- }
454
- const configLines = [];
455
- if (eslintIgnores.length)
456
- configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
457
- if (result.extra.includes("formatter"))
458
- configLines.push(`formatters: true,`);
459
- if (result.extra.includes("unocss"))
460
- configLines.push(`unocss: true,`);
461
- for (const framework of result.frameworks)
462
- configLines.push(`${framework}: true,`);
463
- const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
464
- const additionalConfig = [];
465
- const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
466
- await import_promises2.default.writeFile(pathFlatConfig, eslintConfigContent);
467
- p2.log.success(import_picocolors3.default.green(`Created ${configFileName}`));
468
- const files = import_node_fs.default.readdirSync(cwd);
469
- const legacyConfig = [];
470
- files.forEach((file) => {
471
- if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
472
- legacyConfig.push(file);
473
- });
474
- if (legacyConfig.length)
475
- p2.note(`${import_picocolors3.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
474
+ p2.note(`${import_picocolors3.default.dim(addedPackages.join(", "))}`, "Added packages");
475
+ await import_promises2.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
476
+ p2.log.success(import_picocolors3.default.green(`Changes wrote to package.json`));
476
477
  }
477
478
 
478
479
  // src/cli/stages/update-vscode-settings.ts
479
- var import_node_path3 = __toESM(require("path"), 1);
480
- var import_promises3 = __toESM(require("fs/promises"), 1);
481
480
  var import_node_fs2 = __toESM(require("fs"), 1);
481
+ var import_promises3 = __toESM(require("fs/promises"), 1);
482
+ var import_node_path3 = __toESM(require("path"), 1);
482
483
  var import_node_process3 = __toESM(require("process"), 1);
483
- var import_picocolors4 = __toESM(require("picocolors"), 1);
484
484
  var p3 = __toESM(require("@clack/prompts"), 1);
485
+ var import_picocolors4 = __toESM(require("picocolors"), 1);
485
486
  async function updateVscodeSettings(result) {
486
487
  const cwd = import_node_process3.default.cwd();
487
488
  if (!result.updateVscodeSettings)
@@ -580,9 +581,9 @@ async function run(options = {}) {
580
581
  // src/cli/index.ts
581
582
  function header() {
582
583
  console.log("\n");
583
- p5.intro(`${import_picocolors6.default.green(`@2030/eslint-config `)}${import_picocolors6.default.dim(`v${package_default.version}`)}`);
584
+ p5.intro(`${import_picocolors6.default.green(`@jun2030/eslint-config `)}${import_picocolors6.default.dim(`v${package_default.version}`)}`);
584
585
  }
585
- var instance = (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process5.default.argv)).scriptName("@2030/eslint-config").usage("").command(
586
+ var instance = (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process5.default.argv)).scriptName("@jun2030/eslint-config").usage("").command(
586
587
  "*",
587
588
  "Run the initialization or migration",
588
589
  (args) => args.option("yes", {