@infernodesign/eslint-config 1.17.1 → 1.17.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/dist/cli.js +16 -16
- package/dist/index.js +6 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as PACKAGE_NAME } from "./constants-DjBrEP6N.js";
|
|
2
|
-
import
|
|
3
|
-
import fs from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import fs$1 from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import * as p from "@clack/prompts";
|
|
6
6
|
import c, { green } from "ansis";
|
|
@@ -9,7 +9,7 @@ import parse from "parse-gitignore";
|
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
|
-
var version = "1.17.
|
|
12
|
+
var version = "1.17.2";
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/cli/constants.ts
|
|
@@ -163,13 +163,13 @@ async function updateEslintFiles(result) {
|
|
|
163
163
|
const cwd = process.cwd();
|
|
164
164
|
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
165
165
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
166
|
-
const pkgContent = await
|
|
166
|
+
const pkgContent = await fs.readFile(pathPackageJSON, "utf-8");
|
|
167
167
|
const configFileName = JSON.parse(pkgContent).type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
168
168
|
const pathFlatConfig = path.join(cwd, configFileName);
|
|
169
169
|
const eslintIgnores = [];
|
|
170
|
-
if (fs.existsSync(pathESLintIgnore)) {
|
|
170
|
+
if (fs$1.existsSync(pathESLintIgnore)) {
|
|
171
171
|
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
172
|
-
const globs = parse(await
|
|
172
|
+
const globs = parse(await fs.readFile(pathESLintIgnore, "utf-8")).globs();
|
|
173
173
|
for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
|
174
174
|
else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
175
175
|
}
|
|
@@ -179,9 +179,9 @@ async function updateEslintFiles(result) {
|
|
|
179
179
|
if (result.extra.includes("unocss")) configLines.push("unocss: true,");
|
|
180
180
|
for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
|
|
181
181
|
const eslintConfigContent = getEslintConfigContent(configLines.map((i) => ` ${i}`).join("\n"), []);
|
|
182
|
-
await
|
|
182
|
+
await fs.writeFile(pathFlatConfig, eslintConfigContent);
|
|
183
183
|
p.log.success(c.green`Created ${configFileName}`);
|
|
184
|
-
const files = fs.readdirSync(cwd);
|
|
184
|
+
const files = fs$1.readdirSync(cwd);
|
|
185
185
|
const legacyConfig = [];
|
|
186
186
|
files.forEach((file) => {
|
|
187
187
|
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) legacyConfig.push(file);
|
|
@@ -216,7 +216,7 @@ async function updatePackageJson(result) {
|
|
|
216
216
|
const cwd = process.cwd();
|
|
217
217
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
218
218
|
p.log.step(c.cyan`Bumping ${PACKAGE_NAME} to v${version}`);
|
|
219
|
-
const pkgContent = await
|
|
219
|
+
const pkgContent = await fs.readFile(pathPackageJSON, "utf-8");
|
|
220
220
|
const pkg = JSON.parse(pkgContent);
|
|
221
221
|
pkg.devDependencies ??= {};
|
|
222
222
|
pkg.devDependencies[PACKAGE_NAME] = `^${version}`;
|
|
@@ -247,7 +247,7 @@ async function updatePackageJson(result) {
|
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
249
|
if (addedPackages.length) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
250
|
-
await
|
|
250
|
+
await fs.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
251
251
|
p.log.success(c.green`Changes wrote to package.json`);
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -258,16 +258,16 @@ async function updateVscodeSettings(result) {
|
|
|
258
258
|
if (!result.updateVscodeSettings) return;
|
|
259
259
|
const dotVscodePath = path.join(cwd, ".vscode");
|
|
260
260
|
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
261
|
-
if (!fs.existsSync(dotVscodePath)) await
|
|
262
|
-
if (!fs.existsSync(settingsPath)) {
|
|
263
|
-
await
|
|
261
|
+
if (!fs$1.existsSync(dotVscodePath)) await fs.mkdir(dotVscodePath, { recursive: true });
|
|
262
|
+
if (!fs$1.existsSync(settingsPath)) {
|
|
263
|
+
await fs.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
|
|
264
264
|
p.log.success(green`Created .vscode/settings.json`);
|
|
265
265
|
} else {
|
|
266
|
-
let settingsContent = await
|
|
266
|
+
let settingsContent = await fs.readFile(settingsPath, "utf8");
|
|
267
267
|
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
268
268
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
269
269
|
settingsContent += `${vscodeSettingsString}}\n`;
|
|
270
|
-
await
|
|
270
|
+
await fs.writeFile(settingsPath, settingsContent, "utf-8");
|
|
271
271
|
p.log.success(green`Updated .vscode/settings.json`);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -278,7 +278,7 @@ async function run(options = {}) {
|
|
|
278
278
|
const argSkipPrompt = !!process.env.SKIP_PROMPT || options.yes;
|
|
279
279
|
const argTemplate = options.frameworks?.map((m) => m?.trim()).filter(Boolean);
|
|
280
280
|
const argExtra = options.extra?.map((m) => m?.trim()).filter(Boolean);
|
|
281
|
-
if (fs.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
281
|
+
if (fs$1.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
282
282
|
p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`);
|
|
283
283
|
return process.exit(1);
|
|
284
284
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as PACKAGE_NAME } from "./constants-DjBrEP6N.js";
|
|
2
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import process$1 from "node:process";
|
|
4
|
-
import
|
|
4
|
+
import fs from "node:fs/promises";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import fs, { existsSync, readdirSync, statSync } from "node:fs";
|
|
6
|
+
import fs$1, { existsSync, readdirSync, statSync } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { isPackageExists } from "local-pkg";
|
|
9
9
|
import createCommand from "eslint-plugin-command/config";
|
|
@@ -28,7 +28,7 @@ async function findUp(name, { cwd = process$1.cwd(), type = "file", stopAt } = {
|
|
|
28
28
|
while (directory) {
|
|
29
29
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
30
30
|
try {
|
|
31
|
-
const stats = await
|
|
31
|
+
const stats = await fs.stat(filePath);
|
|
32
32
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
33
33
|
} catch {}
|
|
34
34
|
if (directory === stopAt || directory === root) break;
|
|
@@ -43,7 +43,7 @@ function findUpSync(name, { cwd = process$1.cwd(), type = "file", stopAt } = {})
|
|
|
43
43
|
while (directory) {
|
|
44
44
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
45
45
|
try {
|
|
46
|
-
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
46
|
+
const stats = fs$1.statSync(filePath, { throwIfNoEntry: false });
|
|
47
47
|
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
48
48
|
} catch {}
|
|
49
49
|
if (directory === stopAt || directory === root) break;
|
|
@@ -1712,7 +1712,7 @@ async function pnpm(options) {
|
|
|
1712
1712
|
async function detectCatalogUsage() {
|
|
1713
1713
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1714
1714
|
if (!workspaceFile) return false;
|
|
1715
|
-
const yaml = await
|
|
1715
|
+
const yaml = await fs.readFile(workspaceFile, "utf-8");
|
|
1716
1716
|
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1717
1717
|
}
|
|
1718
1718
|
|
|
@@ -2407,7 +2407,7 @@ async function tailwindcss(options = {}) {
|
|
|
2407
2407
|
rules: {
|
|
2408
2408
|
...pluginTailwindCSS.configs["recommended-error"]?.rules,
|
|
2409
2409
|
"tailwindcss/enforce-consistent-line-wrapping": "off",
|
|
2410
|
-
...isUsingEntryPoint ? { "tailwindcss/no-unknown-classes": ["error", {
|
|
2410
|
+
...isUsingEntryPoint ? { "tailwindcss/no-unknown-classes": ["error", { entryPoint: resolvedEntryPointPath }] } : { "tailwindcss/no-unknown-classes": "off" },
|
|
2411
2411
|
...overrides
|
|
2412
2412
|
}
|
|
2413
2413
|
}];
|
package/package.json
CHANGED