@coderwyd/eslint-config 4.11.0 → 5.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/README.md +228 -142
- package/dist/index.d.mts +26 -14994
- package/dist/index.mjs +67 -1881
- package/package.json +16 -81
- package/bin/index.mjs +0 -3
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -184
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Donny's ESLint config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -16,110 +16,45 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git+https://github.com/coderwyd/eslint-config.git"
|
|
18
18
|
},
|
|
19
|
-
"bin": "./bin/index.mjs",
|
|
20
19
|
"files": [
|
|
21
|
-
"bin",
|
|
22
20
|
"dist"
|
|
23
21
|
],
|
|
24
22
|
"type": "module",
|
|
25
23
|
"types": "./dist/index.d.mts",
|
|
26
24
|
"exports": {
|
|
27
25
|
".": "./dist/index.mjs",
|
|
28
|
-
"./cli": "./dist/cli.mjs",
|
|
29
26
|
"./package.json": "./package.json"
|
|
30
27
|
},
|
|
31
28
|
"publishConfig": {
|
|
32
29
|
"access": "public"
|
|
33
30
|
},
|
|
34
31
|
"dependencies": {
|
|
35
|
-
"@antfu/
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"@typescript-eslint/parser": "^8.56.1",
|
|
39
|
-
"@vitest/eslint-plugin": "^1.6.9",
|
|
40
|
-
"cac": "^7.0.0",
|
|
41
|
-
"eslint-config-flat-gitignore": "^2.2.1",
|
|
42
|
-
"eslint-config-prettier": "^10.1.8",
|
|
43
|
-
"eslint-plugin-antfu": "^3.2.2",
|
|
44
|
-
"eslint-plugin-command": "^3.5.2",
|
|
45
|
-
"eslint-plugin-de-morgan": "^2.1.1",
|
|
46
|
-
"eslint-plugin-import-lite": "^0.5.2",
|
|
47
|
-
"eslint-plugin-jsdoc": "61.4.1",
|
|
48
|
-
"eslint-plugin-jsonc": "^3.1.1",
|
|
49
|
-
"eslint-plugin-n": "^17.24.0",
|
|
50
|
-
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
51
|
-
"eslint-plugin-perfectionist": "^5.6.0",
|
|
52
|
-
"eslint-plugin-pnpm": "^1.6.0",
|
|
53
|
-
"eslint-plugin-regexp": "^3.0.0",
|
|
54
|
-
"eslint-plugin-unicorn": "^63.0.0",
|
|
55
|
-
"eslint-plugin-unused-imports": "^4.4.1",
|
|
56
|
-
"eslint-plugin-vue": "^10.8.0",
|
|
57
|
-
"eslint-plugin-yml": "^3.3.0",
|
|
58
|
-
"globals": "^17.4.0",
|
|
59
|
-
"parse-gitignore": "^2.0.0",
|
|
60
|
-
"prompts": "^2.4.2",
|
|
61
|
-
"vue-eslint-parser": "^10.4.0",
|
|
62
|
-
"yaml-eslint-parser": "^2.0.0"
|
|
32
|
+
"@antfu/eslint-config": "^8.1.1",
|
|
33
|
+
"defu": "^6.1.7",
|
|
34
|
+
"eslint-flat-config-utils": "^3.1.0"
|
|
63
35
|
},
|
|
64
36
|
"devDependencies": {
|
|
65
|
-
"@eslint
|
|
66
|
-
"@
|
|
67
|
-
"@types/eslint-config-prettier": "^6.11.3",
|
|
68
|
-
"@types/node": "^25.3.3",
|
|
69
|
-
"@types/prompts": "^2.4.9",
|
|
37
|
+
"@eslint/config-inspector": "^1.5.0",
|
|
38
|
+
"@types/node": "^25.6.0",
|
|
70
39
|
"@typescript/native-preview": "7.0.0-dev.20260107.1",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"eslint": "^
|
|
74
|
-
"eslint-plugin-react-hooks": "7.0.1",
|
|
75
|
-
"eslint-plugin-react-refresh": "^0.5.2",
|
|
76
|
-
"eslint-plugin-svelte": "^3.15.0",
|
|
77
|
-
"eslint-plugin-tailwindcss": "^3.18.2",
|
|
40
|
+
"bumpp": "^11.0.1",
|
|
41
|
+
"eslint": "^10.2.0",
|
|
42
|
+
"eslint-plugin-better-tailwindcss": "^4.4.0",
|
|
78
43
|
"eslint-typegen": "^2.3.1",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"oxfmt": "^0.35.0",
|
|
82
|
-
"prettier": "^3.8.1",
|
|
44
|
+
"nano-staged": "^1.0.2",
|
|
45
|
+
"oxfmt": "^0.44.0",
|
|
83
46
|
"publint": "^0.3.18",
|
|
84
47
|
"simple-git-hooks": "^2.13.1",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"typescript": "^5.9.3",
|
|
48
|
+
"tsdown": "^0.21.7",
|
|
49
|
+
"typescript": "^6.0.2",
|
|
88
50
|
"unplugin-unused": "^0.5.7"
|
|
89
51
|
},
|
|
90
52
|
"peerDependencies": {
|
|
91
|
-
"@eslint-react/eslint-plugin": "^2.11.0",
|
|
92
|
-
"@unocss/eslint-plugin": ">=0.50.0",
|
|
93
53
|
"eslint": "^9.10.0 || ^10.0.0",
|
|
94
|
-
"eslint-plugin-
|
|
95
|
-
"eslint-plugin-react-refresh": "^0.5.0",
|
|
96
|
-
"eslint-plugin-svelte": ">=2.35.1",
|
|
97
|
-
"eslint-plugin-tailwindcss": "^3.16.0",
|
|
98
|
-
"svelte-eslint-parser": ">=0.37.0"
|
|
54
|
+
"eslint-plugin-better-tailwindcss": "^0.1.0"
|
|
99
55
|
},
|
|
100
56
|
"peerDependenciesMeta": {
|
|
101
|
-
"
|
|
102
|
-
"optional": true
|
|
103
|
-
},
|
|
104
|
-
"@unocss/eslint-plugin": {
|
|
105
|
-
"optional": true
|
|
106
|
-
},
|
|
107
|
-
"eslint-plugin-react-compiler": {
|
|
108
|
-
"optional": true
|
|
109
|
-
},
|
|
110
|
-
"eslint-plugin-react-hooks": {
|
|
111
|
-
"optional": true
|
|
112
|
-
},
|
|
113
|
-
"eslint-plugin-react-refresh": {
|
|
114
|
-
"optional": true
|
|
115
|
-
},
|
|
116
|
-
"eslint-plugin-svelte": {
|
|
117
|
-
"optional": true
|
|
118
|
-
},
|
|
119
|
-
"eslint-plugin-tailwindcss": {
|
|
120
|
-
"optional": true
|
|
121
|
-
},
|
|
122
|
-
"svelte-eslint-parser": {
|
|
57
|
+
"eslint-plugin-better-tailwindcss": {
|
|
123
58
|
"optional": true
|
|
124
59
|
}
|
|
125
60
|
},
|
|
@@ -138,7 +73,7 @@
|
|
|
138
73
|
"scripts": {
|
|
139
74
|
"build": "pnpm build:typegen && tsdown",
|
|
140
75
|
"build:inspector": "pnpm build && pnpx @eslint/config-inspector build",
|
|
141
|
-
"build:typegen": "
|
|
76
|
+
"build:typegen": "node scripts/typegen.ts",
|
|
142
77
|
"dev": "pnpx @eslint/config-inspector",
|
|
143
78
|
"fmt": "oxfmt",
|
|
144
79
|
"lint": "eslint .",
|
package/bin/index.mjs
DELETED
package/dist/cli.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/cli.mjs
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import process from "node:process";
|
|
2
|
-
import { styleText } from "node:util";
|
|
3
|
-
import { cac } from "cac";
|
|
4
|
-
import fs from "node:fs";
|
|
5
|
-
import fsp from "node:fs/promises";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import parse from "parse-gitignore";
|
|
8
|
-
import prompts from "prompts";
|
|
9
|
-
import { execSync } from "node:child_process";
|
|
10
|
-
|
|
11
|
-
//#region package.json
|
|
12
|
-
var version = "4.11.0";
|
|
13
|
-
var devDependencies = {
|
|
14
|
-
"@eslint-react/eslint-plugin": "catalog:peer",
|
|
15
|
-
"@eslint/config-inspector": "catalog:dev",
|
|
16
|
-
"@types/eslint-config-prettier": "catalog:dev",
|
|
17
|
-
"@types/node": "catalog:dev",
|
|
18
|
-
"@types/prompts": "catalog:dev",
|
|
19
|
-
"@typescript/native-preview": "catalog:dev",
|
|
20
|
-
"@unocss/eslint-plugin": "catalog:peer",
|
|
21
|
-
"bumpp": "catalog:dev",
|
|
22
|
-
"eslint": "catalog:peer",
|
|
23
|
-
"eslint-plugin-react-hooks": "catalog:peer",
|
|
24
|
-
"eslint-plugin-react-refresh": "catalog:peer",
|
|
25
|
-
"eslint-plugin-svelte": "catalog:peer",
|
|
26
|
-
"eslint-plugin-tailwindcss": "catalog:peer",
|
|
27
|
-
"eslint-typegen": "catalog:dev",
|
|
28
|
-
"jiti": "catalog:dev",
|
|
29
|
-
"nano-staged": "catalog:dev",
|
|
30
|
-
"oxfmt": "catalog:dev",
|
|
31
|
-
"prettier": "catalog:dev",
|
|
32
|
-
"publint": "catalog:dev",
|
|
33
|
-
"simple-git-hooks": "catalog:dev",
|
|
34
|
-
"svelte-eslint-parser": "catalog:peer",
|
|
35
|
-
"tsdown": "catalog:dev",
|
|
36
|
-
"typescript": "catalog:dev",
|
|
37
|
-
"unplugin-unused": "catalog:dev"
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/cli/constants.ts
|
|
42
|
-
const ARROW = styleText("cyan", "→");
|
|
43
|
-
const CHECK = styleText("green", "✔");
|
|
44
|
-
const CROSS = styleText("red", "✘");
|
|
45
|
-
const WARN = styleText("yellow", "ℹ");
|
|
46
|
-
const eslintVersion = devDependencies.eslint;
|
|
47
|
-
const vscodeSettingsString = `
|
|
48
|
-
"editor.formatOnSave": true,
|
|
49
|
-
|
|
50
|
-
// Auto fix
|
|
51
|
-
"editor.codeActionsOnSave": {
|
|
52
|
-
"source.fixAll.eslint": "explicit",
|
|
53
|
-
"source.organizeImports": "never"
|
|
54
|
-
},
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/cli/utils.ts
|
|
59
|
-
function isGitClean() {
|
|
60
|
-
try {
|
|
61
|
-
execSync("git diff-index --quiet HEAD --");
|
|
62
|
-
return true;
|
|
63
|
-
} catch {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/cli/run.ts
|
|
70
|
-
async function run(options = {}) {
|
|
71
|
-
const SKIP_PROMPT = !!process.env.SKIP_PROMPT || options.yes;
|
|
72
|
-
const SKIP_GIT_CHECK = !!process.env.SKIP_GIT_CHECK;
|
|
73
|
-
const cwd = process.cwd();
|
|
74
|
-
const pathFlatConfig = path.join(cwd, "eslint.config.js");
|
|
75
|
-
const pathPackageJSON = path.join(cwd, "package.json");
|
|
76
|
-
const pathESLintIngore = path.join(cwd, ".eslintignore");
|
|
77
|
-
if (fs.existsSync(pathFlatConfig)) {
|
|
78
|
-
console.log(styleText("yellow", `${WARN} eslint.config.js already exists, migration wizard exited.`));
|
|
79
|
-
return process.exit(1);
|
|
80
|
-
}
|
|
81
|
-
if (!SKIP_GIT_CHECK && !isGitClean()) {
|
|
82
|
-
const { confirmed } = await prompts({
|
|
83
|
-
initial: false,
|
|
84
|
-
message: "There are uncommitted changes in the current repository, are you sure to continue?",
|
|
85
|
-
name: "confirmed",
|
|
86
|
-
type: "confirm"
|
|
87
|
-
});
|
|
88
|
-
if (!confirmed) return process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
console.log(styleText("cyan", `${ARROW} bumping @coderwyd/eslint-config to v${version}`));
|
|
91
|
-
const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
|
|
92
|
-
const pkg = JSON.parse(pkgContent);
|
|
93
|
-
pkg.devDependencies ??= {};
|
|
94
|
-
pkg.devDependencies["@coderwyd/eslint-config"] = `^${version}`;
|
|
95
|
-
if (!pkg.devDependencies.eslint) pkg.devDependencies.eslint = eslintVersion;
|
|
96
|
-
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
97
|
-
console.log(styleText("green", `${CHECK} changes wrote to package.json`));
|
|
98
|
-
const eslintIgnores = [];
|
|
99
|
-
if (fs.existsSync(pathESLintIngore)) {
|
|
100
|
-
console.log(styleText("cyan", `${ARROW} migrating existing .eslintignore`));
|
|
101
|
-
const globs = parse(await fsp.readFile(pathESLintIngore, "utf-8")).globs();
|
|
102
|
-
for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
|
103
|
-
else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
104
|
-
}
|
|
105
|
-
let eslintConfigContent = "";
|
|
106
|
-
const coderwydConfig = `${eslintIgnores.length > 0 ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
|
|
107
|
-
if (pkg.type === "module") eslintConfigContent = `
|
|
108
|
-
import { defineConfig } from '@coderwyd/eslint-config'
|
|
109
|
-
|
|
110
|
-
export default defineConfig({\n${coderwydConfig}\n})
|
|
111
|
-
`.trimStart();
|
|
112
|
-
else eslintConfigContent = `
|
|
113
|
-
const { defineConfig } = require('@coderwyd/eslint-config')
|
|
114
|
-
|
|
115
|
-
module.exports = defineConfig({\n${coderwydConfig}\n})
|
|
116
|
-
`.trimStart();
|
|
117
|
-
await fsp.writeFile(pathFlatConfig, eslintConfigContent);
|
|
118
|
-
console.log(styleText("green", `${CHECK} created eslint.config.js`));
|
|
119
|
-
const files = fs.readdirSync(cwd);
|
|
120
|
-
const legacyConfig = [];
|
|
121
|
-
files.forEach((file) => {
|
|
122
|
-
if (/eslint|prettier/.test(file) && !/eslint.config./.test(file)) legacyConfig.push(file);
|
|
123
|
-
});
|
|
124
|
-
if (legacyConfig.length > 0) {
|
|
125
|
-
console.log(`${WARN} you can now remove those files manually:`);
|
|
126
|
-
console.log(` ${styleText("dim", legacyConfig.join(", "))}`);
|
|
127
|
-
}
|
|
128
|
-
let promptResult = { updateVscodeSettings: true };
|
|
129
|
-
if (!SKIP_PROMPT) try {
|
|
130
|
-
promptResult = await prompts({
|
|
131
|
-
initial: true,
|
|
132
|
-
message: "Update .vscode/settings.json for better VS Code experience?",
|
|
133
|
-
name: "updateVscodeSettings",
|
|
134
|
-
type: "confirm"
|
|
135
|
-
}, { onCancel: () => {
|
|
136
|
-
throw new Error(`Cancelled`);
|
|
137
|
-
} });
|
|
138
|
-
} catch (error) {
|
|
139
|
-
console.log(error.message);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (promptResult?.updateVscodeSettings ?? true) {
|
|
143
|
-
const dotVscodePath = path.join(cwd, ".vscode");
|
|
144
|
-
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
145
|
-
if (!fs.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
|
|
146
|
-
if (!fs.existsSync(settingsPath)) {
|
|
147
|
-
await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
|
|
148
|
-
console.log(styleText("green", `${CHECK} created .vscode/settings.json`));
|
|
149
|
-
} else {
|
|
150
|
-
let settingsContent = await fsp.readFile(settingsPath, "utf8");
|
|
151
|
-
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
152
|
-
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
153
|
-
settingsContent += `${vscodeSettingsString}}\n`;
|
|
154
|
-
await fsp.writeFile(settingsPath, settingsContent, "utf-8");
|
|
155
|
-
console.log(styleText("green", `${CHECK} updated .vscode/settings.json`));
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
console.log(styleText("green", `${CHECK} migration completed`));
|
|
159
|
-
console.log(`Now you can update the dependencies and run ${styleText("blue", "eslint . --fix")}\n`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/cli/index.ts
|
|
164
|
-
function header() {
|
|
165
|
-
console.log(`\n${styleText("green", `@coderwyd/eslint-config `)}${styleText("dim", `v${version}`)}`);
|
|
166
|
-
}
|
|
167
|
-
const cli = cac("@coderwyd/eslint-config");
|
|
168
|
-
cli.command("", "Run the initialization or migration").option("--yes, -y", "Skip prompts and use default values", { default: false }).action(async (args) => {
|
|
169
|
-
header();
|
|
170
|
-
console.log();
|
|
171
|
-
try {
|
|
172
|
-
await run(args);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.error(styleText(["red", "inverse"], " Failed to migrate "));
|
|
175
|
-
console.error(styleText("red", `${CROSS} ${String(error)}`));
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
cli.help();
|
|
180
|
-
cli.version(version);
|
|
181
|
-
cli.parse();
|
|
182
|
-
|
|
183
|
-
//#endregion
|
|
184
|
-
export { };
|