@dhzh/eslint-config 1.12.1 → 1.13.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.
@@ -28,7 +28,7 @@ var import_ansis5 = __toESM(require("ansis"), 1);
28
28
  var import_cac = require("cac");
29
29
 
30
30
  // package.json
31
- var version = "1.12.1";
31
+ var version = "1.13.0";
32
32
  var package_default = {
33
33
  name: "@dhzh/eslint-config",
34
34
  type: "module",
@@ -117,14 +117,14 @@ var package_default = {
117
117
  "eslint-plugin-toml": "^0.12.0",
118
118
  "eslint-plugin-unicorn": "^60.0.0",
119
119
  "eslint-plugin-unused-imports": "^4.1.4",
120
- "eslint-plugin-vue": "^10.1.0",
120
+ "eslint-plugin-vue": "^10.4.0",
121
121
  "eslint-plugin-yml": "^1.18.0",
122
122
  "eslint-processor-vue-blocks": "^2.0.0",
123
123
  globals: "^16.0.0",
124
124
  "jsonc-eslint-parser": "^2.4.0",
125
125
  "local-pkg": "^1.1.1",
126
126
  "toml-eslint-parser": "^0.10.0",
127
- "typescript-eslint": "^8.31.0",
127
+ "typescript-eslint": "^8.42.0",
128
128
  "vue-eslint-parser": "^10.1.3",
129
129
  "yaml-eslint-parser": "^1.3.0"
130
130
  },
@@ -135,7 +135,7 @@ var package_default = {
135
135
  "@types/node": "^22.18.0",
136
136
  bumpp: "^10.1.0",
137
137
  "bundle-require": "^5.1.0",
138
- eslint: "^9.25.1",
138
+ eslint: "^9.34.0",
139
139
  "eslint-typegen": "^2.1.0",
140
140
  "lint-staged": "^16.0.0",
141
141
  "simple-git-hooks": "^2.13.0",
@@ -273,20 +273,23 @@ var vscodeSettingsString = `
273
273
  "editor.defaultFormatter": "dbaeumer.vscode-eslint"
274
274
  }
275
275
  `;
276
- var eslintConfigContent = `import { defineConfig } from '@dhzh/eslint-config';
276
+ var eslintConfigContent = (options) => `import { defineConfig } from '@dhzh/eslint-config';
277
277
 
278
- export default defineConfig();
278
+ export default defineConfig({
279
+ configs: {
280
+ json: {
281
+ packageJsonRequireTypes: ${!options.hasNest},
282
+ },
283
+ },
284
+ });
279
285
  `;
280
286
 
281
287
  // src/cli/stages/update-eslint-config.ts
282
- async function updateEslintConfig() {
288
+ async function updateEslintConfig(options) {
283
289
  const cwd = import_node_process.default.cwd();
284
- const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
285
- const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf8");
286
- const pkg = JSON.parse(pkgContent);
287
- const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
290
+ const configFileName = "eslint.config.js";
288
291
  const pathFlatConfig = import_node_path.default.join(cwd, configFileName);
289
- await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent);
292
+ await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent(options));
290
293
  p.log.success(import_ansis.default.green`Created ${configFileName}`);
291
294
  }
292
295
 
@@ -339,9 +342,9 @@ async function updateVscodeSettings() {
339
342
  }
340
343
 
341
344
  // src/cli/run.ts
342
- async function run() {
345
+ async function run(options) {
343
346
  await updatePackageJson();
344
- await updateEslintConfig();
347
+ await updateEslintConfig(options);
345
348
  await updateVscodeSettings();
346
349
  p4.log.success(import_ansis4.default.green`Setup completed`);
347
350
  p4.outro(`Now you can update the dependencies by run ${import_ansis4.default.blue("pnpm i")} and run ${import_ansis4.default.blue("eslint --fix")}
@@ -353,8 +356,20 @@ var cli = (0, import_cac.cac)("@dhzh/eslint-config");
353
356
  cli.command("", "Run the initialization or migration").action(async () => {
354
357
  console.log("\n");
355
358
  p5.intro(`${import_ansis5.default.green`@dhzh/eslint-config `}${import_ansis5.default.dim`v${version}`}`);
359
+ const options = {
360
+ hasNest: false
361
+ };
362
+ const hasNest = await p5.confirm({
363
+ message: "Is NestJS a part of the current project?"
364
+ });
365
+ if (p5.isCancel(hasNest)) {
366
+ p5.cancel("Operation cancelled");
367
+ throw new Error("Operation cancelled");
368
+ } else {
369
+ options.hasNest = hasNest;
370
+ }
356
371
  try {
357
- await run();
372
+ await run(options);
358
373
  } catch (error) {
359
374
  p5.log.error(import_ansis5.default.inverse.red(" Failed to migrate "));
360
375
  p5.log.error(import_ansis5.default.red`✘ ${String(error)}`);
package/dist/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import c4 from "ansis";
4
4
  import { cac } from "cac";
5
5
 
6
6
  // package.json
7
- var version = "1.12.1";
7
+ var version = "1.13.0";
8
8
  var package_default = {
9
9
  name: "@dhzh/eslint-config",
10
10
  type: "module",
@@ -93,14 +93,14 @@ var package_default = {
93
93
  "eslint-plugin-toml": "^0.12.0",
94
94
  "eslint-plugin-unicorn": "^60.0.0",
95
95
  "eslint-plugin-unused-imports": "^4.1.4",
96
- "eslint-plugin-vue": "^10.1.0",
96
+ "eslint-plugin-vue": "^10.4.0",
97
97
  "eslint-plugin-yml": "^1.18.0",
98
98
  "eslint-processor-vue-blocks": "^2.0.0",
99
99
  globals: "^16.0.0",
100
100
  "jsonc-eslint-parser": "^2.4.0",
101
101
  "local-pkg": "^1.1.1",
102
102
  "toml-eslint-parser": "^0.10.0",
103
- "typescript-eslint": "^8.31.0",
103
+ "typescript-eslint": "^8.42.0",
104
104
  "vue-eslint-parser": "^10.1.3",
105
105
  "yaml-eslint-parser": "^1.3.0"
106
106
  },
@@ -111,7 +111,7 @@ var package_default = {
111
111
  "@types/node": "^22.18.0",
112
112
  bumpp: "^10.1.0",
113
113
  "bundle-require": "^5.1.0",
114
- eslint: "^9.25.1",
114
+ eslint: "^9.34.0",
115
115
  "eslint-typegen": "^2.1.0",
116
116
  "lint-staged": "^16.0.0",
117
117
  "simple-git-hooks": "^2.13.0",
@@ -249,20 +249,23 @@ var vscodeSettingsString = `
249
249
  "editor.defaultFormatter": "dbaeumer.vscode-eslint"
250
250
  }
251
251
  `;
252
- var eslintConfigContent = `import { defineConfig } from '@dhzh/eslint-config';
252
+ var eslintConfigContent = (options) => `import { defineConfig } from '@dhzh/eslint-config';
253
253
 
254
- export default defineConfig();
254
+ export default defineConfig({
255
+ configs: {
256
+ json: {
257
+ packageJsonRequireTypes: ${!options.hasNest},
258
+ },
259
+ },
260
+ });
255
261
  `;
256
262
 
257
263
  // src/cli/stages/update-eslint-config.ts
258
- async function updateEslintConfig() {
264
+ async function updateEslintConfig(options) {
259
265
  const cwd = process.cwd();
260
- const pathPackageJSON = path.join(cwd, "package.json");
261
- const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
262
- const pkg = JSON.parse(pkgContent);
263
- const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
266
+ const configFileName = "eslint.config.js";
264
267
  const pathFlatConfig = path.join(cwd, configFileName);
265
- await fsp.writeFile(pathFlatConfig, eslintConfigContent);
268
+ await fsp.writeFile(pathFlatConfig, eslintConfigContent(options));
266
269
  p.log.success(c.green`Created ${configFileName}`);
267
270
  }
268
271
 
@@ -315,9 +318,9 @@ async function updateVscodeSettings() {
315
318
  }
316
319
 
317
320
  // src/cli/run.ts
318
- async function run() {
321
+ async function run(options) {
319
322
  await updatePackageJson();
320
- await updateEslintConfig();
323
+ await updateEslintConfig(options);
321
324
  await updateVscodeSettings();
322
325
  p4.log.success(c3.green`Setup completed`);
323
326
  p4.outro(`Now you can update the dependencies by run ${c3.blue("pnpm i")} and run ${c3.blue("eslint --fix")}
@@ -329,8 +332,20 @@ var cli = cac("@dhzh/eslint-config");
329
332
  cli.command("", "Run the initialization or migration").action(async () => {
330
333
  console.log("\n");
331
334
  p5.intro(`${c4.green`@dhzh/eslint-config `}${c4.dim`v${version}`}`);
335
+ const options = {
336
+ hasNest: false
337
+ };
338
+ const hasNest = await p5.confirm({
339
+ message: "Is NestJS a part of the current project?"
340
+ });
341
+ if (p5.isCancel(hasNest)) {
342
+ p5.cancel("Operation cancelled");
343
+ throw new Error("Operation cancelled");
344
+ } else {
345
+ options.hasNest = hasNest;
346
+ }
332
347
  try {
333
- await run();
348
+ await run(options);
334
349
  } catch (error) {
335
350
  p5.log.error(c4.inverse.red(" Failed to migrate "));
336
351
  p5.log.error(c4.red`✘ ${String(error)}`);
package/dist/index.cjs CHANGED
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- defineConfig: () => defineConfig
33
+ defineConfig: () => defineConfig3
34
34
  });
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
@@ -268,6 +268,7 @@ function react(options = {}) {
268
268
  }
269
269
 
270
270
  // src/configs/vue.ts
271
+ var import_config = require("eslint/config");
271
272
  var import_js = __toESM(require("@eslint/js"), 1);
272
273
  var import_typescript_eslint = __toESM(require("typescript-eslint"), 1);
273
274
  var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
@@ -276,7 +277,7 @@ var import_eslint_merge_processors = require("eslint-merge-processors");
276
277
  var import_eslint_processor_vue_blocks = __toESM(require("eslint-processor-vue-blocks"), 1);
277
278
  function vue(options = {}) {
278
279
  const { overrides = {} } = options;
279
- return import_typescript_eslint.default.config(
280
+ return (0, import_config.defineConfig)(
280
281
  {
281
282
  ...import_js.default.configs.recommended,
282
283
  name: `${RULE_PREFIX}/vue/shared/javascript`,
@@ -584,11 +585,12 @@ function stylistic(options = {}) {
584
585
 
585
586
  // src/configs/typescript.ts
586
587
  var import_node_process = __toESM(require("process"), 1);
588
+ var import_config2 = require("eslint/config");
587
589
  var import_typescript_eslint2 = __toESM(require("typescript-eslint"), 1);
588
590
  function typescript(options = {}) {
589
591
  const { overrides = {}, typeSafe = false, strict = false } = options;
590
592
  return [
591
- ...import_typescript_eslint2.default.config(
593
+ ...(0, import_config2.defineConfig)(
592
594
  import_typescript_eslint2.default.configs.base,
593
595
  import_typescript_eslint2.default.configs.recommendedTypeChecked,
594
596
  import_typescript_eslint2.default.configs.strictTypeChecked,
@@ -1029,9 +1031,12 @@ var import_eslint_plugin_jsonc = __toESM(require("eslint-plugin-jsonc"), 1);
1029
1031
  var import_eslint_plugin_package_json = __toESM(require("eslint-plugin-package-json"), 1);
1030
1032
  var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
1031
1033
  var import_eslint_plugin_hyoban2 = __toESM(require("eslint-plugin-hyoban"), 1);
1032
- var import_local_pkg2 = require("local-pkg");
1033
1034
  function json(options = {}) {
1034
- const { overrides = { core: {}, packageJson: {} }, indent = 2 } = options;
1035
+ const {
1036
+ overrides = { core: {}, packageJson: {} },
1037
+ indent = 2,
1038
+ packageJsonRequireTypes = true
1039
+ } = options;
1035
1040
  return [
1036
1041
  ...import_eslint_plugin_jsonc.default.configs["flat/recommended-with-json"].map((item) => ({
1037
1042
  ...item,
@@ -1181,7 +1186,7 @@ function json(options = {}) {
1181
1186
  ]
1182
1187
  }
1183
1188
  ],
1184
- "package-json/require-types": (0, import_local_pkg2.isPackageExists)("@nestjs/core") ? "off" : "error",
1189
+ "package-json/require-types": packageJsonRequireTypes ? "error" : "off",
1185
1190
  ...overrides.packageJson
1186
1191
  }
1187
1192
  }
@@ -1508,10 +1513,10 @@ function format(options = {}) {
1508
1513
 
1509
1514
  // src/configs/tailwindcss.ts
1510
1515
  var import_eslint_plugin_tailwindcss = __toESM(require("eslint-plugin-tailwindcss"), 1);
1511
- var import_local_pkg3 = require("local-pkg");
1516
+ var import_local_pkg2 = require("local-pkg");
1512
1517
  function tailwindcss(options = {}) {
1513
1518
  const { overrides = {} } = options;
1514
- return (0, import_local_pkg3.isPackageExists)("tailwindcss") ? [
1519
+ return (0, import_local_pkg2.isPackageExists)("tailwindcss") ? [
1515
1520
  ...import_eslint_plugin_tailwindcss.default.configs["flat/recommended"].map((item) => ({
1516
1521
  ...item,
1517
1522
  name: `${RULE_PREFIX}/tailwindcss/shared/${item.name?.replace("tailwindcss:", "")}`,
@@ -1530,10 +1535,10 @@ function tailwindcss(options = {}) {
1530
1535
 
1531
1536
  // src/configs/unocss.ts
1532
1537
  var import_flat = __toESM(require("@unocss/eslint-config/flat"), 1);
1533
- var import_local_pkg4 = require("local-pkg");
1538
+ var import_local_pkg3 = require("local-pkg");
1534
1539
  function unocss(options = {}) {
1535
1540
  const { overrides = {} } = options;
1536
- const isUnocssEnabled = (0, import_local_pkg4.isPackageExists)("unocss");
1541
+ const isUnocssEnabled = (0, import_local_pkg3.isPackageExists)("unocss");
1537
1542
  if (!isUnocssEnabled) {
1538
1543
  return [];
1539
1544
  }
@@ -1798,7 +1803,7 @@ function disables(options = {}) {
1798
1803
  }
1799
1804
 
1800
1805
  // src/index.ts
1801
- function defineConfig(options = {}) {
1806
+ function defineConfig3(options = {}) {
1802
1807
  const { configs: configs2 = {}, ignorePatterns = [] } = options;
1803
1808
  return [
1804
1809
  ...react(configs2.react),
package/dist/index.d.cts CHANGED
@@ -147,6 +147,7 @@ interface IJsonConfigsOptions {
147
147
  core?: Record<string, Linter.RuleEntry>;
148
148
  packageJson?: Record<string, Linter.RuleEntry>;
149
149
  };
150
+ packageJsonRequireTypes?: boolean;
150
151
  }
151
152
  interface IUnicornConfigsOptions extends IConfigsOptions {
152
153
  }
package/dist/index.d.ts CHANGED
@@ -147,6 +147,7 @@ interface IJsonConfigsOptions {
147
147
  core?: Record<string, Linter.RuleEntry>;
148
148
  packageJson?: Record<string, Linter.RuleEntry>;
149
149
  };
150
+ packageJsonRequireTypes?: boolean;
150
151
  }
151
152
  interface IUnicornConfigsOptions extends IConfigsOptions {
152
153
  }
package/dist/index.js CHANGED
@@ -232,6 +232,7 @@ function react(options = {}) {
232
232
  }
233
233
 
234
234
  // src/configs/vue.ts
235
+ import { defineConfig } from "eslint/config";
235
236
  import js from "@eslint/js";
236
237
  import tseslint from "typescript-eslint";
237
238
  import pluginVue from "eslint-plugin-vue";
@@ -240,7 +241,7 @@ import { mergeProcessors } from "eslint-merge-processors";
240
241
  import processorVueBlocks from "eslint-processor-vue-blocks";
241
242
  function vue(options = {}) {
242
243
  const { overrides = {} } = options;
243
- return tseslint.config(
244
+ return defineConfig(
244
245
  {
245
246
  ...js.configs.recommended,
246
247
  name: `${RULE_PREFIX}/vue/shared/javascript`,
@@ -548,11 +549,12 @@ function stylistic(options = {}) {
548
549
 
549
550
  // src/configs/typescript.ts
550
551
  import process from "node:process";
552
+ import { defineConfig as defineConfig2 } from "eslint/config";
551
553
  import tseslint2 from "typescript-eslint";
552
554
  function typescript(options = {}) {
553
555
  const { overrides = {}, typeSafe = false, strict = false } = options;
554
556
  return [
555
- ...tseslint2.config(
557
+ ...defineConfig2(
556
558
  tseslint2.configs.base,
557
559
  tseslint2.configs.recommendedTypeChecked,
558
560
  tseslint2.configs.strictTypeChecked,
@@ -993,9 +995,12 @@ import pluginJsonc from "eslint-plugin-jsonc";
993
995
  import pluginPackageJson from "eslint-plugin-package-json";
994
996
  import parserJsonc from "jsonc-eslint-parser";
995
997
  import pluginHyoban2 from "eslint-plugin-hyoban";
996
- import { isPackageExists as isPackageExists2 } from "local-pkg";
997
998
  function json(options = {}) {
998
- const { overrides = { core: {}, packageJson: {} }, indent = 2 } = options;
999
+ const {
1000
+ overrides = { core: {}, packageJson: {} },
1001
+ indent = 2,
1002
+ packageJsonRequireTypes = true
1003
+ } = options;
999
1004
  return [
1000
1005
  ...pluginJsonc.configs["flat/recommended-with-json"].map((item) => ({
1001
1006
  ...item,
@@ -1145,7 +1150,7 @@ function json(options = {}) {
1145
1150
  ]
1146
1151
  }
1147
1152
  ],
1148
- "package-json/require-types": isPackageExists2("@nestjs/core") ? "off" : "error",
1153
+ "package-json/require-types": packageJsonRequireTypes ? "error" : "off",
1149
1154
  ...overrides.packageJson
1150
1155
  }
1151
1156
  }
@@ -1472,10 +1477,10 @@ function format(options = {}) {
1472
1477
 
1473
1478
  // src/configs/tailwindcss.ts
1474
1479
  import pluginTailwindcss from "eslint-plugin-tailwindcss";
1475
- import { isPackageExists as isPackageExists3 } from "local-pkg";
1480
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
1476
1481
  function tailwindcss(options = {}) {
1477
1482
  const { overrides = {} } = options;
1478
- return isPackageExists3("tailwindcss") ? [
1483
+ return isPackageExists2("tailwindcss") ? [
1479
1484
  ...pluginTailwindcss.configs["flat/recommended"].map((item) => ({
1480
1485
  ...item,
1481
1486
  name: `${RULE_PREFIX}/tailwindcss/shared/${item.name?.replace("tailwindcss:", "")}`,
@@ -1494,10 +1499,10 @@ function tailwindcss(options = {}) {
1494
1499
 
1495
1500
  // src/configs/unocss.ts
1496
1501
  import configUnocss from "@unocss/eslint-config/flat";
1497
- import { isPackageExists as isPackageExists4 } from "local-pkg";
1502
+ import { isPackageExists as isPackageExists3 } from "local-pkg";
1498
1503
  function unocss(options = {}) {
1499
1504
  const { overrides = {} } = options;
1500
- const isUnocssEnabled = isPackageExists4("unocss");
1505
+ const isUnocssEnabled = isPackageExists3("unocss");
1501
1506
  if (!isUnocssEnabled) {
1502
1507
  return [];
1503
1508
  }
@@ -1762,7 +1767,7 @@ function disables(options = {}) {
1762
1767
  }
1763
1768
 
1764
1769
  // src/index.ts
1765
- function defineConfig(options = {}) {
1770
+ function defineConfig3(options = {}) {
1766
1771
  const { configs: configs2 = {}, ignorePatterns = [] } = options;
1767
1772
  return [
1768
1773
  ...react(configs2.react),
@@ -1786,5 +1791,5 @@ function defineConfig(options = {}) {
1786
1791
  ];
1787
1792
  }
1788
1793
  export {
1789
- defineConfig
1794
+ defineConfig3 as defineConfig
1790
1795
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dhzh/eslint-config",
3
3
  "type": "module",
4
- "version": "1.12.1",
4
+ "version": "1.13.0",
5
5
  "description": "Lyle's ESLint config",
6
6
  "author": {
7
7
  "name": "Lyle Zheng",
@@ -73,14 +73,14 @@
73
73
  "eslint-plugin-toml": "^0.12.0",
74
74
  "eslint-plugin-unicorn": "^60.0.0",
75
75
  "eslint-plugin-unused-imports": "^4.1.4",
76
- "eslint-plugin-vue": "^10.1.0",
76
+ "eslint-plugin-vue": "^10.4.0",
77
77
  "eslint-plugin-yml": "^1.18.0",
78
78
  "eslint-processor-vue-blocks": "^2.0.0",
79
79
  "globals": "^16.0.0",
80
80
  "jsonc-eslint-parser": "^2.4.0",
81
81
  "local-pkg": "^1.1.1",
82
82
  "toml-eslint-parser": "^0.10.0",
83
- "typescript-eslint": "^8.31.0",
83
+ "typescript-eslint": "^8.42.0",
84
84
  "vue-eslint-parser": "^10.1.3",
85
85
  "yaml-eslint-parser": "^1.3.0"
86
86
  },
@@ -91,7 +91,7 @@
91
91
  "@types/node": "^22.18.0",
92
92
  "bumpp": "^10.1.0",
93
93
  "bundle-require": "^5.1.0",
94
- "eslint": "^9.25.1",
94
+ "eslint": "^9.34.0",
95
95
  "eslint-typegen": "^2.1.0",
96
96
  "lint-staged": "^16.0.0",
97
97
  "simple-git-hooks": "^2.13.0",