@kirklin/eslint-config 2.6.1 → 2.8.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,8 +12,8 @@ import c from "picocolors";
19
12
  var package_default = {
20
13
  name: "@kirklin/eslint-config",
21
14
  type: "module",
22
- version: "2.6.1",
23
- packageManager: "pnpm@9.9.0",
15
+ version: "2.8.0",
16
+ packageManager: "pnpm@9.12.3",
24
17
  description: "Kirk Lin's ESLint config",
25
18
  author: "Kirk Lin (https://github.com/kirklin/)",
26
19
  license: "MIT",
@@ -62,14 +55,14 @@ var package_default = {
62
55
  "@prettier/plugin-xml": "^3.4.1",
63
56
  "@unocss/eslint-plugin": ">=0.50.0",
64
57
  "astro-eslint-parser": "^1.0.2",
65
- eslint: ">=8.40.0",
58
+ eslint: "^9.10.0",
66
59
  "eslint-plugin-astro": "^1.2.0",
67
60
  "eslint-plugin-format": ">=0.1.0",
68
- "eslint-plugin-react-hooks": "^4.6.0",
61
+ "eslint-plugin-react-hooks": "^5.0.0",
69
62
  "eslint-plugin-react-refresh": "^0.4.4",
70
- "eslint-plugin-solid": "^0.13.2",
63
+ "eslint-plugin-solid": "^0.14.3",
71
64
  "eslint-plugin-svelte": ">=2.35.1",
72
- "prettier-plugin-astro": "^0.13.0",
65
+ "prettier-plugin-astro": "^0.14.0",
73
66
  "prettier-plugin-slidev": "^1.0.5",
74
67
  "svelte-eslint-parser": ">=0.37.0"
75
68
  },
@@ -115,88 +108,87 @@ var package_default = {
115
108
  }
116
109
  },
117
110
  dependencies: {
118
- "@antfu/install-pkg": "^0.4.1",
119
- "@clack/prompts": "^0.7.0",
120
- "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
121
- "@stylistic/eslint-plugin": "^2.6.4",
122
- "@typescript-eslint/eslint-plugin": "^8.3.0",
123
- "@typescript-eslint/parser": "^8.3.0",
124
- "@vitest/eslint-plugin": "^1.0.5",
125
- "eslint-config-flat-gitignore": "^0.1.8",
126
- "eslint-flat-config-utils": "^0.3.1",
111
+ "@antfu/install-pkg": "^0.5.0",
112
+ "@clack/prompts": "^0.8.2",
113
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
114
+ "@eslint/markdown": "^6.2.1",
115
+ "@stylistic/eslint-plugin": "^2.11.0",
116
+ "@typescript-eslint/eslint-plugin": "^8.16.0",
117
+ "@typescript-eslint/parser": "^8.16.0",
118
+ "@vitest/eslint-plugin": "^1.1.12",
119
+ "eslint-config-flat-gitignore": "^0.3.0",
120
+ "eslint-flat-config-utils": "^0.4.0",
127
121
  "eslint-merge-processors": "^0.1.0",
128
- "eslint-plugin-command": "^0.2.3",
129
- "eslint-plugin-import-x": "^4.0.0",
130
- "eslint-plugin-jsdoc": "^50.2.2",
131
- "eslint-plugin-jsonc": "^2.16.0",
132
- "eslint-plugin-kirklin": "^1.3.0",
133
- "eslint-plugin-markdown": "^5.1.0",
134
- "eslint-plugin-n": "^17.10.2",
122
+ "eslint-plugin-command": "^0.2.6",
123
+ "eslint-plugin-import-x": "^4.4.3",
124
+ "eslint-plugin-jsdoc": "^50.6.0",
125
+ "eslint-plugin-jsonc": "^2.18.2",
126
+ "eslint-plugin-kirklin": "^1.5.0",
127
+ "eslint-plugin-n": "^17.14.0",
135
128
  "eslint-plugin-no-only-tests": "^3.3.0",
136
- "eslint-plugin-perfectionist": "^3.2.0",
137
- "eslint-plugin-regexp": "^2.6.0",
129
+ "eslint-plugin-perfectionist": "^4.1.2",
130
+ "eslint-plugin-regexp": "^2.7.0",
138
131
  "eslint-plugin-toml": "^0.11.1",
139
- "eslint-plugin-unicorn": "^55.0.0",
140
- "eslint-plugin-unused-imports": "^4.1.3",
141
- "eslint-plugin-vue": "^9.27.0",
142
- "eslint-plugin-yml": "^1.14.0",
132
+ "eslint-plugin-unicorn": "^56.0.1",
133
+ "eslint-plugin-unused-imports": "^4.1.4",
134
+ "eslint-plugin-vue": "^9.31.0",
135
+ "eslint-plugin-yml": "^1.15.0",
143
136
  "eslint-processor-vue-blocks": "^0.1.2",
144
- globals: "^15.9.0",
137
+ globals: "^15.12.0",
145
138
  "jsonc-eslint-parser": "^2.4.0",
146
- "local-pkg": "^0.5.0",
139
+ "local-pkg": "^0.5.1",
147
140
  "parse-gitignore": "^2.0.0",
148
- picocolors: "^1.0.1",
141
+ picocolors: "^1.1.1",
149
142
  "toml-eslint-parser": "^0.10.0",
150
143
  "vue-eslint-parser": "^9.4.3",
151
144
  "yaml-eslint-parser": "^1.2.3",
152
145
  yargs: "^17.7.2"
153
146
  },
