@dhzh/eslint-config 1.26.0 → 1.27.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dhzh/eslint-config",
3
3
  "type": "module",
4
- "version": "1.26.0",
4
+ "version": "1.27.1",
5
5
  "description": "tinywaves's ESLint config",
6
6
  "author": {
7
7
  "name": "Lyle Zheng",
@@ -94,7 +94,7 @@
94
94
  "lint-staged": "^16.4.0",
95
95
  "simple-git-hooks": "^2.13.1",
96
96
  "tailwindcss": "^4.2.4",
97
- "tsup": "^8.5.1",
97
+ "tsdown": "^0.21.10",
98
98
  "tsx": "^4.21.0",
99
99
  "typescript": "^6.0.3"
100
100
  },
@@ -105,7 +105,7 @@
105
105
  "*": "eslint --fix"
106
106
  },
107
107
  "scripts": {
108
- "build": "pnpm run typegen && tsup --clean --dts",
108
+ "build": "pnpm run typegen && tsdown --clean --dts",
109
109
  "build:inspector": "pnpm run build && npx @eslint/config-inspector build",
110
110
  "dev": "pnpm run typegen && npx @eslint/config-inspector --config eslint.config.ts",
111
111
  "lint": "eslint",
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/cli/index.js DELETED
@@ -1,391 +0,0 @@
1
- // src/cli/index.ts
2
- import * as p6 from "@clack/prompts";
3
- import c5 from "ansis";
4
- import { cac } from "cac";
5
-
6
- // package.json
7
- var version = "1.26.0";
8
- var package_default = {
9
- name: "@dhzh/eslint-config",
10
- type: "module",
11
- version,
12
- packageManager: "pnpm@10.33.2",
13
- description: "tinywaves's ESLint config",
14
- author: {
15
- name: "Lyle Zheng",
16
- email: "dhzhme@gmail.com"
17
- },
18
- license: "MIT",
19
- homepage: "https://github.com/tinywaves/eslint-config",
20
- repository: {
21
- type: "git",
22
- url: "git+https://github.com/tinywaves/eslint-config"
23
- },
24
- bugs: {
25
- url: "https://github.com/tinywaves/eslint-config/issues"
26
- },
27
- keywords: [
28
- "eslint",
29
- "eslint-config"
30
- ],
31
- sideEffects: false,
32
- exports: {
33
- ".": {
34
- import: "./dist/index.js",
35
- require: "./dist/index.cjs"
36
- }
37
- },
38
- main: "./dist/index.js",
39
- types: "./dist/index.d.ts",
40
- bin: "./bin/index.js",
41
- files: [
42
- "bin",
43
- "dist"
44
- ],
45
- engines: {
46
- node: "^22.13.0 || >=24"
47
- },
48
- scripts: {
49
- build: "pnpm run typegen && tsup --clean --dts",
50
- "build:inspector": "pnpm run build && npx @eslint/config-inspector build",
51
- dev: "pnpm run typegen && npx @eslint/config-inspector --config eslint.config.ts",
52
- lint: "eslint",
53
- "lint-fix": "eslint --fix .",
54
- prepack: "pnpm run build",
55
- prepare: "simple-git-hooks",
56
- release: "bumpp",
57
- typecheck: "tsc --noEmit",
58
- typegen: "tsx scripts/eslint-typegen.ts"
59
- },
60
- peerDependencies: {
61
- "@prettier/plugin-xml": "^3.4.2",
62
- eslint: "^10.2.1"
63
- },
64
- peerDependenciesMeta: {
65
- "@prettier/plugin-xml": {
66
- optional: true
67
- }
68
- },
69
- dependencies: {
70
- "@clack/prompts": "^1.2.0",
71
- "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
72
- "@eslint-react/eslint-plugin": "^4.2.3",
73
- "@eslint/js": "^10.0.1",
74
- "@stylistic/eslint-plugin": "^5.10.0",
75
- "@unocss/eslint-config": "66.6.8",
76
- ansis: "^4.2.0",
77
- cac: "^7.0.0",
78
- "eslint-merge-processors": "^2.0.0",
79
- "eslint-plugin-antfu": "^3.2.2",
80
- "eslint-plugin-format": "^2.0.1",
81
- "eslint-plugin-import-x": "^4.16.2",
82
- "eslint-plugin-jsonc": "^3.1.2",
83
- "eslint-plugin-n": "^17.24.0",
84
- "eslint-plugin-package-json": "^0.91.1",
85
- "eslint-plugin-react-compiler": "19.1.0-rc.2",
86
- "eslint-plugin-react-google-translate": "^1.0.4",
87
- "eslint-plugin-react-hooks": "^7.1.1",
88
- "eslint-plugin-react-refresh": "^0.5.2",
89
- "eslint-plugin-regexp": "^3.1.0",
90
- "eslint-plugin-simple-import-sort": "^13.0.0",
91
- "eslint-plugin-tailwindcss": "4.0.0-beta.0",
92
- "eslint-plugin-toml": "^1.3.1",
93
- "eslint-plugin-unicorn": "^64.0.0",
94
- "eslint-plugin-unused-imports": "^4.4.1",
95
- "eslint-plugin-vue": "^10.9.0",
96
- "eslint-plugin-yml": "^3.3.1",
97
- "eslint-processor-vue-blocks": "^2.0.0",
98
- globals: "^17.5.0",
99
- "local-pkg": "^1.1.2",
100
- "toml-eslint-parser": "^1.0.3",
101
- "typescript-eslint": "^8.59.0",
102
- "vue-eslint-parser": "^10.4.0"
103
- },
104
- devDependencies: {
105
- "@eslint/config-inspector": "^2.0.0",
106
- "@prettier/plugin-xml": "^3.4.2",
107
- "@types/eslint-plugin-tailwindcss": "^3.17.0",
108
- "@types/node": "^24.12.2",
109
- "@typescript-eslint/types": "^8.59.0",
110
- bumpp: "^11.0.1",
111
- "bundle-require": "^5.1.0",
112
- eslint: "^10.2.1",
113
- "eslint-typegen": "^2.3.1",
114
- "lint-staged": "^16.4.0",
115
- "simple-git-hooks": "^2.13.1",
116
- tailwindcss: "^4.2.4",
117
- tsup: "^8.5.1",
118
- tsx: "^4.21.0",
119
- typescript: "^6.0.3"
120
- },
121
- "simple-git-hooks": {
122
- "pre-commit": "npx lint-staged"
123
- },
124
- "lint-staged": {
125
- "*": "eslint --fix"
126
- }
127
- };
128
-
129
- // src/cli/run.ts
130
- import * as p5 from "@clack/prompts";
131
- import c4 from "ansis";
132
-
133
- // src/cli/stages/update-package-json.ts
134
- import fsp from "fs/promises";
135
- import path from "path";
136
- import process from "process";
137
- import * as p from "@clack/prompts";
138
- import c from "ansis";
139
- async function updatePackageJson() {
140
- const cwd = process.cwd();
141
- const pathPackageJSON = path.join(cwd, "package.json");
142
- p.log.step(c.cyan`Bumping @dhzh/eslint-config to v${version}`);
143
- const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
144
- const pkg = JSON.parse(pkgContent);
145
- pkg.devDependencies ??= {};
146
- pkg.devDependencies["@dhzh/eslint-config"] = `^${version}`;
147
- pkg.devDependencies.eslint ??= package_default.devDependencies.eslint;
148
- pkg.scripts ??= {};
149
- pkg.scripts.lint = "eslint .";
150
- pkg.scripts["lint-fix"] = "eslint --fix .";
151
- await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
152
- p.log.success(c.green`Changes wrote to package.json`);
153
- }
154
-
155
- // src/cli/stages/update-eslint-config.ts
156
- import fsp2 from "fs/promises";
157
- import path2 from "path";
158
- import process2 from "process";
159
- import c2 from "ansis";
160
- import * as p2 from "@clack/prompts";
161
-
162
- // src/cli/constants.ts
163
- var vscodeSettingsString = `
164
- // Entry
165
- "eslint.format.enable": true,
166
- "eslint.ignoreUntitled": true,
167
- "eslint.enable": true,
168
-
169
- // Disable the default formatter, use eslint instead
170
- "prettier.enable": false,
171
-
172
- // Auto fix
173
- "editor.codeActionsOnSave": {
174
- "source.fixAll.eslint": "explicit",
175
- "source.organizeImports": "never"
176
- },
177
-
178
- // Silent the stylistic rules in you IDE, but still auto fix them
179
- // "eslint.rules.customizations": [
180
- // { "rule": "style/*", "severity": "off", "fixable": true },
181
- // { "rule": "format/*", "severity": "off", "fixable": true },
182
- // { "rule": "*-indent", "severity": "off", "fixable": true },
183
- // { "rule": "*-spacing", "severity": "off", "fixable": true },
184
- // { "rule": "*-spaces", "severity": "off", "fixable": true },
185
- // { "rule": "*-order", "severity": "off", "fixable": true },
186
- // { "rule": "*-dangle", "severity": "off", "fixable": true },
187
- // { "rule": "*-newline", "severity": "off", "fixable": true },
188
- // { "rule": "*quotes", "severity": "off", "fixable": true },
189
- // { "rule": "*semi", "severity": "off", "fixable": true }
190
- // ],
191
-
192
- // Enable eslint for all supported languages
193
- "eslint.validate": [
194
- "javascript",
195
- "javascriptreact",
196
- "typescript",
197
- "typescriptreact",
198
- "html",
199
- "json",
200
- "json5",
201
- "jsonc",
202
- "yaml",
203
- "toml",
204
- "xml",
205
- "css",
206
- "less",
207
- "scss",
208
- "pcss",
209
- "postcss",
210
- "gql",
211
- "graphql",
212
- "vue"
213
- ],
214
-
215
- // Enable eslint as the default formatter
216
- "[javascript]": {
217
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
218
- },
219
- "[javascriptreact]": {
220
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
221
- },
222
- "[typescript]": {
223
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
224
- },
225
- "[typescriptreact]": {
226
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
227
- },
228
- "[html]": {
229
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
230
- },
231
- "[json]": {
232
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
233
- },
234
- "[jsonc]": {
235
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
236
- },
237
- "[yaml]": {
238
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
239
- },
240
- "[toml]": {
241
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
242
- },
243
- "[xml]": {
244
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
245
- },
246
- "[css]": {
247
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
248
- },
249
- "[less]": {
250
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
251
- },
252
- "[scss]": {
253
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
254
- },
255
- "[pcss]": {
256
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
257
- },
258
- "[postcss]": {
259
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
260
- },
261
- "[gql]": {
262
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
263
- },
264
- "[graphql]": {
265
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
266
- },
267
- "[vue]": {
268
- "editor.defaultFormatter": "dbaeumer.vscode-eslint"
269
- }
270
- `;
271
- var eslintConfigContent = (options) => `import { defineConfig } from '@dhzh/eslint-config';
272
-
273
- export default defineConfig(${options.hasNest ? `{
274
- configs: {
275
- json: {
276
- packageJsonRequireType: false,
277
- },
278
- },
279
- }` : ""});
280
- `;
281
- var npmignoreString = `# If these files (ESLint flat config files) are not included in .npmignore,
282
- # they will be published, and importing devDependencies in published files will trigger \`n/no-unpublished-import\` errors.
283
- eslint.config.js
284
- eslint.config.mjs
285
- `;
286
-
287
- // src/cli/stages/update-eslint-config.ts
288
- async function updateEslintConfig(options) {
289
- const cwd = process2.cwd();
290
- const pathPackageJSON = path2.join(cwd, "package.json");
291
- const pkgContent = await fsp2.readFile(pathPackageJSON, "utf8");
292
- const pkg = JSON.parse(pkgContent);
293
- const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
294
- const pathFlatConfig = path2.join(cwd, configFileName);
295
- await fsp2.writeFile(pathFlatConfig, eslintConfigContent(options));
296
- p2.log.success(c2.green`Created ${configFileName}`);
297
- }
298
-
299
- // src/cli/stages/update-npmignore.ts
300
- import fsp3 from "fs/promises";
301
- import path3 from "path";
302
- import process3 from "process";
303
- import c3 from "ansis";
304
- import * as p3 from "@clack/prompts";
305
- async function updateNpmignore() {
306
- const cwd = process3.cwd();
307
- const npmignoreFileName = ".npmignore";
308
- const npmignoreFilePath = path3.join(cwd, npmignoreFileName);
309
- let action = "Created";
310
- try {
311
- await fsp3.access(npmignoreFilePath);
312
- const existingContent = await fsp3.readFile(npmignoreFilePath, "utf8");
313
- const trimmedContent = existingContent.trimEnd();
314
- await fsp3.writeFile(npmignoreFilePath, `${trimmedContent}
315
- ${npmignoreString}`);
316
- action = "Updated";
317
- } catch {
318
- await fsp3.writeFile(npmignoreFilePath, npmignoreString);
319
- }
320
- p3.log.success(c3.green`${action} ${npmignoreFileName}`);
321
- }
322
-
323
- // src/cli/stages/update-vscode-settings.ts
324
- import fs from "fs";
325
- import fsp4 from "fs/promises";
326
- import path4 from "path";
327
- import process4 from "process";
328
- import { green } from "ansis";
329
- import * as p4 from "@clack/prompts";
330
- async function updateVscodeSettings() {
331
- const cwd = process4.cwd();
332
- const dotVscodePath = path4.join(cwd, ".vscode");
333
- const settingsPath = path4.join(dotVscodePath, "settings.json");
334
- if (!fs.existsSync(dotVscodePath)) {
335
- await fsp4.mkdir(dotVscodePath, { recursive: true });
336
- }
337
- if (fs.existsSync(settingsPath)) {
338
- let settingsContent = await fsp4.readFile(settingsPath, "utf8");
339
- settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
340
- settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
341
- settingsContent += `${vscodeSettingsString}}
342
- `;
343
- await fsp4.writeFile(settingsPath, settingsContent, "utf8");
344
- p4.log.success(green`Updated .vscode/settings.json`);
345
- } else {
346
- await fsp4.writeFile(settingsPath, `{${vscodeSettingsString}}
347
- `, "utf8");
348
- p4.log.success(green`Created .vscode/settings.json`);
349
- }
350
- }
351
-
352
- // src/cli/run.ts
353
- async function run(options) {
354
- await updatePackageJson();
355
- await updateEslintConfig(options);
356
- await updateNpmignore();
357
- await updateVscodeSettings();
358
- p5.log.success(c4.green`Setup completed`);
359
- p5.outro(`Now you can update the dependencies by run ${c4.blue("pnpm i")} and run ${c4.blue("eslint --fix")}
360
- `);
361
- }
362
-
363
- // src/cli/index.ts
364
- var cli = cac("@dhzh/eslint-config");
365
- cli.command("", "Run the initialization or migration").action(async () => {
366
- console.log("\n");
367
- p6.intro(`${c5.green`@dhzh/eslint-config `}${c5.dim`v${version}`}`);
368
- const options = {
369
- hasNest: false
370
- };
371
- const hasNest = await p6.confirm({
372
- message: "Is NestJS a part of the current project?",
373
- initialValue: false
374
- });
375
- if (p6.isCancel(hasNest)) {
376
- p6.cancel("Operation cancelled");
377
- throw new Error("Operation cancelled");
378
- } else {
379
- options.hasNest = hasNest;
380
- }
381
- try {
382
- await run(options);
383
- } catch (error) {
384
- p6.log.error(c5.inverse.red(" Failed to migrate "));
385
- p6.log.error(c5.red`✘ ${String(error)}`);
386
- throw error;
387
- }
388
- });
389
- cli.help();
390
- cli.version(version);
391
- cli.parse();