@antfu/eslint-config 7.6.1 → 7.7.2
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 +66 -0
- package/dist/cli.mjs +11 -18
- package/dist/index.d.mts +1154 -2001
- package/dist/index.mjs +130 -142
- package/dist/{lib-B1Rme4qD.mjs → lib-D3Kr7UIJ.mjs} +559 -850
- package/package.json +45 -32
package/README.md
CHANGED
|
@@ -167,6 +167,72 @@ Add the following settings to your `.vscode/settings.json`:
|
|
|
167
167
|
|
|
168
168
|
</details>
|
|
169
169
|
|
|
170
|
+
<details>
|
|
171
|
+
<summary>🔲 Zed support</summary>
|
|
172
|
+
|
|
173
|
+
<br>
|
|
174
|
+
|
|
175
|
+
Add the following settings to your `.zed/settings.json`:
|
|
176
|
+
|
|
177
|
+
```jsonc
|
|
178
|
+
{
|
|
179
|
+
"format_on_save": "on",
|
|
180
|
+
"formatter": [
|
|
181
|
+
// Use ESLint's --fix:
|
|
182
|
+
{ "code_action": "source.fixAll.eslint" }
|
|
183
|
+
],
|
|
184
|
+
// Enable eslint for all supported languages
|
|
185
|
+
// Defaults only include https://github.com/search?q=repo%3Azed-industries%2Fzed%20eslint_languages&type=code
|
|
186
|
+
"languages": {
|
|
187
|
+
"HTML": {
|
|
188
|
+
"language_servers": ["...", "eslint"]
|
|
189
|
+
},
|
|
190
|
+
"Markdown": {
|
|
191
|
+
"language_servers": ["...", "eslint"]
|
|
192
|
+
},
|
|
193
|
+
"JSON": {
|
|
194
|
+
"language_servers": ["...", "eslint"]
|
|
195
|
+
},
|
|
196
|
+
"JSONC": {
|
|
197
|
+
"language_servers": ["...", "eslint"]
|
|
198
|
+
},
|
|
199
|
+
"YAML": {
|
|
200
|
+
"language_servers": ["...", "eslint"]
|
|
201
|
+
},
|
|
202
|
+
"CSS": {
|
|
203
|
+
"language_servers": ["...", "eslint"]
|
|
204
|
+
}
|
|
205
|
+
// Add other languages as needed
|
|
206
|
+
},
|
|
207
|
+
"lsp": {
|
|
208
|
+
"eslint": {
|
|
209
|
+
"settings": {
|
|
210
|
+
// Remove after https://github.com/zed-industries/zed/issues/49387
|
|
211
|
+
"experimental": {
|
|
212
|
+
"useFlatConfig": false
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
// Silent the stylistic rules in your IDE, but still auto fix them
|
|
216
|
+
"rulesCustomizations": [
|
|
217
|
+
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
218
|
+
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
219
|
+
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
220
|
+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
221
|
+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
222
|
+
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
223
|
+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
224
|
+
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
225
|
+
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
226
|
+
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
</details>
|
|
235
|
+
|
|
170
236
|
<details>
|
|
171
237
|
<summary>🟩 Neovim Support</summary>
|
|
172
238
|
|
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 = "7.
|
|
13
|
-
|
|
11
|
+
var version = "7.7.2";
|
|
14
12
|
//#endregion
|
|
15
13
|
//#region src/cli/constants.ts
|
|
16
14
|
const vscodeSettingsString = `
|
|
@@ -116,7 +114,6 @@ const dependenciesMap = {
|
|
|
116
114
|
unocss: ["@unocss/eslint-plugin"],
|
|
117
115
|
vue: []
|
|
118
116
|
};
|
|
119
|
-
|
|
120
117
|
//#endregion
|
|
121
118
|
//#region src/cli/utils.ts
|
|
122
119
|
function isGitClean() {
|
|
@@ -136,9 +133,10 @@ ${mainConfig}
|
|
|
136
133
|
}${additionalConfigs?.map((config) => `,{\n${config}\n}`)})
|
|
137
134
|
`.trimStart();
|
|
138
135
|
}
|
|
139
|
-
|
|
140
136
|
//#endregion
|
|
141
137
|
//#region src/cli/stages/update-eslint-files.ts
|
|
138
|
+
const ESLINT_OR_PRETTIER = /eslint|prettier/;
|
|
139
|
+
const ESLINT_CONFIG = /eslint\.config\./;
|
|
142
140
|
async function updateEslintFiles(result) {
|
|
143
141
|
const cwd = process.cwd();
|
|
144
142
|
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
@@ -164,30 +162,28 @@ async function updateEslintFiles(result) {
|
|
|
164
162
|
const files = fs$1.readdirSync(cwd);
|
|
165
163
|
const legacyConfig = [];
|
|
166
164
|
files.forEach((file) => {
|
|
167
|
-
if (
|
|
165
|
+
if (ESLINT_OR_PRETTIER.test(file) && !ESLINT_CONFIG.test(file)) legacyConfig.push(file);
|
|
168
166
|
});
|
|
169
167
|
if (legacyConfig.length) p.note(c.dim(legacyConfig.join(", ")), "You can now remove those files manually");
|
|
170
168
|
}
|
|
171
|
-
|
|
172
169
|
//#endregion
|
|
173
170
|
//#region src/cli/constants-generated.ts
|
|
174
171
|
const versionsMap = {
|
|
175
172
|
"@eslint-react/eslint-plugin": "^2.13.0",
|
|
176
173
|
"@next/eslint-plugin-next": "^16.1.6",
|
|
177
|
-
"@unocss/eslint-plugin": "^66.6.
|
|
174
|
+
"@unocss/eslint-plugin": "^66.6.6",
|
|
178
175
|
"astro-eslint-parser": "^1.3.0",
|
|
179
|
-
"eslint": "^10.0.
|
|
176
|
+
"eslint": "^10.0.3",
|
|
180
177
|
"eslint-plugin-astro": "^1.6.0",
|
|
181
178
|
"eslint-plugin-format": "^2.0.1",
|
|
182
179
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
183
180
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
184
181
|
"eslint-plugin-solid": "^0.14.5",
|
|
185
|
-
"eslint-plugin-svelte": "^3.15.
|
|
182
|
+
"eslint-plugin-svelte": "^3.15.2",
|
|
186
183
|
"prettier-plugin-astro": "^0.14.1",
|
|
187
184
|
"prettier-plugin-slidev": "^1.0.5",
|
|
188
|
-
"svelte-eslint-parser": "^1.
|
|
185
|
+
"svelte-eslint-parser": "^1.6.0"
|
|
189
186
|
};
|
|
190
|
-
|
|
191
187
|
//#endregion
|
|
192
188
|
//#region src/cli/stages/update-package-json.ts
|
|
193
189
|
async function updatePackageJson(result) {
|
|
@@ -228,9 +224,9 @@ async function updatePackageJson(result) {
|
|
|
228
224
|
await fs.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
229
225
|
p.log.success(c.green`Changes wrote to package.json`);
|
|
230
226
|
}
|
|
231
|
-
|
|
232
227
|
//#endregion
|
|
233
228
|
//#region src/cli/stages/update-vscode-settings.ts
|
|
229
|
+
const LAST_LINE_PATTERN = /\s*\}$/;
|
|
234
230
|
async function updateVscodeSettings(result) {
|
|
235
231
|
const cwd = process.cwd();
|
|
236
232
|
if (!result.updateVscodeSettings) return;
|
|
@@ -242,14 +238,13 @@ async function updateVscodeSettings(result) {
|
|
|
242
238
|
p.log.success(green`Created .vscode/settings.json`);
|
|
243
239
|
} else {
|
|
244
240
|
let settingsContent = await fs.readFile(settingsPath, "utf8");
|
|
245
|
-
settingsContent = settingsContent.trim().replace(
|
|
241
|
+
settingsContent = settingsContent.trim().replace(LAST_LINE_PATTERN, "");
|
|
246
242
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
247
243
|
settingsContent += `${vscodeSettingsString}}\n`;
|
|
248
244
|
await fs.writeFile(settingsPath, settingsContent, "utf-8");
|
|
249
245
|
p.log.success(green`Updated .vscode/settings.json`);
|
|
250
246
|
}
|
|
251
247
|
}
|
|
252
|
-
|
|
253
248
|
//#endregion
|
|
254
249
|
//#region src/cli/run.ts
|
|
255
250
|
async function run(options = {}) {
|
|
@@ -314,7 +309,6 @@ async function run(options = {}) {
|
|
|
314
309
|
p.log.success(c.green`Setup completed`);
|
|
315
310
|
p.outro(`Now you can update the dependencies by run ${c.blue("pnpm install")} and run ${c.blue("eslint --fix")}\n`);
|
|
316
311
|
}
|
|
317
|
-
|
|
318
312
|
//#endregion
|
|
319
313
|
//#region src/cli/index.ts
|
|
320
314
|
function header() {
|
|
@@ -335,6 +329,5 @@ cli.command("", "Run the initialization or migration").option("--yes, -y", "Skip
|
|
|
335
329
|
cli.help();
|
|
336
330
|
cli.version(version);
|
|
337
331
|
cli.parse();
|
|
338
|
-
|
|
339
332
|
//#endregion
|
|
340
|
-
export {
|
|
333
|
+
export {};
|