154
147
  devDependencies: {
155
- "@antfu/ni": "^0.23.0",
156
- "@eslint-react/eslint-plugin": "^1.12.2",
157
- "@eslint/config-inspector": "^0.5.4",
148
+ "@antfu/ni": "^0.23.1",
149
+ "@eslint-react/eslint-plugin": "^1.17.1",
150
+ "@eslint/config-inspector": "^0.5.6",
158
151
  "@kirklin/eslint-config": "workspace:*",
159
152
  "@prettier/plugin-xml": "^3.4.1",
160
- "@stylistic/eslint-plugin-migrate": "^2.6.4",
161
- "@types/eslint": "^9.6.1",
153
+ "@stylistic/eslint-plugin-migrate": "^2.11.0",
162
154
  "@types/fs-extra": "^11.0.4",
163
- "@types/node": "^22.5.0",
155
+ "@types/node": "^22.10.1",
164
156
  "@types/prompts": "^2.4.9",
165
157
  "@types/yargs": "^17.0.33",
166
- "@unocss/eslint-plugin": "^0.62.3",
167
- "astro-eslint-parser": "^1.0.2",
168
- bumpp: "^9.5.2",
169
- eslint: "^9.9.1",
170
- "eslint-plugin-astro": "^1.2.3",
158
+ "@unocss/eslint-plugin": "^0.64.1",
159
+ "astro-eslint-parser": "^1.1.0",
160
+ bumpp: "^9.8.1",
161
+ eslint: "^9.15.0",
162
+ "eslint-plugin-astro": "^1.3.1",
171
163
  "eslint-plugin-format": "^0.1.2",
172
- "eslint-plugin-react-hooks": "^4.6.2",
173
- "eslint-plugin-react-refresh": "^0.4.11",
174
- "eslint-plugin-solid": "^0.14.2",
175
- "eslint-plugin-svelte": "^2.43.0",
176
- "eslint-typegen": "^0.3.1",
177
- esno: "^4.7.0",
178
- execa: "^9.3.1",
164
+ "eslint-plugin-react-hooks": "^5.0.0",
165
+ "eslint-plugin-react-refresh": "^0.4.14",
166
+ "eslint-plugin-solid": "^0.14.4",
167
+ "eslint-plugin-svelte": "^2.46.0",
168
+ "eslint-typegen": "^0.3.2",
169
+ esno: "^4.8.0",
170
+ execa: "^9.5.1",
179
171
  "fast-glob": "^3.3.2",
180
172
  "fs-extra": "^11.2.0",
181
- jiti: "^1.21.6",
182
- "lint-staged": "^15.2.9",
173
+ jiti: "^2.4.0",
174
+ "lint-staged": "^15.2.10",
183
175
  "prettier-plugin-astro": "^0.14.1",
184
176
  "prettier-plugin-slidev": "^1.0.5",
185
177
  rimraf: "^6.0.1",
186
178
  "simple-git-hooks": "^2.11.1",
187
- svelte: "^4.2.19",
188
- "svelte-eslint-parser": "^0.41.0",
189
- tsup: "^8.2.4",
190
- tsx: "^4.19.0",
191
- typescript: "^5.5.4",
192
- vitest: "^2.0.5",
193
- vue: "^3.4.38"
179
+ svelte: "^5.2.10",
180
+ "svelte-eslint-parser": "^0.43.0",
181
+ tsup: "^8.3.5",
182
+ tsx: "^4.19.2",
183
+ typescript: "^5.7.2",
184
+ vitest: "^2.1.6",
185
+ vue: "^3.5.13"
194
186
  },
