@eienjs/eslint-config 1.9.1 → 1.9.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.mjs +6 -6
- package/dist/cli/stages/update_eslint_files.mjs +4 -4
- package/dist/cli/stages/update_package_json.mjs +3 -3
- package/dist/cli/stages/update_vscode_settings.mjs +5 -5
- package/dist/configs/adonisjs.mjs +12 -2
- package/dist/configs/formatters.mjs +1 -1
- package/dist/configs/ignores.d.mts +1 -1
- package/dist/configs/ignores.mjs +3 -2
- package/dist/configs/jsdoc.mjs +2 -0
- package/dist/configs/node.mjs +2 -0
- package/dist/factory.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.mjs +2 -2
- package/dist/package.mjs +1 -1
- package/dist/typegen.d.mts +227 -168
- package/dist/types.d.mts +3 -1
- package/package.json +41 -38
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region src/cli/constants_generated.ts
|
|
2
2
|
const versionsMap = {
|
|
3
|
-
"@adonisjs/eslint-plugin": "^2.2.
|
|
4
|
-
"@nuxt/eslint-plugin": "^1.
|
|
5
|
-
"astro-eslint-parser": "^1.
|
|
6
|
-
"eslint": "^9.39.
|
|
7
|
-
"eslint-plugin-astro": "^1.
|
|
8
|
-
"eslint-plugin-format": "^1.
|
|
3
|
+
"@adonisjs/eslint-plugin": "^2.2.2",
|
|
4
|
+
"@nuxt/eslint-plugin": "^1.15.1",
|
|
5
|
+
"astro-eslint-parser": "^1.3.0",
|
|
6
|
+
"eslint": "^9.39.3",
|
|
7
|
+
"eslint-plugin-astro": "^1.6.0",
|
|
8
|
+
"eslint-plugin-format": "^1.4.0",
|
|
9
9
|
"prettier-plugin-astro": "^0.14.1"
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getEslintConfigContent } from "../utils.mjs";
|
|
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.mjs";
|
|
|
2
2
|
import { dependenciesMap } from "../constants.mjs";
|
|
3
3
|
import { versionsMap } from "../constants_generated.mjs";
|
|
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";
|
|
@@ -12,7 +12,7 @@ async function updatePackageJson(result) {
|
|
|
12
12
|
const cwd = process.cwd();
|
|
13
13
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
14
14
|
p.log.step(c.cyan`Bumping @eienjs/eslint-config to v${version}`);
|
|
15
|
-
const pkgContent = await
|
|
15
|
+
const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf8");
|
|
16
16
|
const pkg = JSON.parse(pkgContent);
|
|
17
17
|
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
18
18
|
pkg.devDependencies["@eienjs/eslint-config"] = `^${version}`;
|
|
@@ -38,7 +38,7 @@ async function updatePackageJson(result) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
if (addedPackages.length > 0) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
41
|
-
await
|
|
41
|
+
await fsPromises.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
42
42
|
p.log.success(c.green`Changes wrote to package.json`);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vscodeSettingsString } from "../constants.mjs";
|
|
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(/\s*\}$/, "");
|
|
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
|
}
|
|
@@ -17,10 +17,11 @@ async function adonisjs(options = {}) {
|
|
|
17
17
|
dirs.listeners = dirs.listeners || `${appPath}/listeners`;
|
|
18
18
|
dirs.events = dirs.events || `${appPath}/events`;
|
|
19
19
|
dirs.middleware = dirs.middleware || `${appPath}/middleware`;
|
|
20
|
+
dirs.transformers = dirs.transformers || `${appPath}/transformers`;
|
|
20
21
|
dirs.validators = dirs.validators || `${appPath}/validators`;
|
|
22
|
+
dirs.providers = dirs.providers || `${dirs.root}/providers`;
|
|
21
23
|
dirs.policies = dirs.policies || `${appPath}/policies`;
|
|
22
24
|
dirs.abilities = dirs.abilities || `${appPath}/abilities`;
|
|
23
|
-
dirs.providers = dirs.providers || `${dirs.root}/providers`;
|
|
24
25
|
dirs.database = dirs.database || `${dirs.root}/database`;
|
|
25
26
|
dirs.bin = dirs.bin || `${dirs.root}/bin`;
|
|
26
27
|
dirs.start = dirs.start || `${dirs.root}/start`;
|
|
@@ -73,7 +74,8 @@ async function adonisjs(options = {}) {
|
|
|
73
74
|
name: "eienjs/adonisjs/bin-disables",
|
|
74
75
|
rules: {
|
|
75
76
|
...commonRulesSet,
|
|
76
|
-
"@typescript-eslint/no-misused-promises": "off"
|
|
77
|
+
"@typescript-eslint/no-misused-promises": "off",
|
|
78
|
+
"n/prefer-global/process": "off"
|
|
77
79
|
}
|
|
78
80
|
},
|
|
79
81
|
{
|
|
@@ -86,6 +88,14 @@ async function adonisjs(options = {}) {
|
|
|
86
88
|
name: "eienjs/adonisjs/middleware-disables",
|
|
87
89
|
rules: { ...commonRulesSet }
|
|
88
90
|
},
|
|
91
|
+
{
|
|
92
|
+
files: [join(dirs.transformers, nestedGlobPattern)],
|
|
93
|
+
name: "eienjs/adonisjs/transformers-disables",
|
|
94
|
+
rules: {
|
|
95
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
96
|
+
"@typescript-eslint/explicit-module-boundary-types": "off"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
89
99
|
{
|
|
90
100
|
files: [join(dirs.exceptions, nestedGlobPattern)],
|
|
91
101
|
name: "eienjs/adonisjs/exceptions-disables",
|
|
@@ -3,7 +3,7 @@ import { ensurePackages, interopDefault, isPackageInScope, parserPlain } from ".
|
|
|
3
3
|
import { StylisticConfigDefaults } from "./stylistic.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/configs/formatters.ts
|
|
6
|
-
function mergePrettierOptions(options, overrides
|
|
6
|
+
function mergePrettierOptions(options, overrides) {
|
|
7
7
|
return {
|
|
8
8
|
...options,
|
|
9
9
|
...overrides,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedFlatConfigItem } from "../types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/configs/ignores.d.ts
|
|
4
|
-
declare function ignores(userIgnores?: string[] | ((originals: string[]) => string[])): TypedFlatConfigItem[];
|
|
4
|
+
declare function ignores(userIgnores?: string[] | ((originals: string[]) => string[]), ignoreTypescript?: boolean): TypedFlatConfigItem[];
|
|
5
5
|
//#endregion
|
|
6
6
|
export { ignores };
|
package/dist/configs/ignores.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { GLOB_EXCLUDE } from "../globs.mjs";
|
|
1
|
+
import { GLOB_EXCLUDE, GLOB_TS, GLOB_TSX } from "../globs.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/configs/ignores.ts
|
|
4
|
-
function ignores(userIgnores = []) {
|
|
4
|
+
function ignores(userIgnores = [], ignoreTypescript = false) {
|
|
5
5
|
let ignores = [...GLOB_EXCLUDE];
|
|
6
|
+
if (ignoreTypescript) ignores.push(GLOB_TS, GLOB_TSX);
|
|
6
7
|
ignores = typeof userIgnores === "function" ? userIgnores(ignores) : [...ignores, ...userIgnores];
|
|
7
8
|
return [{
|
|
8
9
|
ignores,
|
package/dist/configs/jsdoc.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { GLOB_SRC } from "../globs.mjs";
|
|
1
2
|
import { interopDefault } from "../utils.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/configs/jsdoc.ts
|
|
4
5
|
async function jsdoc(options = {}) {
|
|
5
6
|
const { stylistic = true } = options;
|
|
6
7
|
return [{
|
|
8
|
+
files: [GLOB_SRC],
|
|
7
9
|
name: "eienjs/jsdoc/rules",
|
|
8
10
|
plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
|
|
9
11
|
rules: {
|
package/dist/configs/node.mjs
CHANGED
package/dist/factory.mjs
CHANGED
|
@@ -68,7 +68,7 @@ function eienjs(options = {}) {
|
|
|
68
68
|
...enableGitignore
|
|
69
69
|
})]));
|
|
70
70
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
71
|
-
configs.push(ignores(userIgnores), javascript({
|
|
71
|
+
configs.push(ignores(userIgnores, !enableTypeScript), javascript({
|
|
72
72
|
isInEditor,
|
|
73
73
|
overrides: getOverrides(options, "javascript")
|
|
74
74
|
}), comments(), command(), perfectionist());
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ConfigNames } from "./typegen.mjs";
|
|
1
|
+
import { ConfigNames, RuleOptions } from "./typegen.mjs";
|
|
2
2
|
import { Awaitable, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsPnpm, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, Rules, StylisticConfig, TypedFlatConfigItem } from "./types.mjs";
|
|
3
3
|
import { ResolvedOptions, defaultPluginRenaming, eienjs, getOverrides, resolveSubOptions } from "./factory.mjs";
|
|
4
4
|
import { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON } from "./config_presets.mjs";
|
|
5
5
|
import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML } from "./globs.mjs";
|
|
6
6
|
import { combine, ensurePackages, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, toArray } from "./utils.mjs";
|
|
7
|
-
export { Awaitable, CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsPnpm, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, ResolvedOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
|
7
|
+
export { Awaitable, CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_EXTS, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsErasableSyntaxOnly, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsPnpm, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsTypescriptWithErasableSyntaxOnly, OptionsVue, ResolvedOptions, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
|
@@ -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";
|
|
@@ -14,7 +14,7 @@ async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {})
|
|
|
14
14
|
while (directory) {
|
|
15
15
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
16
16
|
try {
|
|
17
|
-
const stats = await
|
|
17
|
+
const stats = await fsPromises.stat(filePath);
|
|
18
18
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
19
19
|
} catch {}
|
|
20
20
|
if (directory === stopAt || directory === root) break;
|
package/dist/package.mjs
CHANGED