@2030/eslint-config 1.0.0 → 2.0.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.js CHANGED
@@ -1,16 +1,9 @@
1
1
  // src/cli/index.ts
2
2
  import process5 from "node:process";
3
+ import * as p5 from "@clack/prompts";
3
4
  import c6 from "picocolors";
4
- import { hideBin } from "yargs/helpers";
5
5
  import yargs from "yargs";
6
- import * as p5 from "@clack/prompts";
7
-
8
- // src/cli/run.ts
9
- import fs3 from "node:fs";
10
- import path4 from "node:path";
11
- import process4 from "node:process";
12
- import c5 from "picocolors";
13
- import * as p4 from "@clack/prompts";
6
+ import { hideBin } from "yargs/helpers";
14
7
 
15
8
  // src/cli/constants.ts
16
9
  import c from "picocolors";
@@ -19,7 +12,7 @@ import c from "picocolors";
19
12
  var package_default = {
20
13
  name: "@2030/eslint-config",
21
14
  type: "module",
22
- version: "1.0.0",
15
+ version: "2.0.0",
23
16
  description: "Shareable ESLint config for conventional coding style",
24
17
  author: "Dai Jun <zijun2030@163.com>",
25
18
  license: "MIT",
@@ -55,20 +48,20 @@ var package_default = {
55
48
  prepare: "simple-git-hooks"
56
49
  },
57
50
  peerDependencies: {
58
- "@eslint-react/eslint-plugin": "^1.12.1",
51
+ "@eslint-react/eslint-plugin": "^1.5.8",
59
52
  "@prettier/plugin-xml": "^3.4.1",
60
- "@unocss/eslint-plugin": "^0.62.3",
53
+ "@unocss/eslint-plugin": ">=0.50.0",
61
54
  "astro-eslint-parser": "^1.0.2",
62
- eslint: "^9.9.1",
63
- "eslint-plugin-astro": "^1.2.3",
64
- "eslint-plugin-format": "^0.1.2",
65
- "eslint-plugin-react-hooks": "^4.6.2",
66
- "eslint-plugin-react-refresh": "^0.4.11",
67
- "eslint-plugin-solid": "^0.14.2",
68
- "eslint-plugin-svelte": "^2.43.0",
69
- "prettier-plugin-astro": "^0.14.1",
55
+ eslint: "^9.10.0",
56
+ "eslint-plugin-astro": "^1.2.0",
57
+ "eslint-plugin-format": ">=0.1.0",
58
+ "eslint-plugin-react-hooks": "^4.6.0",
59
+ "eslint-plugin-react-refresh": "^0.4.4",
60
+ "eslint-plugin-solid": "^0.14.3",
61
+ "eslint-plugin-svelte": ">=2.35.1",
62
+ "prettier-plugin-astro": "^0.13.0",
70
63
  "prettier-plugin-slidev": "^1.0.5",
71
- "svelte-eslint-parser": "^0.41.0"
64
+ "svelte-eslint-parser": ">=0.37.0"
72
65
  },
73
66
  peerDependenciesMeta: {
74
67
  "@eslint-react/eslint-plugin": {
@@ -115,34 +108,34 @@ var package_default = {
115
108
  "@antfu/install-pkg": "^0.4.1",
116
109
  "@clack/prompts": "^0.7.0",
117
110
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
118
- "@stylistic/eslint-plugin": "^2.6.4",
119
- "@typescript-eslint/eslint-plugin": "^8.3.0",
120
- "@typescript-eslint/parser": "^8.3.0",
121
- "@vitest/eslint-plugin": "^1.0.5",
122
- "eslint-config-flat-gitignore": "^0.1.8",
123
- "eslint-flat-config-utils": "^0.3.1",
111
+ "@eslint/markdown": "^6.1.0",
112
+ "@stylistic/eslint-plugin": "^2.8.0",
113
+ "@typescript-eslint/eslint-plugin": "^8.7.0",
114
+ "@typescript-eslint/parser": "^8.7.0",
115
+ "@vitest/eslint-plugin": "^1.1.4",
116
+ "eslint-config-flat-gitignore": "^0.3.0",
117
+ "eslint-flat-config-utils": "^0.4.0",
124
118
  "eslint-merge-processors": "^0.1.0",
125
- "eslint-plugin-antfu": "^2.3.6",
126
- "eslint-plugin-command": "^0.2.3",
127
- "eslint-plugin-import-x": "^4.0.0",
128
- "eslint-plugin-jsdoc": "^50.2.2",
119
+ "eslint-plugin-antfu": "^2.7.0",
120
+ "eslint-plugin-command": "^0.2.6",
121
+ "eslint-plugin-import-x": "^4.3.0",
122
+ "eslint-plugin-jsdoc": "^50.3.0",
129
123
  "eslint-plugin-jsonc": "^2.16.0",
130
- "eslint-plugin-markdown": "^5.1.0",
131
- "eslint-plugin-n": "^17.10.2",
124
+ "eslint-plugin-n": "^17.10.3",
132
125
  "eslint-plugin-no-only-tests": "^3.3.0",
133
- "eslint-plugin-perfectionist": "^3.2.0",
126
+ "eslint-plugin-perfectionist": "^3.7.0",
134
127
  "eslint-plugin-regexp": "^2.6.0",
135
128
  "eslint-plugin-toml": "^0.11.1",
136
129
  "eslint-plugin-unicorn": "^55.0.0",
137
- "eslint-plugin-unused-imports": "^4.1.3",
138
- "eslint-plugin-vue": "^9.27.0",
130
+ "eslint-plugin-unused-imports": "^4.1.4",
131
+ "eslint-plugin-vue": "^9.28.0",
139
132
  "eslint-plugin-yml": "^1.14.0",
140
133
  "eslint-processor-vue-blocks": "^0.1.2",
141
134
  globals: "^15.9.0",
142
135
  "jsonc-eslint-parser": "^2.4.0",
143
136
  "local-pkg": "^0.5.0",
144
137
  "parse-gitignore": "^2.0.0",
145
- picocolors: "^1.0.1",
138
+ picocolors: "^1.1.0",
146
139
  "toml-eslint-parser": "^0.10.0",
147
140
  "vue-eslint-parser": "^9.4.3",
148
141
  "yaml-eslint-parser": "^1.2.3",
@@ -150,50 +143,49 @@ var package_default = {
150
143
  },
151
144
  devDependencies: {
152
145
  "@2030/eslint-config": "workspace:*",
153
- "@antfu/ni": "^0.22.4",
154
- "@eslint-react/eslint-plugin": "^1.12.1",
146
+ "@antfu/ni": "^0.23.0",
147
+ "@eslint-react/eslint-plugin": "^1.14.2",
155
148
  "@eslint/config-inspector": "^0.5.4",
156
149
  "@prettier/plugin-xml": "^3.4.1",
157
- "@stylistic/eslint-plugin-migrate": "^2.6.4",
158
- "@types/eslint": "^9.6.1",
150
+ "@stylistic/eslint-plugin-migrate": "^2.8.0",
159
151
  "@types/fs-extra": "^11.0.4",
160
- "@types/node": "^22.5.0",
152
+ "@types/node": "^22.7.3",
161
153
  "@types/prompts": "^2.4.9",
162
154
  "@types/yargs": "^17.0.33",
163
- "@unocss/eslint-plugin": "^0.62.3",
164
- "astro-eslint-parser": "^1.0.2",
155
+ "@unocss/eslint-plugin": "^0.62.4",
156
+ "astro-eslint-parser": "^1.0.3",
165
157
  bumpp: "^9.5.2",
166
- eslint: "^9.9.1",
167
- "eslint-plugin-astro": "^1.2.3",
158
+ eslint: "^9.11.1",
159
+ "eslint-plugin-astro": "^1.2.4",
168
160
  "eslint-plugin-format": "^0.1.2",
169
161
  "eslint-plugin-react-hooks": "^4.6.2",
170
- "eslint-plugin-react-refresh": "^0.4.11",
171
- "eslint-plugin-solid": "^0.14.2",
172
- "eslint-plugin-svelte": "^2.43.0",
173
- "eslint-typegen": "^0.3.1",
162
+ "eslint-plugin-react-refresh": "^0.4.12",
163
+ "eslint-plugin-solid": "^0.14.3",
164
+ "eslint-plugin-svelte": "^2.44.0",
165
+ "eslint-typegen": "^0.3.2",
174
166
  esno: "^4.7.0",
175
- execa: "^9.3.1",
167
+ execa: "^9.4.0",
176
168
  "fast-glob": "^3.3.2",
177
169
  "fs-extra": "^11.2.0",
178
- jiti: "^1.21.6",
179
- "lint-staged": "^15.2.9",
170
+ jiti: "^2.0.0",
171
+ "lint-staged": "^15.2.10",
180
172
  "prettier-plugin-astro": "^0.14.1",
181
173
  "prettier-plugin-slidev": "^1.0.5",
182
174
  rimraf: "^6.0.1",
183
175
  "simple-git-hooks": "^2.11.1",
184
176
  svelte: "^4.2.19",
185
- "svelte-eslint-parser": "^0.41.0",
186
- tsup: "^8.2.4",
187
- tsx: "^4.18.0",
188
- typescript: "^5.5.4",
189
- vitest: "^2.0.5",
190
- vue: "^3.4.38"
177
+ "svelte-eslint-parser": "^0.41.1",
178
+ tsup: "^8.3.0",
179
+ tsx: "^4.19.1",
180
+ typescript: "^5.6.2",
181
+ vitest: "^2.1.1",
182
+ vue: "^3.5.9"
191
183
  },
192
184
  resolutions: {
193
185
  "@eslint-community/eslint-utils": "^4.4.0",
194
- "@typescript-eslint/utils": "^8.3.0",
195
- eslint: "^9.9.1",
196
- tsx: "^4.18.0"
186
+ "@typescript-eslint/utils": "^8.7.0",
187
+ eslint: "^9.11.1",
188
+ tsx: "^4.19.1"
197
189
  },
198
190
  "simple-git-hooks": {
199
191
  "pre-commit": "npx lint-staged"
@@ -315,6 +307,22 @@ var dependenciesMap = {
315
307
  vue: []
316
308
  };
317
309
 
310
+ // src/cli/run.ts
311
+ import fs3 from "node:fs";
312
+ import path4 from "node:path";
313
+ import process4 from "node:process";
314
+ import * as p4 from "@clack/prompts";
315
+ import c5 from "picocolors";
316
+
317
+ // src/cli/stages/update-eslint-files.ts
318
+ import fs from "node:fs";
319
+ import fsp from "node:fs/promises";
320
+ import path from "node:path";
321
+ import process from "node:process";
322
+ import * as p from "@clack/prompts";
323
+ import parse from "parse-gitignore";
324
+ import c2 from "picocolors";
325
+
318
326
  // src/cli/utils.ts
319
327
  import { execSync } from "node:child_process";
320
328
  function isGitClean() {
@@ -327,7 +335,7 @@ function isGitClean() {
327
335
  }
328
336
  function getEslintConfigContent(mainConfig, additionalConfigs) {
329
337
  return `
330
- import jun from '@2030/eslint-config'
338
+ import jun from '@jun2030/eslint-config'
331
339
 
332
340
  export default jun({
333
341
  ${mainConfig}
@@ -337,20 +345,66 @@ ${config}
337
345
  `.trimStart();
338
346
  }
339
347
 
340
- // src/cli/stages/update-package-json.ts
341
- import path from "node:path";
342
- import fsp from "node:fs/promises";
343
- import process from "node:process";
344
- import c2 from "picocolors";
345
- import * as p from "@clack/prompts";
346
- async function updatePackageJson(result) {
348
+ // src/cli/stages/update-eslint-files.ts
349
+ async function updateEslintFiles(result) {
347
350
  const cwd = process.cwd();
351
+ const pathESLintIgnore = path.join(cwd, ".eslintignore");
348
352
  const pathPackageJSON = path.join(cwd, "package.json");
349
- p.log.step(c2.cyan(`Bumping @2030/eslint-config to v${package_default.version}`));
350
353
  const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
351
354
  const pkg = JSON.parse(pkgContent);
355
+ const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
356
+ const pathFlatConfig = path.join(cwd, configFileName);
357
+ const eslintIgnores = [];
358
+ if (fs.existsSync(pathESLintIgnore)) {
359
+ p.log.step(c2.cyan(`Migrating existing .eslintignore`));
360
+ const content = await fsp.readFile(pathESLintIgnore, "utf-8");
361
+ const parsed = parse(content);
362
+ const globs = parsed.globs();
363
+ for (const glob of globs) {
364
+ if (glob.type === "ignore")
365
+ eslintIgnores.push(...glob.patterns);
366
+ else if (glob.type === "unignore")
367
+ eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
368
+ }
369
+ }
370
+ const configLines = [];
371
+ if (eslintIgnores.length)
372
+ configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
373
+ if (result.extra.includes("formatter"))
374
+ configLines.push(`formatters: true,`);
375
+ if (result.extra.includes("unocss"))
376
+ configLines.push(`unocss: true,`);
377
+ for (const framework of result.frameworks)
378
+ configLines.push(`${framework}: true,`);
379
+ const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
380
+ const additionalConfig = [];
381
+ const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
382
+ await fsp.writeFile(pathFlatConfig, eslintConfigContent);
383
+ p.log.success(c2.green(`Created ${configFileName}`));
384
+ const files = fs.readdirSync(cwd);
385
+ const legacyConfig = [];
386
+ files.forEach((file) => {
387
+ if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
388
+ legacyConfig.push(file);
389
+ });
390
+ if (legacyConfig.length)
391
+ p.note(`${c2.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
392
+ }
393
+
394
+ // src/cli/stages/update-package-json.ts
395
+ import fsp2 from "node:fs/promises";
396
+ import path2 from "node:path";
397
+ import process2 from "node:process";
398
+ import * as p2 from "@clack/prompts";
399
+ import c3 from "picocolors";
400
+ async function updatePackageJson(result) {
401
+ const cwd = process2.cwd();
402
+ const pathPackageJSON = path2.join(cwd, "package.json");
403
+ p2.log.step(c3.cyan(`Bumping @jun2030/eslint-config to v${package_default.version}`));
404
+ const pkgContent = await fsp2.readFile(pathPackageJSON, "utf-8");
405
+ const pkg = JSON.parse(pkgContent);
352
406
  pkg.devDependencies ??= {};
353
- pkg.devDependencies["@2030/eslint-config"] = `^${package_default.version}`;
407
+ pkg.devDependencies["@jun2030/eslint-config"] = `^${package_default.version}`;
354
408
  pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
355
409
  const addedPackages = [];
356
410
  if (result.extra.length) {
@@ -388,71 +442,18 @@ async function updatePackageJson(result) {
388
442
  }
389
443
  }
390
444
  if (addedPackages.length)
391
- p.note(`${c2.dim(addedPackages.join(", "))}`, "Added packages");
392
- await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
393
- p.log.success(c2.green(`Changes wrote to package.json`));
394
- }
395
-
396
- // src/cli/stages/update-eslint-files.ts
397
- import fs from "node:fs";
398
- import fsp2 from "node:fs/promises";
399
- import process2 from "node:process";
400
- import path2 from "node:path";
401
- import c3 from "picocolors";
402
- import * as p2 from "@clack/prompts";
403
- import parse from "parse-gitignore";
404
- async function updateEslintFiles(result) {
405
- const cwd = process2.cwd();
406
- const pathESLintIgnore = path2.join(cwd, ".eslintignore");
407
- const pathPackageJSON = path2.join(cwd, "package.json");
408
- const pkgContent = await fsp2.readFile(pathPackageJSON, "utf-8");
409
- const pkg = JSON.parse(pkgContent);
410
- const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
411
- const pathFlatConfig = path2.join(cwd, configFileName);
412
- const eslintIgnores = [];
413
- if (fs.existsSync(pathESLintIgnore)) {
414
- p2.log.step(c3.cyan(`Migrating existing .eslintignore`));
415
- const content = await fsp2.readFile(pathESLintIgnore, "utf-8");
416
- const parsed = parse(content);
417
- const globs = parsed.globs();
418
- for (const glob of globs) {
419
- if (glob.type === "ignore")
420
- eslintIgnores.push(...glob.patterns);
421
- else if (glob.type === "unignore")
422
- eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
423
- }
424
- }
425
- const configLines = [];
426
- if (eslintIgnores.length)
427
- configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
428
- if (result.extra.includes("formatter"))
429
- configLines.push(`formatters: true,`);
430
- if (result.extra.includes("unocss"))
431
- configLines.push(`unocss: true,`);
432
- for (const framework of result.frameworks)
433
- configLines.push(`${framework}: true,`);
434
- const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
435
- const additionalConfig = [];
436
- const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
437
- await fsp2.writeFile(pathFlatConfig, eslintConfigContent);
438
- p2.log.success(c3.green(`Created ${configFileName}`));
439
- const files = fs.readdirSync(cwd);
440
- const legacyConfig = [];
441
- files.forEach((file) => {
442
- if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
443
- legacyConfig.push(file);
444
- });
445
- if (legacyConfig.length)
446
- p2.note(`${c3.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
445
+ p2.note(`${c3.dim(addedPackages.join(", "))}`, "Added packages");
446
+ await fsp2.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
447
+ p2.log.success(c3.green(`Changes wrote to package.json`));
447
448
  }
448
449
 
449
450
  // src/cli/stages/update-vscode-settings.ts
450
- import path3 from "node:path";
451
- import fsp3 from "node:fs/promises";
452
451
  import fs2 from "node:fs";
452
+ import fsp3 from "node:fs/promises";
453
+ import path3 from "node:path";
453
454
  import process3 from "node:process";
454
- import c4 from "picocolors";
455
455
  import * as p3 from "@clack/prompts";
456
+ import c4 from "picocolors";
456
457
  async function updateVscodeSettings(result) {
457
458
  const cwd = process3.cwd();
458
459
  if (!result.updateVscodeSettings)
@@ -551,9 +552,9 @@ async function run(options = {}) {
551
552
  // src/cli/index.ts
552
553
  function header() {
553
554
  console.log("\n");
554
- p5.intro(`${c6.green(`@2030/eslint-config `)}${c6.dim(`v${package_default.version}`)}`);
555
+ p5.intro(`${c6.green(`@jun2030/eslint-config `)}${c6.dim(`v${package_default.version}`)}`);
555
556
  }
556
- var instance = yargs(hideBin(process5.argv)).scriptName("@2030/eslint-config").usage("").command(
557
+ var instance = yargs(hideBin(process5.argv)).scriptName("@jun2030/eslint-config").usage("").command(
557
558
  "*",
558
559
  "Run the initialization or migration",
559
560
  (args) => args.option("yes", {