195
187
  resolutions: {
196
- "@eslint-community/eslint-utils": "^4.4.0",
197
- "@typescript-eslint/utils": "^8.3.0",
198
- eslint: "^9.9.1",
199
- tsx: "^4.18.0"
188
+ "@eslint-community/eslint-utils": "^4.4.1",
189
+ "@typescript-eslint/utils": "^8.16.0",
190
+ eslint: "^9.15.0",
191
+ tsx: "^4.19.2"
200
192
  },
201
193
  "simple-git-hooks": {
202
194
  "pre-commit": "npx lint-staged"
@@ -242,6 +234,7 @@ var vscodeSettingsString = `
242
234
  "html",
243
235
  "markdown",
244
236
  "json",
237
+ "json5",
245
238
  "jsonc",
246
239
  "yaml",
247
240
  "toml",
@@ -318,6 +311,22 @@ var dependenciesMap = {
318
311
  vue: []
319
312
  };
320
313
 
314
+ // src/cli/run.ts
315
+ import fs3 from "node:fs";
316
+ import path4 from "node:path";
317
+ import process4 from "node:process";
318
+ import * as p4 from "@clack/prompts";
319
+ import c5 from "picocolors";
320
+
321
+ // src/cli/stages/update-eslint-files.ts
322
+ import fs from "node:fs";
323
+ import fsp from "node:fs/promises";
324
+ import path from "node:path";
325
+ import process from "node:process";
326
+ import * as p from "@clack/prompts";
327
+ import parse from "parse-gitignore";
328
+ import c2 from "picocolors";
329
+
321
330
  // src/cli/utils.ts
322
331
  import { execSync } from "node:child_process";
323
332
  function isGitClean() {
@@ -340,18 +349,71 @@ ${config}
340
349
  `.trimStart();
341
350
  }
342
351
 
