@eienjs/eslint-config 1.11.1 → 1.11.3
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/constants_generated.js +2 -2
- package/dist/cli/stages/update_eslint_files.js +4 -4
- package/dist/cli/stages/update_package_json.js +3 -3
- package/dist/cli/stages/update_vscode_settings.js +5 -5
- package/dist/configs/e18e.d.ts +2 -2
- package/dist/configs/e18e.js +5 -1
- package/dist/factory.js +2 -5
- package/dist/node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js +2 -2
- package/dist/package.js +1 -1
- package/dist/typegen.d.ts +411 -152
- package/dist/types.d.ts +2 -2
- package/dist/utils.js +1 -1
- package/package.json +26 -23
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
const versionsMap = {
|
|
3
3
|
"@adonisjs/eslint-plugin": "^2.2.2",
|
|
4
4
|
"@nuxt/eslint-plugin": "^1.15.2",
|
|
5
|
-
"astro-eslint-parser": "^1.
|
|
6
|
-
"eslint": "^10.0
|
|
5
|
+
"astro-eslint-parser": "^1.4.0",
|
|
6
|
+
"eslint": "^10.2.0",
|
|
7
7
|
"eslint-plugin-astro": "^1.6.0",
|
|
8
8
|
"eslint-plugin-format": "^2.0.1",
|
|
9
9
|
"prettier-plugin-astro": "^0.14.1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getEslintConfigContent } from "../utils.js";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import
|
|
3
|
+
import fsPromises from "node:fs/promises";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import * as p from "@clack/prompts";
|
|
@@ -12,13 +12,13 @@ async function updateEslintFiles(result) {
|
|
|
12
12
|
const cwd = process.cwd();
|
|
13
13
|
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
14
14
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
15
|
-
const pkgContent = await
|
|
15
|
+
const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf8");
|
|
16
16
|
const configFileName = JSON.parse(pkgContent).type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
17
17
|
const pathFlatConfig = path.join(cwd, configFileName);
|
|
18
18
|
const eslintIgnores = [];
|
|
19
19
|
if (fs.existsSync(pathESLintIgnore)) {
|
|
20
20
|
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
21
|
-
const globs = parse(await
|
|
21
|
+
const globs = parse(await fsPromises.readFile(pathESLintIgnore, "utf8")).globs();
|
|
22
22
|
for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
|
23
23
|
else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
24
24
|
}
|
|
@@ -27,7 +27,7 @@ async function updateEslintFiles(result) {
|
|
|
27
27
|
if (result.extra.includes("formatter")) configLines.push("formatters: true,");
|
|
28
28
|
for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
|
|
29
29
|
const eslintConfigContent = getEslintConfigContent(configLines.map((i) => ` ${i}`).join("\n"));
|
|
30
|
-
await
|
|
30
|
+
await fsPromises.writeFile(pathFlatConfig, eslintConfigContent);
|
|
31
31
|
p.log.success(c.green`Created ${configFileName}`);
|
|
32
32
|
const files = fs.readdirSync(cwd);
|
|
33
33
|
const legacyConfig = [];
|
|
@@ -2,7 +2,7 @@ import { version } from "../../package.js";
|
|
|
2
2
|
import { dependenciesMap } from "../constants.js";
|
|
3
3
|
import { versionsMap } from "../constants_generated.js";
|
|
4
4
|
import process from "node:process";
|
|
5
|
-
import
|
|
5
|
+
import fsPromises from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import * as p from "@clack/prompts";
|
|
8
8
|
import c from "ansis";
|
|
@@ -11,7 +11,7 @@ async function updatePackageJson(result) {
|
|
|
11
11
|
const cwd = process.cwd();
|
|
12
12
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
13
13
|
p.log.step(c.cyan`Bumping @eienjs/eslint-config to v${version}`);
|
|
14
|
-
const pkgContent = await
|
|
14
|
+
const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf8");
|
|
15
15
|
const pkg = JSON.parse(pkgContent);
|
|
16
16
|
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
17
17
|
pkg.devDependencies["@eienjs/eslint-config"] = `^${version}`;
|
|
@@ -37,7 +37,7 @@ async function updatePackageJson(result) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
if (addedPackages.length > 0) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
40
|
-
await
|
|
40
|
+
await fsPromises.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
41
41
|
p.log.success(c.green`Changes wrote to package.json`);
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vscodeSettingsString } from "../constants.js";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import
|
|
3
|
+
import fsPromises from "node:fs/promises";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import * as p from "@clack/prompts";
|
|
@@ -12,16 +12,16 @@ async function updateVscodeSettings(result) {
|
|
|
12
12
|
if (!result.updateVscodeSettings) return;
|
|
13
13
|
const dotVscodePath = path.join(cwd, ".vscode");
|
|
14
14
|
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
15
|
-
if (!fs.existsSync(dotVscodePath)) await
|
|
15
|
+
if (!fs.existsSync(dotVscodePath)) await fsPromises.mkdir(dotVscodePath, { recursive: true });
|
|
16
16
|
if (fs.existsSync(settingsPath)) {
|
|
17
|
-
let settingsContent = await
|
|
17
|
+
let settingsContent = await fsPromises.readFile(settingsPath, "utf8");
|
|
18
18
|
settingsContent = settingsContent.trim().replace(LAST_LINE_PATTERN, "");
|
|
19
19
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
20
20
|
settingsContent += `${vscodeSettingsString}}\n`;
|
|
21
|
-
await
|
|
21
|
+
await fsPromises.writeFile(settingsPath, settingsContent, "utf8");
|
|
22
22
|
p.log.success(green`Updated .vscode/settings.json`);
|
|
23
23
|
} else {
|
|
24
|
-
await
|
|
24
|
+
await fsPromises.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf8");
|
|
25
25
|
p.log.success(green`Created .vscode/settings.json`);
|
|
26
26
|
}
|
|
27
27
|
}
|
package/dist/configs/e18e.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OptionsE18e,
|
|
1
|
+
import { OptionsE18e, TypedFlatConfigItem } from "../types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/configs/e18e.d.ts
|
|
4
|
-
declare function e18e(options?:
|
|
4
|
+
declare function e18e(options?: OptionsE18e): TypedFlatConfigItem[];
|
|
5
5
|
//#endregion
|
|
6
6
|
export { e18e };
|
package/dist/configs/e18e.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pluginE18e } from "../plugins.js";
|
|
2
2
|
//#region src/configs/e18e.ts
|
|
3
3
|
function e18e(options = {}) {
|
|
4
|
-
const {
|
|
4
|
+
const { modernization = true, moduleReplacements = false, overrides = {}, performanceImprovements = true } = options;
|
|
5
5
|
const configs = pluginE18e.configs;
|
|
6
6
|
return [{
|
|
7
7
|
name: "eienjs/e18e/setup",
|
|
@@ -12,6 +12,10 @@ function e18e(options = {}) {
|
|
|
12
12
|
...modernization ? { ...configs.modernization.rules } : {},
|
|
13
13
|
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
14
14
|
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
15
|
+
"e18e/prefer-array-to-reversed": "off",
|
|
16
|
+
"e18e/prefer-array-to-sorted": "off",
|
|
17
|
+
"e18e/prefer-array-to-spliced": "off",
|
|
18
|
+
"e18e/prefer-spread-syntax": "off",
|
|
15
19
|
...overrides
|
|
16
20
|
}
|
|
17
21
|
}];
|
package/dist/factory.js
CHANGED
|
@@ -51,7 +51,7 @@ const defaultPluginRenaming = {
|
|
|
51
51
|
"yml": "yaml"
|
|
52
52
|
};
|
|
53
53
|
function eienjs(options = {}) {
|
|
54
|
-
const { adonisjs: enableAdonisjs = false, astro: enableAstro = false, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, node: enableNode = true, nuxt: enableNuxt = false, pnpm: enableCatalogs = Boolean(findUpSync("pnpm-workspace.yaml")), regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
54
|
+
const { adonisjs: enableAdonisjs = false, astro: enableAstro = false, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, node: enableNode = true, nuxt: enableNuxt = false, pnpm: enableCatalogs = Boolean(findUpSync("pnpm-workspace.yaml")), regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
55
55
|
let { isInEditor } = options;
|
|
56
56
|
if (isInEditor == null) {
|
|
57
57
|
isInEditor = isInEditorEnv();
|
|
@@ -78,10 +78,7 @@ function eienjs(options = {}) {
|
|
|
78
78
|
stylistic: stylisticOptions,
|
|
79
79
|
...resolveSubOptions(options, "imports")
|
|
80
80
|
}));
|
|
81
|
-
if (enableE18e) configs.push(e18e({
|
|
82
|
-
isInEditor,
|
|
83
|
-
...enableE18e === true ? {} : enableE18e
|
|
84
|
-
}));
|
|
81
|
+
if (enableE18e) configs.push(e18e({ ...enableE18e === true ? {} : enableE18e }));
|
|
85
82
|
if (enableUnicorn) configs.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
86
83
|
if (enableVue) componentExts.push("vue");
|
|
87
84
|
if (enableTypeScript) configs.push(typescript({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import
|
|
2
|
+
import fsPromises from "node:fs/promises";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
@@ -13,7 +13,7 @@ async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {})
|
|
|
13
13
|
while (directory) {
|
|
14
14
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
15
15
|
try {
|
|
16
|
-
const stats = await
|
|
16
|
+
const stats = await fsPromises.stat(filePath);
|
|
17
17
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
18
18
|
} catch {}
|
|
19
19
|
if (directory === stopAt || directory === root) break;
|
package/dist/package.js
CHANGED