@oliver139/eslint-config 5.1.0 → 6.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 +11 -11
- package/dist/cli.mjs +16 -28
- package/dist/index.d.mts +1675 -2484
- package/dist/index.mjs +160 -267
- package/dist/{lib-CLEwVDK6.mjs → lib-zvCEClb6.mjs} +3157 -2897
- package/package.json +63 -54
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://npmjs.com/package/@oliver139/eslint-config)
|
|
4
4
|
|
|
5
5
|
> [!NOTE]
|
|
6
|
-
> Based on [Anthony's code style v7.
|
|
6
|
+
> Based on [Anthony's code style v7.7.3](https://github.com/antfu/eslint-config)
|
|
7
7
|
> Content below keeps nearly unchanged
|
|
8
8
|
|
|
9
9
|
<!-- [](https://github.com/antfu/eslint-config) -->
|
|
@@ -182,11 +182,11 @@ Add the following settings to your `.zed/settings.json`:
|
|
|
182
182
|
|
|
183
183
|
```jsonc
|
|
184
184
|
{
|
|
185
|
-
|
|
186
|
-
"
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
],
|
|
185
|
+
// Use ESLint's --fix:
|
|
186
|
+
"code_actions_on_format": {
|
|
187
|
+
"source.fixAll.eslint": true
|
|
188
|
+
},
|
|
189
|
+
"formatter": [],
|
|
190
190
|
// Enable eslint for all supported languages
|
|
191
191
|
// Defaults only include https://github.com/search?q=repo%3Azed-industries%2Fzed%20eslint_languages&type=code
|
|
192
192
|
"languages": {
|
|
@@ -196,6 +196,9 @@ Add the following settings to your `.zed/settings.json`:
|
|
|
196
196
|
"Markdown": {
|
|
197
197
|
"language_servers": ["...", "eslint"]
|
|
198
198
|
},
|
|
199
|
+
"Markdown-Inline": {
|
|
200
|
+
"language_servers": ["...", "eslint"]
|
|
201
|
+
},
|
|
199
202
|
"JSON": {
|
|
200
203
|
"language_servers": ["...", "eslint"]
|
|
201
204
|
},
|
|
@@ -213,10 +216,7 @@ Add the following settings to your `.zed/settings.json`:
|
|
|
213
216
|
"lsp": {
|
|
214
217
|
"eslint": {
|
|
215
218
|
"settings": {
|
|
216
|
-
|
|
217
|
-
"experimental": {
|
|
218
|
-
"useFlatConfig": false
|
|
219
|
-
},
|
|
219
|
+
"workingDirectories": ["./"],
|
|
220
220
|
|
|
221
221
|
// Silent the stylistic rules in your IDE, but still auto fix them
|
|
222
222
|
"rulesCustomizations": [
|
|
@@ -713,7 +713,7 @@ export default eslintConfig({
|
|
|
713
713
|
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
714
714
|
|
|
715
715
|
```bash
|
|
716
|
-
npm i -D @eslint-react/eslint-plugin eslint-plugin-react-
|
|
716
|
+
npm i -D @eslint-react/eslint-plugin eslint-plugin-react-refresh
|
|
717
717
|
```
|
|
718
718
|
|
|
719
719
|
#### Next.js
|
package/dist/cli.mjs
CHANGED
|
@@ -7,10 +7,8 @@ import c, { green } from "ansis";
|
|
|
7
7
|
import { cac } from "cac";
|
|
8
8
|
import parse from "parse-gitignore";
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
|
-
|
|
11
10
|
//#region package.json
|
|
12
|
-
var version = "
|
|
13
|
-
|
|
11
|
+
var version = "6.0.0";
|
|
14
12
|
//#endregion
|
|
15
13
|
//#region src/cli/constants.ts
|
|
16
14
|
const vscodeSettingsString = `
|
|
@@ -105,18 +103,13 @@ const dependenciesMap = {
|
|
|
105
103
|
formatter: ["eslint-plugin-format"],
|
|
106
104
|
formatterAstro: ["prettier-plugin-astro"],
|
|
107
105
|
nextjs: ["@next/eslint-plugin-next"],
|
|
108
|
-
react: [
|
|
109
|
-
"@eslint-react/eslint-plugin",
|
|
110
|
-
"eslint-plugin-react-hooks",
|
|
111
|
-
"eslint-plugin-react-refresh"
|
|
112
|
-
],
|
|
106
|
+
react: ["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"],
|
|
113
107
|
slidev: ["prettier-plugin-slidev"],
|
|
114
108
|
solid: ["eslint-plugin-solid"],
|
|
115
109
|
svelte: ["eslint-plugin-svelte", "svelte-eslint-parser"],
|
|
116
110
|
unocss: ["@unocss/eslint-plugin"],
|
|
117
111
|
vue: []
|
|
118
112
|
};
|
|
119
|
-
|
|
120
113
|
//#endregion
|
|
121
114
|
//#region src/cli/utils.ts
|
|
122
115
|
function isGitClean() {
|
|
@@ -136,9 +129,10 @@ ${mainConfig}
|
|
|
136
129
|
}${additionalConfigs?.map((config) => `,{\n${config}\n}`)})
|
|
137
130
|
`.trimStart();
|
|
138
131
|
}
|
|
139
|
-
|
|
140
132
|
//#endregion
|
|
141
133
|
//#region src/cli/stages/update-eslint-files.ts
|
|
134
|
+
const ESLINT_OR_PRETTIER = /eslint|prettier/;
|
|
135
|
+
const ESLINT_CONFIG = /eslint\.config\./;
|
|
142
136
|
async function updateEslintFiles(result) {
|
|
143
137
|
const cwd = process.cwd();
|
|
144
138
|
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
@@ -164,30 +158,27 @@ async function updateEslintFiles(result) {
|
|
|
164
158
|
const files = fs$1.readdirSync(cwd);
|
|
165
159
|
const legacyConfig = [];
|
|
166
160
|
files.forEach((file) => {
|
|
167
|
-
if (
|
|
161
|
+
if (ESLINT_OR_PRETTIER.test(file) && !ESLINT_CONFIG.test(file)) legacyConfig.push(file);
|
|
168
162
|
});
|
|
169
163
|
if (legacyConfig.length) p.note(c.dim(legacyConfig.join(", ")), "You can now remove those files manually");
|
|
170
164
|
}
|
|
171
|
-
|
|
172
165
|
//#endregion
|
|
173
166
|
//#region src/cli/constants-generated.ts
|
|
174
167
|
const versionsMap = {
|
|
175
|
-
"@eslint-react/eslint-plugin": "^
|
|
176
|
-
"@next/eslint-plugin-next": "^16.
|
|
177
|
-
"@unocss/eslint-plugin": "^66.6.
|
|
178
|
-
"astro-eslint-parser": "^1.
|
|
179
|
-
"eslint": "^10.0
|
|
180
|
-
"eslint-plugin-astro": "^1.
|
|
168
|
+
"@eslint-react/eslint-plugin": "^3.0.0",
|
|
169
|
+
"@next/eslint-plugin-next": "^16.2.3",
|
|
170
|
+
"@unocss/eslint-plugin": "^66.6.8",
|
|
171
|
+
"astro-eslint-parser": "^1.4.0",
|
|
172
|
+
"eslint": "^10.2.0",
|
|
173
|
+
"eslint-plugin-astro": "^1.7.0",
|
|
181
174
|
"eslint-plugin-format": "^2.0.1",
|
|
182
|
-
"eslint-plugin-react-hooks": "^7.0.1",
|
|
183
175
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
184
176
|
"eslint-plugin-solid": "^0.14.5",
|
|
185
|
-
"eslint-plugin-svelte": "^3.
|
|
177
|
+
"eslint-plugin-svelte": "^3.17.0",
|
|
186
178
|
"prettier-plugin-astro": "^0.14.1",
|
|
187
179
|
"prettier-plugin-slidev": "^1.0.5",
|
|
188
|
-
"svelte-eslint-parser": "^1.
|
|
180
|
+
"svelte-eslint-parser": "^1.6.0"
|
|
189
181
|
};
|
|
190
|
-
|
|
191
182
|
//#endregion
|
|
192
183
|
//#region src/cli/stages/update-package-json.ts
|
|
193
184
|
async function updatePackageJson(result) {
|
|
@@ -228,9 +219,9 @@ async function updatePackageJson(result) {
|
|
|
228
219
|
await fs.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
229
220
|
p.log.success(c.green`Changes wrote to package.json`);
|
|
230
221
|
}
|
|
231
|
-
|
|
232
222
|
//#endregion
|
|
233
223
|
//#region src/cli/stages/update-vscode-settings.ts
|
|
224
|
+
const LAST_LINE_PATTERN = /\s*\}$/;
|
|
234
225
|
async function updateVscodeSettings(result) {
|
|
235
226
|
const cwd = process.cwd();
|
|
236
227
|
if (!result.updateVscodeSettings) return;
|
|
@@ -242,14 +233,13 @@ async function updateVscodeSettings(result) {
|
|
|
242
233
|
p.log.success(green`Created .vscode/settings.json`);
|
|
243
234
|
} else {
|
|
244
235
|
let settingsContent = await fs.readFile(settingsPath, "utf8");
|
|
245
|
-
settingsContent = settingsContent.trim().replace(
|
|
236
|
+
settingsContent = settingsContent.trim().replace(LAST_LINE_PATTERN, "");
|
|
246
237
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
247
238
|
settingsContent += `${vscodeSettingsString}}\n`;
|
|
248
239
|
await fs.writeFile(settingsPath, settingsContent, "utf-8");
|
|
249
240
|
p.log.success(green`Updated .vscode/settings.json`);
|
|
250
241
|
}
|
|
251
242
|
}
|
|
252
|
-
|
|
253
243
|
//#endregion
|
|
254
244
|
//#region src/cli/run.ts
|
|
255
245
|
async function run(options = {}) {
|
|
@@ -314,7 +304,6 @@ async function run(options = {}) {
|
|
|
314
304
|
p.log.success(c.green`Setup completed`);
|
|
315
305
|
p.outro(`Now you can update the dependencies by run ${c.blue("pnpm install")} and run ${c.blue("eslint --fix")}\n`);
|
|
316
306
|
}
|
|
317
|
-
|
|
318
307
|
//#endregion
|
|
319
308
|
//#region src/cli/index.ts
|
|
320
309
|
function header() {
|
|
@@ -335,6 +324,5 @@ cli.command("", "Run the initialization or migration").option("--yes, -y", "Skip
|
|
|
335
324
|
cli.help();
|
|
336
325
|
cli.version(version);
|
|
337
326
|
cli.parse();
|
|
338
|
-
|
|
339
327
|
//#endregion
|
|
340
|
-
export {
|
|
328
|
+
export {};
|