343
- // src/cli/stages/update-package-json.ts
344
- import path from "node:path";
345
- import fsp from "node:fs/promises";
346
- import process from "node:process";
347
- import c2 from "picocolors";
348
- import * as p from "@clack/prompts";
349
- async function updatePackageJson(result) {
352
+ // src/cli/stages/update-eslint-files.ts
353
+ async function updateEslintFiles(result) {
350
354
  const cwd = process.cwd();
355
+ const pathESLintIgnore = path.join(cwd, ".eslintignore");
351
356
  const pathPackageJSON = path.join(cwd, "package.json");
352
- p.log.step(c2.cyan(`Bumping @kirklin/eslint-config to v${package_default.version}`));
353
357
  const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
354
358
  const pkg = JSON.parse(pkgContent);
359
+ const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
360
+ const pathFlatConfig = path.join(cwd, configFileName);
361
+ const eslintIgnores = [];
362
+ if (fs.existsSync(pathESLintIgnore)) {
363
+ p.log.step(c2.cyan(`Migrating existing .eslintignore`));
364
+ const content = await fsp.readFile(pathESLintIgnore, "utf-8");
365
+ const parsed = parse(content);
366
+ const globs = parsed.globs();
367
+ for (const glob of globs) {
368
+ if (glob.type === "ignore") {
369
+ eslintIgnores.push(...glob.patterns);
370
+ } else if (glob.type === "unignore") {
371
+ eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
372
+ }
373
+ }
374
+ }
375
+ const configLines = [];
376
+ if (eslintIgnores.length) {
377
+ configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
378
+ }
379
+ if (result.extra.includes("formatter")) {
380
+ configLines.push(`formatters: true,`);
381
+ }
382
+ if (result.extra.includes("unocss")) {
383
+ configLines.push(`unocss: true,`);
384
+ }
385
+ for (const framework of result.frameworks) {
386
+ configLines.push(`${framework}: true,`);
387
+ }
388
+ const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
389
+ const additionalConfig = [];
390
+ const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
391
+ await fsp.writeFile(pathFlatConfig, eslintConfigContent);
392
+ p.log.success(c2.green(`Created ${configFileName}`));
393
+ const files = fs.readdirSync(cwd);
394
+ const legacyConfig = [];
395
+ files.forEach((file) => {
396
+ if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) {
397
+ legacyConfig.push(file);
398
+ }
399
+ });
400
+ if (legacyConfig.length) {
401
+ p.note(`${c2.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
402
+ }
403
+ }
404
+
405
+ // src/cli/stages/update-package-json.ts
406
+ import fsp2 from "node:fs/promises";
407
+ import path2 from "node:path";
408
+ import process2 from "node:process";
409
+ import * as p2 from "@clack/prompts";
410
+ import c3 from "picocolors";
411
+ async function updatePackageJson(result) {
412
+ const cwd = process2.cwd();
413
+ const pathPackageJSON = path2.join(cwd, "package.json");
414
+ p2.log.step(c3.cyan(`Bumping @kirklin/eslint-config to v${package_default.version}`));
415
+ const pkgContent = await fsp2.readFile(pathPackageJSON, "utf-8");
416
+ const pkg = JSON.parse(pkgContent);
355
417
  pkg.devDependencies ??= {};
356
418
  pkg.devDependencies["@kirklin/eslint-config"] = `^${package_default.version}`;
357
419
  pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
@@ -392,79 +454,19 @@ async function updatePackageJson(result) {
392
454
  }
393
455
  }
394
456
  if (addedPackages.length) {
395
- p.note(`${c2.dim(addedPackages.join(", "))}`, "Added packages");
396
- }
397
- await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
398
- p.log.success(c2.green(`Changes wrote to package.json`));
399
- }
400
-
401
- // src/cli/stages/update-eslint-files.ts
402
- import fs from "node:fs";
403
- import fsp2 from "node:fs/promises";
404
- import process2 from "node:process";
405
- import path2 from "node:path";
406
- import c3 from "picocolors";
407
- import * as p2 from "@clack/prompts";
408
- import parse from "parse-gitignore";
409
- async function updateEslintFiles(result) {
410
- const cwd = process2.cwd();
411
- const pathESLintIgnore = path2.join(cwd, ".eslintignore");
412
- const pathPackageJSON = path2.join(cwd, "package.json");
413
- const pkgContent = await fsp2.readFile(pathPackageJSON, "utf-8");
414
- const pkg = JSON.parse(pkgContent);
415
- const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
416
- const pathFlatConfig = path2.join(cwd, configFileName);
417
- const eslintIgnores = [];
418
- if (fs.existsSync(pathESLintIgnore)) {
419
- p2.log.step(c3.cyan(`Migrating existing .eslintignore`));
420
- const content = await fsp2.readFile(pathESLintIgnore, "utf-8");
421
- const parsed = parse(content);
422
- const globs = parsed.globs();
423
- for (const glob of globs) {
424
- if (glob.type === "ignore") {
425
- eslintIgnores.push(...glob.patterns);
426
- } else if (glob.type === "unignore") {
427
- eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
428
- }
429
- }
430
- }
431
- const configLines = [];
432
- if (eslintIgnores.length) {
433
- configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
434
- }
435
- if (result.extra.includes("formatter")) {
436
- configLines.push(`formatters: true,`);
437
- }
438
- if (result.extra.includes("unocss")) {
439
- configLines.push(`unocss: true,`);
440
- }
441
- for (const framework of result.frameworks) {
442
- configLines.push(`${framework}: true,`);
443
- }
444
- const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
445
- const additionalConfig = [];
446
- const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
447
- await fsp2.writeFile(pathFlatConfig, eslintConfigContent);
448
- p2.log.success(c3.green(`Created ${configFileName}`));
449
- const files = fs.readdirSync(cwd);
450
- const legacyConfig = [];
451
- files.forEach((file) => {
452
- if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) {
453
- legacyConfig.push(file);
454
- }
455
- });
456
- if (legacyConfig.length) {
457
- p2.note(`${c3.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
457
+ p2.note(`${c3.dim(addedPackages.join(", "))}`, "Added packages");
458
458
  }
459
+ await fsp2.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
460
+ p2.log.success(c3.green(`Changes wrote to package.json`));
459
461
  }
460
462
 
461
463
  // src/cli/stages/update-vscode-settings.ts
462
- import path3 from "node:path";
463
- import fsp3 from "node:fs/promises";
464
464
  import fs2 from "node:fs";
465
+ import fsp3 from "node:fs/promises";
466
+ import path3 from "node:path";
465
467
  import process3 from "node:process";
466
- import c4 from "picocolors";
467
468
  import * as p3 from "@clack/prompts";
469
+ import c4 from "picocolors";
468
470
  async function updateVscodeSettings(result) {
469
471
  const cwd = process3.cwd();
470
472
  if (!result.updateVscodeSettings) {
@@ -563,7 +565,7 @@ async function run(options = {}) {
563
565
  await updateEslintFiles(result);
564
566
  await updateVscodeSettings(result);
565
567
  p4.log.success(c5.green(`Setup completed`));
566
- p4.outro(`Now you can update the dependencies and run ${c5.blue("eslint . --fix")}
568
+ p4.outro(`Now you can update the dependencies by run ${c5.blue("pnpm install")} and run ${c5.blue("eslint . --fix")}
567
569
  `);
568
570
  }
569
571