@eienjs/eslint-config 0.1.0 → 0.3.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/bin/index.js +3 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +287 -0
- package/dist/configs/index.d.ts +5 -2
- package/dist/configs/index.js +2 -2
- package/dist/{configs-B_fhQhgr.js → configs-BA3UU5JJ.js} +167 -26
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -4
- package/dist/{types-BDuTVdZ8.d.ts → types-B-BVuwa4.d.ts} +52 -7
- package/package.json +19 -6
package/bin/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import * as p from "@clack/prompts";
|
|
3
|
+
import c, { green } from "ansis";
|
|
4
|
+
import { cac } from "cac";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import fsp from "node:fs/promises";
|
|
8
|
+
import parse from "parse-gitignore";
|
|
9
|
+
import { execSync } from "node:child_process";
|
|
10
|
+
|
|
11
|
+
//#region package.json
|
|
12
|
+
var version = "0.3.0";
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/cli/constants.ts
|
|
16
|
+
const vscodeSettingsString = `
|
|
17
|
+
// Disable the default formatter, use eslint instead
|
|
18
|
+
"prettier.enable": false,
|
|
19
|
+
"editor.formatOnSave": false,
|
|
20
|
+
"eslint.format.enable": true,
|
|
21
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
|
|
22
|
+
|
|
23
|
+
// Auto fix
|
|
24
|
+
"editor.codeActionsOnSave": {
|
|
25
|
+
"source.organizeImports": "never"
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
"eslint.runtime": "node",
|
|
29
|
+
|
|
30
|
+
// Enable eslint for all supported languages
|
|
31
|
+
"eslint.validate": [
|
|
32
|
+
"javascript",
|
|
33
|
+
"typescript",
|
|
34
|
+
"vue",
|
|
35
|
+
"html",
|
|
36
|
+
"markdown",
|
|
37
|
+
"json",
|
|
38
|
+
"json5",
|
|
39
|
+
"jsonc",
|
|
40
|
+
"yaml",
|
|
41
|
+
"toml",
|
|
42
|
+
"xml",
|
|
43
|
+
"astro",
|
|
44
|
+
"css",
|
|
45
|
+
"less",
|
|
46
|
+
"scss",
|
|
47
|
+
"pcss",
|
|
48
|
+
"postcss"
|
|
49
|
+
],
|
|
50
|
+
`;
|
|
51
|
+
const frameworkOptions = [
|
|
52
|
+
{
|
|
53
|
+
label: c.green("Vue"),
|
|
54
|
+
value: "vue"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: c.magenta("Astro"),
|
|
58
|
+
value: "astro"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: c.blueBright("AdonisJS"),
|
|
62
|
+
value: "adonisjs"
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
const frameworks = frameworkOptions.map(({ value }) => value);
|
|
66
|
+
const extraOptions = [{
|
|
67
|
+
hint: "Use external formatters (Prettier) to format files that ESLint cannot handle yet (.css, .html, etc)",
|
|
68
|
+
label: c.red("Formatter"),
|
|
69
|
+
value: "formatter"
|
|
70
|
+
}];
|
|
71
|
+
const extra = extraOptions.map(({ value }) => value);
|
|
72
|
+
const dependenciesMap = {
|
|
73
|
+
astro: ["eslint-plugin-astro", "astro-eslint-parser"],
|
|
74
|
+
formatter: ["eslint-plugin-format"],
|
|
75
|
+
formatterAstro: ["prettier-plugin-astro"],
|
|
76
|
+
vue: [],
|
|
77
|
+
adonisjs: ["@adonisjs/eslint-plugin"]
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/cli/utils.ts
|
|
82
|
+
function isGitClean() {
|
|
83
|
+
try {
|
|
84
|
+
execSync("git diff-index --quiet HEAD --");
|
|
85
|
+
return true;
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function getEslintConfigContent(mainConfig) {
|
|
91
|
+
return `
|
|
92
|
+
import eienjs from '@eienjs/eslint-config';
|
|
93
|
+
|
|
94
|
+
export default eienjs({
|
|
95
|
+
${mainConfig}
|
|
96
|
+
});
|
|
97
|
+
`.trimStart();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/cli/stages/update_eslint_files.ts
|
|
102
|
+
async function updateEslintFiles(result) {
|
|
103
|
+
const cwd = process.cwd();
|
|
104
|
+
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
105
|
+
const pathPackageJSON = path.join(cwd, "package.json");
|
|
106
|
+
const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
|
|
107
|
+
const pkg = JSON.parse(pkgContent);
|
|
108
|
+
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
109
|
+
const pathFlatConfig = path.join(cwd, configFileName);
|
|
110
|
+
const eslintIgnores = [];
|
|
111
|
+
if (fs.existsSync(pathESLintIgnore)) {
|
|
112
|
+
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
113
|
+
const content = await fsp.readFile(pathESLintIgnore, "utf8");
|
|
114
|
+
const parsed = parse(content);
|
|
115
|
+
const globs = parsed.globs();
|
|
116
|
+
for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
|
117
|
+
else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
118
|
+
}
|
|
119
|
+
const configLines = [];
|
|
120
|
+
if (eslintIgnores.length > 0) configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
121
|
+
if (result.extra.includes("formatter")) configLines.push("formatters: true,");
|
|
122
|
+
for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
|
|
123
|
+
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
124
|
+
const eslintConfigContent = getEslintConfigContent(mainConfig);
|
|
125
|
+
await fsp.writeFile(pathFlatConfig, eslintConfigContent);
|
|
126
|
+
p.log.success(c.green`Created ${configFileName}`);
|
|
127
|
+
const files = fs.readdirSync(cwd);
|
|
128
|
+
const legacyConfig = [];
|
|
129
|
+
for (const file of files) if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) legacyConfig.push(file);
|
|
130
|
+
if (legacyConfig.length > 0) p.note(c.dim(legacyConfig.join(", ")), "You can now remove those files manually");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/cli/constants_generated.ts
|
|
135
|
+
const versionsMap = {
|
|
136
|
+
"@adonisjs/eslint-plugin": "^2.0.0",
|
|
137
|
+
"astro-eslint-parser": "^1.2.2",
|
|
138
|
+
"eslint": "^9.32.0",
|
|
139
|
+
"eslint-plugin-astro": "^1.3.1",
|
|
140
|
+
"eslint-plugin-format": "^1.0.1",
|
|
141
|
+
"prettier-plugin-astro": "^0.14.1"
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/cli/stages/update_package_json.ts
|
|
146
|
+
async function updatePackageJson(result) {
|
|
147
|
+
const cwd = process.cwd();
|
|
148
|
+
const pathPackageJSON = path.join(cwd, "package.json");
|
|
149
|
+
p.log.step(c.cyan`Bumping @eienjs/eslint-config to v${version}`);
|
|
150
|
+
const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
|
|
151
|
+
const pkg = JSON.parse(pkgContent);
|
|
152
|
+
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
153
|
+
pkg.devDependencies["@eienjs/eslint-config"] = `^${version}`;
|
|
154
|
+
pkg.devDependencies.eslint = pkg.devDependencies.eslint ?? versionsMap.eslint;
|
|
155
|
+
const addedPackages = [];
|
|
156
|
+
if (result.extra.length > 0) {
|
|
157
|
+
const extraPackages = result.extra;
|
|
158
|
+
for (const item of extraPackages) switch (item) {
|
|
159
|
+
case "formatter":
|
|
160
|
+
for (const f of [...dependenciesMap.formatter, ...result.frameworks.includes("astro") ? dependenciesMap.formatterAstro : []]) {
|
|
161
|
+
if (!f) continue;
|
|
162
|
+
pkg.devDependencies[f] = versionsMap[f];
|
|
163
|
+
addedPackages.push(f);
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
for (const framework of result.frameworks) {
|
|
169
|
+
const deps = dependenciesMap[framework];
|
|
170
|
+
if (deps) for (const f of deps) {
|
|
171
|
+
pkg.devDependencies[f] = versionsMap[f];
|
|
172
|
+
addedPackages.push(f);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (addedPackages.length > 0) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
176
|
+
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
177
|
+
p.log.success(c.green`Changes wrote to package.json`);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/cli/stages/update_vscode_settings.ts
|
|
182
|
+
async function updateVscodeSettings(result) {
|
|
183
|
+
const cwd = process.cwd();
|
|
184
|
+
if (!result.updateVscodeSettings) return;
|
|
185
|
+
const dotVscodePath = path.join(cwd, ".vscode");
|
|
186
|
+
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
187
|
+
if (!fs.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
|
|
188
|
+
if (fs.existsSync(settingsPath)) {
|
|
189
|
+
let settingsContent = await fsp.readFile(settingsPath, "utf8");
|
|
190
|
+
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
191
|
+
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
192
|
+
settingsContent += `${vscodeSettingsString}}\n`;
|
|
193
|
+
await fsp.writeFile(settingsPath, settingsContent, "utf8");
|
|
194
|
+
p.log.success(green`Updated .vscode/settings.json`);
|
|
195
|
+
} else {
|
|
196
|
+
await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf8");
|
|
197
|
+
p.log.success(green`Created .vscode/settings.json`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/cli/run.ts
|
|
203
|
+
async function run(options = {}) {
|
|
204
|
+
const argSkipPrompt = Boolean(process.env.SKIP_PROMPT) || options.yes;
|
|
205
|
+
const argTemplate = options.frameworks?.map((m) => m?.trim()).filter(Boolean);
|
|
206
|
+
const argExtra = options.extra?.map((m) => m?.trim()).filter(Boolean);
|
|
207
|
+
if (fs.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
208
|
+
p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`);
|
|
209
|
+
return process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
let result = {
|
|
212
|
+
extra: argExtra ?? [],
|
|
213
|
+
frameworks: argTemplate ?? [],
|
|
214
|
+
uncommittedConfirmed: false,
|
|
215
|
+
updateVscodeSettings: true
|
|
216
|
+
};
|
|
217
|
+
if (!argSkipPrompt) {
|
|
218
|
+
result = await p.group({
|
|
219
|
+
uncommittedConfirmed: async () => {
|
|
220
|
+
if (argSkipPrompt || isGitClean()) return true;
|
|
221
|
+
return p.confirm({
|
|
222
|
+
initialValue: false,
|
|
223
|
+
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
224
|
+
});
|
|
225
|
+
},
|
|
226
|
+
frameworks: async ({ results }) => {
|
|
227
|
+
const isArgTemplateValid = typeof argTemplate === "string" && Boolean(frameworks.includes(argTemplate));
|
|
228
|
+
if (!results.uncommittedConfirmed || isArgTemplateValid) return;
|
|
229
|
+
const message = !isArgTemplateValid && argTemplate ? `"${argTemplate.toString()}" isn't a valid template. Please choose from below: ` : "Select a framework:";
|
|
230
|
+
return p.multiselect({
|
|
231
|
+
message: c.reset(message),
|
|
232
|
+
options: frameworkOptions,
|
|
233
|
+
required: false
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
extra: async ({ results }) => {
|
|
237
|
+
const isArgExtraValid = argExtra?.length && argExtra.filter((element) => !extra.includes(element)).length === 0;
|
|
238
|
+
if (!results.uncommittedConfirmed || isArgExtraValid) return;
|
|
239
|
+
const message = !isArgExtraValid && argExtra ? `"${argExtra.toString()}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
|
|
240
|
+
return p.multiselect({
|
|
241
|
+
message: c.reset(message),
|
|
242
|
+
options: extraOptions,
|
|
243
|
+
required: false
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
updateVscodeSettings: async ({ results }) => {
|
|
247
|
+
if (!results.uncommittedConfirmed) return;
|
|
248
|
+
return p.confirm({
|
|
249
|
+
initialValue: true,
|
|
250
|
+
message: "Update .vscode/settings.json for better VS Code experience?"
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}, { onCancel: () => {
|
|
254
|
+
p.cancel("Operation cancelled.");
|
|
255
|
+
process.exit(0);
|
|
256
|
+
} });
|
|
257
|
+
if (!result.uncommittedConfirmed) return process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
await updatePackageJson(result);
|
|
260
|
+
await updateEslintFiles(result);
|
|
261
|
+
await updateVscodeSettings(result);
|
|
262
|
+
p.log.success(c.green`Setup completed`);
|
|
263
|
+
p.outro(`Now you can update the dependencies by run ${c.blue("pnpm install")} and run ${c.blue("eslint --fix")}\n`);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/cli/index.ts
|
|
268
|
+
function header() {
|
|
269
|
+
console.log("\n");
|
|
270
|
+
p.intro(`${c.green`@eienjs/eslint-config `}${c.dim`v${version}`}`);
|
|
271
|
+
}
|
|
272
|
+
const cli = cac("@eienjs/eslint-config");
|
|
273
|
+
cli.command("", "Run the initialization or migration").option("--yes, -y", "Skip prompts and use default values", { default: false }).option("--template, -t <template>", "Use the framework template for optimal customization: vue / adonisjs / astro", { type: [] }).option("--extra, -e <extra>", "Use the extra utils: formatter", { type: [] }).action(async (args) => {
|
|
274
|
+
header();
|
|
275
|
+
try {
|
|
276
|
+
await run(args);
|
|
277
|
+
} catch (error) {
|
|
278
|
+
p.log.error(c.inverse.red(" Failed to migrate "));
|
|
279
|
+
p.log.error(c.red`✘ ${String(error)}`);
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
cli.help();
|
|
284
|
+
cli.version(version);
|
|
285
|
+
cli.parse();
|
|
286
|
+
|
|
287
|
+
//#endregion
|
package/dist/configs/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { OptionsComponentExts, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsVue, StylisticConfig, TypedFlatConfigItem } from "../types-
|
|
1
|
+
import { OptionsAdonisJS, OptionsComponentExts, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsVue, StylisticConfig, TypedFlatConfigItem } from "../types-B-BVuwa4.js";
|
|
2
2
|
|
|
3
|
+
//#region src/configs/adonisjs.d.ts
|
|
4
|
+
declare function adonisjs(options?: OptionsAdonisJS): Promise<TypedFlatConfigItem[]>;
|
|
5
|
+
//#endregion
|
|
3
6
|
//#region src/configs/astro.d.ts
|
|
4
7
|
declare function astro(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
|
|
5
8
|
//#endregion
|
|
@@ -87,4 +90,4 @@ declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverri
|
|
|
87
90
|
//#region src/configs/yaml.d.ts
|
|
88
91
|
declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
|
|
89
92
|
//#endregion
|
|
90
|
-
export { StylisticConfigDefaults, StylisticOptions, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml };
|
|
93
|
+
export { StylisticConfigDefaults, StylisticOptions, adonisjs, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml };
|
package/dist/configs/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StylisticConfigDefaults, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml } from "../configs-
|
|
1
|
+
import { StylisticConfigDefaults, adonisjs, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml } from "../configs-BA3UU5JJ.js";
|
|
2
2
|
|
|
3
|
-
export { StylisticConfigDefaults, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml };
|
|
3
|
+
export { StylisticConfigDefaults, adonisjs, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isPackageExists } from "local-pkg";
|
|
2
|
+
import { join } from "pathe";
|
|
2
3
|
import process from "node:process";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import createCommand from "eslint-plugin-command/config";
|
|
@@ -60,28 +61,36 @@ const GLOB_ALL_SRC = [
|
|
|
60
61
|
const GLOB_EXCLUDE = [
|
|
61
62
|
"**/node_modules",
|
|
62
63
|
"**/dist",
|
|
64
|
+
"**/build",
|
|
63
65
|
"**/package-lock.json",
|
|
64
66
|
"**/yarn.lock",
|
|
65
67
|
"**/pnpm-lock.yaml",
|
|
66
68
|
"**/bun.lockb",
|
|
69
|
+
"**/composer.lock",
|
|
70
|
+
"**/composer.json",
|
|
67
71
|
"**/output",
|
|
68
72
|
"**/coverage",
|
|
69
73
|
"**/temp",
|
|
70
74
|
"**/.temp",
|
|
71
75
|
"**/tmp",
|
|
72
76
|
"**/.tmp",
|
|
77
|
+
"**/vendor",
|
|
78
|
+
"**/public",
|
|
73
79
|
"**/.history",
|
|
74
80
|
"**/.vitepress/cache",
|
|
81
|
+
"**/.adonisjs",
|
|
75
82
|
"**/.nuxt",
|
|
76
83
|
"**/.next",
|
|
77
84
|
"**/.svelte-kit",
|
|
78
85
|
"**/.vercel",
|
|
86
|
+
"**/.husky",
|
|
79
87
|
"**/.changeset",
|
|
80
88
|
"**/.idea",
|
|
81
89
|
"**/.cache",
|
|
82
90
|
"**/.output",
|
|
83
91
|
"**/.vite-inspect",
|
|
84
92
|
"**/.yarn",
|
|
93
|
+
"**/.pnpm-store",
|
|
85
94
|
"**/vite.config.*.timestamp-*",
|
|
86
95
|
"**/CHANGELOG*.md",
|
|
87
96
|
"**/*.min.*",
|
|
@@ -136,7 +145,9 @@ async function ensurePackages(packages) {
|
|
|
136
145
|
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
137
146
|
if (nonExistingPackages.length === 0) return;
|
|
138
147
|
const p = await import("@clack/prompts");
|
|
139
|
-
const
|
|
148
|
+
const packagesMissing = nonExistingPackages.join(", ");
|
|
149
|
+
const packagesMissingPlural = nonExistingPackages.length === 1 ? "Package is" : "Packages are";
|
|
150
|
+
const result = await p.confirm({ message: `${packagesMissingPlural} required for this config: ${packagesMissing}. Do you want to install them?` });
|
|
140
151
|
if (result) await import("@antfu/install-pkg").then(async (i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
141
152
|
}
|
|
142
153
|
function isInEditorEnv() {
|
|
@@ -148,6 +159,114 @@ function isInGitHooksOrLintStaged() {
|
|
|
148
159
|
return Boolean(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
149
160
|
}
|
|
150
161
|
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/configs/adonisjs.ts
|
|
164
|
+
async function adonisjs(options = {}) {
|
|
165
|
+
const { overrides = {}, dirs = {} } = options;
|
|
166
|
+
await ensurePackages(["@adonisjs/eslint-plugin"]);
|
|
167
|
+
const pluginAdonisJS = await interopDefault(import("@adonisjs/eslint-plugin"));
|
|
168
|
+
dirs.root = dirs.root || ".";
|
|
169
|
+
const appPath = `${dirs.root}/app`;
|
|
170
|
+
dirs.controllers = dirs.controllers || `${appPath}/controllers`;
|
|
171
|
+
dirs.exceptions = dirs.exceptions || `${appPath}/exceptions`;
|
|
172
|
+
dirs.models = dirs.models || `${appPath}/models`;
|
|
173
|
+
dirs.mails = dirs.mails || `${appPath}/mails`;
|
|
174
|
+
dirs.services = dirs.services || `${appPath}/services`;
|
|
175
|
+
dirs.listeners = dirs.listeners || `${appPath}/listeners`;
|
|
176
|
+
dirs.events = dirs.events || `${appPath}/events`;
|
|
177
|
+
dirs.middleware = dirs.middleware || `${appPath}/middleware`;
|
|
178
|
+
dirs.validators = dirs.validators || `${appPath}/validators`;
|
|
179
|
+
dirs.policies = dirs.policies || `${appPath}/policies`;
|
|
180
|
+
dirs.abilities = dirs.abilities || `${appPath}/abilities`;
|
|
181
|
+
dirs.providers = dirs.providers || `${dirs.root}/providers`;
|
|
182
|
+
dirs.database = dirs.database || `${dirs.root}/database`;
|
|
183
|
+
dirs.bin = dirs.bin || `${dirs.root}/bin`;
|
|
184
|
+
dirs.start = dirs.start || `${dirs.root}/start`;
|
|
185
|
+
dirs.tests = dirs.tests || `${dirs.root}/tests`;
|
|
186
|
+
dirs.config = dirs.config || `${dirs.root}/config`;
|
|
187
|
+
dirs.commands = dirs.commands || `${dirs.root}/commands`;
|
|
188
|
+
const nestedGlobPattern = `**/*.${GLOB_SRC_EXT}`;
|
|
189
|
+
const fileRoutes = [...Object.values(dirs).map((dir) => join(dir, nestedGlobPattern)), `${dirs.root}/ace.js`];
|
|
190
|
+
const commonRulesSet = {
|
|
191
|
+
"@typescript-eslint/require-await": "off",
|
|
192
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
193
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
194
|
+
"@typescript-eslint/no-floating-promises": "off",
|
|
195
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
196
|
+
"unicorn/no-anonymous-default-export": "off"
|
|
197
|
+
};
|
|
198
|
+
return [
|
|
199
|
+
{
|
|
200
|
+
name: "eienjs/adonisjs/rules",
|
|
201
|
+
plugins: { "@adonisjs": pluginAdonisJS },
|
|
202
|
+
rules: {
|
|
203
|
+
"@adonisjs/prefer-lazy-controller-import": "error",
|
|
204
|
+
"@adonisjs/prefer-lazy-listener-import": "error",
|
|
205
|
+
...overrides
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
files: fileRoutes,
|
|
210
|
+
name: "eienjs/adonisjs/disables",
|
|
211
|
+
rules: { "antfu/no-top-level-await": "off" }
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
files: [join(dirs.database, nestedGlobPattern)],
|
|
215
|
+
name: "eienjs/adonisjs/database-disables",
|
|
216
|
+
rules: { ...commonRulesSet }
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
files: [join(dirs.bin, nestedGlobPattern)],
|
|
220
|
+
name: "eienjs/adonisjs/bin-disables",
|
|
221
|
+
rules: {
|
|
222
|
+
...commonRulesSet,
|
|
223
|
+
"@typescript-eslint/no-misused-promises": "off"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
files: [join(dirs.commands, nestedGlobPattern)],
|
|
228
|
+
name: "eienjs/adonisjs/commands-disables",
|
|
229
|
+
rules: { ...commonRulesSet }
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
files: [join(dirs.middleware, nestedGlobPattern)],
|
|
233
|
+
name: "eienjs/adonisjs/middleware-disables",
|
|
234
|
+
rules: { ...commonRulesSet }
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
files: [join(dirs.exceptions, nestedGlobPattern)],
|
|
238
|
+
name: "eienjs/adonisjs/exceptions-disables",
|
|
239
|
+
rules: { ...commonRulesSet }
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
files: [join(dirs.controllers, nestedGlobPattern)],
|
|
243
|
+
name: "eienjs/adonisjs/controllers-disables",
|
|
244
|
+
rules: {
|
|
245
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
246
|
+
"@typescript-eslint/explicit-module-boundary-types": "off"
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
files: [join(dirs.config, nestedGlobPattern)],
|
|
251
|
+
name: "eienjs/adonisjs/config-disables",
|
|
252
|
+
rules: { "@typescript-eslint/consistent-type-definitions": "off" }
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
files: [join(dirs.providers, nestedGlobPattern)],
|
|
256
|
+
name: "eienjs/adonisjs/providers-disables",
|
|
257
|
+
rules: { "@typescript-eslint/consistent-type-definitions": "off" }
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
files: [join(dirs.tests, nestedGlobPattern)],
|
|
261
|
+
name: "eienjs/adonisjs/tests-disables",
|
|
262
|
+
rules: {
|
|
263
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
264
|
+
"@typescript-eslint/explicit-module-boundary-types": "off"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
|
|
151
270
|
//#endregion
|
|
152
271
|
//#region src/configs/astro.ts
|
|
153
272
|
async function astro(options = {}) {
|
|
@@ -234,6 +353,15 @@ async function disables() {
|
|
|
234
353
|
"@typescript-eslint/explicit-function-return-type": "off"
|
|
235
354
|
}
|
|
236
355
|
},
|
|
356
|
+
{
|
|
357
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
358
|
+
name: "eienjs/disables/cli",
|
|
359
|
+
rules: {
|
|
360
|
+
"antfu/no-top-level-await": "off",
|
|
361
|
+
"no-console": "off",
|
|
362
|
+
"unicorn/no-process-exit": "off"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
237
365
|
{
|
|
238
366
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
239
367
|
name: "eienjs/disables/bin",
|
|
@@ -256,11 +384,6 @@ async function disables() {
|
|
|
256
384
|
name: "eienjs/disables/cjs",
|
|
257
385
|
rules: { "@typescript-eslint/no-require-imports": "off" }
|
|
258
386
|
},
|
|
259
|
-
{
|
|
260
|
-
files: [GLOB_MARKDOWN],
|
|
261
|
-
name: "eienjs/disables/markdown",
|
|
262
|
-
rules: { "unicorn/filename-case": "off" }
|
|
263
|
-
},
|
|
264
387
|
{
|
|
265
388
|
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
266
389
|
name: "eienjs/disables/config-files",
|
|
@@ -277,8 +400,7 @@ async function disables() {
|
|
|
277
400
|
//#region src/configs/stylistic.ts
|
|
278
401
|
const StylisticConfigDefaults = {
|
|
279
402
|
indent: 2,
|
|
280
|
-
quotes: "single"
|
|
281
|
-
maxLineLength: 120
|
|
403
|
+
quotes: "single"
|
|
282
404
|
};
|
|
283
405
|
async function stylistic(options = {}) {
|
|
284
406
|
const { indent, overrides = {}, quotes, maxLineLength = 120 } = {
|
|
@@ -301,11 +423,15 @@ async function stylistic(options = {}) {
|
|
|
301
423
|
...config.rules,
|
|
302
424
|
"antfu/consistent-chaining": "error",
|
|
303
425
|
"antfu/consistent-list-newline": "error",
|
|
304
|
-
"
|
|
426
|
+
"@stylistic/arrow-parens": ["error", "always"],
|
|
427
|
+
"@stylistic/brace-style": [
|
|
428
|
+
"error",
|
|
429
|
+
"1tbs",
|
|
430
|
+
{ allowSingleLine: true }
|
|
431
|
+
],
|
|
305
432
|
"@stylistic/max-len": ["error", {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
"ignoreComments": true
|
|
433
|
+
code: maxLineLength,
|
|
434
|
+
ignoreComments: true
|
|
309
435
|
}],
|
|
310
436
|
"@stylistic/padding-line-between-statements": [
|
|
311
437
|
"error",
|
|
@@ -325,6 +451,11 @@ async function stylistic(options = {}) {
|
|
|
325
451
|
before: false
|
|
326
452
|
}],
|
|
327
453
|
"@stylistic/quote-props": ["error", "consistent"],
|
|
454
|
+
"@stylistic/quotes": [
|
|
455
|
+
"error",
|
|
456
|
+
quotes,
|
|
457
|
+
{ avoidEscape: true }
|
|
458
|
+
],
|
|
328
459
|
"@stylistic/semi": "error",
|
|
329
460
|
"@stylistic/comma-spacing": "error",
|
|
330
461
|
"@stylistic/yield-star-spacing": ["error", {
|
|
@@ -541,6 +672,7 @@ async function javascript(options = {}) {
|
|
|
541
672
|
}],
|
|
542
673
|
"block-scoped-var": "error",
|
|
543
674
|
"constructor-super": "error",
|
|
675
|
+
"curly": "error",
|
|
544
676
|
"default-case-last": "error",
|
|
545
677
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
546
678
|
"eqeqeq": ["error", "smart"],
|
|
@@ -688,7 +820,6 @@ async function javascript(options = {}) {
|
|
|
688
820
|
"no-sequences": ["error", { allowInParentheses: false }],
|
|
689
821
|
"no-shadow-restricted-names": "error",
|
|
690
822
|
"no-sparse-arrays": "error",
|
|
691
|
-
"no-template-curly-in-string": "error",
|
|
692
823
|
"no-this-before-super": "error",
|
|
693
824
|
"no-throw-literal": "error",
|
|
694
825
|
"no-undef": "error",
|
|
@@ -926,6 +1057,7 @@ async function markdown(options = {}) {
|
|
|
926
1057
|
"no-unused-expressions": "off",
|
|
927
1058
|
"no-unused-labels": "off",
|
|
928
1059
|
"no-unused-vars": "off",
|
|
1060
|
+
"unicode-bom": "off",
|
|
929
1061
|
"n/prefer-global/process": "off",
|
|
930
1062
|
"@stylistic/comma-dangle": "off",
|
|
931
1063
|
"@stylistic/eol-last": "off",
|
|
@@ -939,9 +1071,9 @@ async function markdown(options = {}) {
|
|
|
939
1071
|
"@typescript-eslint/no-unused-expressions": "off",
|
|
940
1072
|
"@typescript-eslint/no-unused-vars": "off",
|
|
941
1073
|
"@typescript-eslint/no-use-before-define": "off",
|
|
942
|
-
"unicode-bom": "off",
|
|
943
1074
|
"unused-imports/no-unused-imports": "off",
|
|
944
1075
|
"unused-imports/no-unused-vars": "off",
|
|
1076
|
+
"unicorn/filename-case": "off",
|
|
945
1077
|
...overrides
|
|
946
1078
|
}
|
|
947
1079
|
}
|
|
@@ -1468,8 +1600,7 @@ async function typescript(options = {}) {
|
|
|
1468
1600
|
"@typescript-eslint/restrict-plus-operands": "error",
|
|
1469
1601
|
"@typescript-eslint/restrict-template-expressions": "error",
|
|
1470
1602
|
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
1471
|
-
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }]
|
|
1472
|
-
"@typescript-eslint/unbound-method": "error"
|
|
1603
|
+
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }]
|
|
1473
1604
|
};
|
|
1474
1605
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1475
1606
|
function makeParser(typeAware, files$1, ignores$1) {
|
|
@@ -1591,6 +1722,7 @@ async function unicorn(options = {}) {
|
|
|
1591
1722
|
"unicorn/expiring-todo-comments": "off",
|
|
1592
1723
|
"unicorn/no-array-reduce": "off",
|
|
1593
1724
|
"unicorn/prefer-export-from": "off",
|
|
1725
|
+
"unicorn/prefer-top-level-await": "off",
|
|
1594
1726
|
...overrides
|
|
1595
1727
|
}
|
|
1596
1728
|
}];
|
|
@@ -1659,16 +1791,18 @@ async function vue(options = {}) {
|
|
|
1659
1791
|
...acc,
|
|
1660
1792
|
...c
|
|
1661
1793
|
}), {}),
|
|
1662
|
-
"
|
|
1663
|
-
"n/prefer-global/process": "off",
|
|
1664
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1665
|
-
"@typescript-eslint/naming-convention": "off",
|
|
1794
|
+
"vue/block-lang": ["error", { script: { lang: "ts" } }],
|
|
1666
1795
|
"vue/block-order": ["error", { order: [
|
|
1667
1796
|
"script",
|
|
1668
1797
|
"template",
|
|
1669
1798
|
"style"
|
|
1670
1799
|
] }],
|
|
1671
|
-
"vue/component-
|
|
1800
|
+
"vue/component-api-style": ["error", ["script-setup"]],
|
|
1801
|
+
"vue/component-name-in-template-casing": [
|
|
1802
|
+
"error",
|
|
1803
|
+
"PascalCase",
|
|
1804
|
+
{ registeredComponentsOnly: true }
|
|
1805
|
+
],
|
|
1672
1806
|
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
1673
1807
|
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
1674
1808
|
"vue/define-macros-order": ["error", { order: [
|
|
@@ -1686,6 +1820,7 @@ async function vue(options = {}) {
|
|
|
1686
1820
|
"vue/max-attributes-per-line": "off",
|
|
1687
1821
|
"vue/multi-word-component-names": "off",
|
|
1688
1822
|
"vue/no-dupe-keys": "off",
|
|
1823
|
+
"vue/no-empty-component-block": "error",
|
|
1689
1824
|
"vue/no-empty-pattern": "error",
|
|
1690
1825
|
"vue/no-irregular-whitespace": "error",
|
|
1691
1826
|
"vue/no-loss-of-precision": "error",
|
|
@@ -1703,8 +1838,8 @@ async function vue(options = {}) {
|
|
|
1703
1838
|
"vue/no-setup-props-reactivity-loss": "off",
|
|
1704
1839
|
"vue/no-sparse-arrays": "error",
|
|
1705
1840
|
"vue/no-template-target-blank": "error",
|
|
1706
|
-
"vue/no-unused-refs": "error",
|
|
1707
1841
|
"vue/no-unused-properties": "error",
|
|
1842
|
+
"vue/no-unused-refs": "error",
|
|
1708
1843
|
"vue/no-use-v-else-with-v-for": "error",
|
|
1709
1844
|
"vue/no-useless-mustaches": "error",
|
|
1710
1845
|
"vue/no-useless-v-bind": "error",
|
|
@@ -1719,14 +1854,15 @@ async function vue(options = {}) {
|
|
|
1719
1854
|
],
|
|
1720
1855
|
"vue/prefer-separate-static-class": "error",
|
|
1721
1856
|
"vue/prefer-template": "error",
|
|
1857
|
+
"vue/prefer-true-attribute-shorthand": "error",
|
|
1722
1858
|
"vue/prop-name-casing": ["error", "camelCase"],
|
|
1723
|
-
"vue/require-
|
|
1724
|
-
"vue/require-prop-types": "off",
|
|
1859
|
+
"vue/require-typed-ref": "error",
|
|
1725
1860
|
"vue/space-infix-ops": "error",
|
|
1726
1861
|
"vue/space-unary-ops": ["error", {
|
|
1727
1862
|
nonwords: false,
|
|
1728
1863
|
words: true
|
|
1729
1864
|
}],
|
|
1865
|
+
"vue/static-class-names-order": "off",
|
|
1730
1866
|
...stylistic$1 ? {
|
|
1731
1867
|
"vue/array-bracket-spacing": ["error", "never"],
|
|
1732
1868
|
"vue/arrow-spacing": ["error", {
|
|
@@ -1740,7 +1876,7 @@ async function vue(options = {}) {
|
|
|
1740
1876
|
}],
|
|
1741
1877
|
"vue/brace-style": [
|
|
1742
1878
|
"error",
|
|
1743
|
-
"
|
|
1879
|
+
"1tbs",
|
|
1744
1880
|
{ allowSingleLine: true }
|
|
1745
1881
|
],
|
|
1746
1882
|
"vue/comma-dangle": ["error", "always-multiline"],
|
|
@@ -1772,6 +1908,11 @@ async function vue(options = {}) {
|
|
|
1772
1908
|
"vue/template-curly-spacing": "error"
|
|
1773
1909
|
} : {},
|
|
1774
1910
|
"unicorn/filename-case": "off",
|
|
1911
|
+
"antfu/no-top-level-await": "off",
|
|
1912
|
+
"n/prefer-global/process": "off",
|
|
1913
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1914
|
+
"@typescript-eslint/naming-convention": "off",
|
|
1915
|
+
"@stylistic/max-len": "off",
|
|
1775
1916
|
...overrides
|
|
1776
1917
|
}
|
|
1777
1918
|
}];
|
|
@@ -1858,4 +1999,4 @@ async function yaml(options = {}) {
|
|
|
1858
1999
|
}
|
|
1859
2000
|
|
|
1860
2001
|
//#endregion
|
|
1861
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, 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, StylisticConfigDefaults, astro, combine, command, comments, disables, ensurePackages, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, vue, yaml };
|
|
2002
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, 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, StylisticConfigDefaults, adonisjs, astro, combine, command, comments, disables, ensurePackages, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, vue, yaml };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Awaitable, ConfigNames, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem } from "./types-
|
|
1
|
+
import { Awaitable, ConfigNames, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem } from "./types-B-BVuwa4.js";
|
|
2
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import { Linter } from "eslint";
|
|
4
4
|
|
|
@@ -82,4 +82,4 @@ declare function ensurePackages(packages: (string | undefined)[]): Promise<void>
|
|
|
82
82
|
declare function isInEditorEnv(): boolean;
|
|
83
83
|
declare function isInGitHooksOrLintStaged(): boolean;
|
|
84
84
|
//#endregion
|
|
85
|
-
export { Awaitable, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, 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, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, ResolvedOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
|
85
|
+
export { Awaitable, ConfigNames, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, 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, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, ResolvedOptions, Rules, StylisticConfig, TypedFlatConfigItem, combine, eienjs as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, 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, astro, combine, command, comments, disables, ensurePackages, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, vue, yaml } from "./configs-
|
|
1
|
+
import { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, 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, adonisjs, astro, combine, command, comments, disables, ensurePackages, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, parserPlain, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, vue, yaml } from "./configs-BA3UU5JJ.js";
|
|
2
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import { isPackageExists } from "local-pkg";
|
|
4
4
|
|
|
@@ -24,7 +24,7 @@ const defaultPluginRenaming = {
|
|
|
24
24
|
"yml": "yaml"
|
|
25
25
|
};
|
|
26
26
|
function eienjs(options = {}) {
|
|
27
|
-
const { astro: enableAstro = false, componentExts = [], gitignore: enableGitignore = true, imports: enableImports = true, pnpm: enableCatalogs = false, regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
27
|
+
const { astro: enableAstro = false, componentExts = [], gitignore: enableGitignore = true, imports: enableImports = true, pnpm: enableCatalogs = false, regexp: enableRegexp = true, typescript: enableTypeScript = isPackageExists("typescript"), unicorn: enableUnicorn = true, vue: enableVue = VuePackages.some((i) => isPackageExists(i)), adonisjs: enableAdonisjs = false } = options;
|
|
28
28
|
let { isInEditor } = options;
|
|
29
29
|
if (isInEditor == null) {
|
|
30
30
|
isInEditor = isInEditorEnv();
|
|
@@ -75,6 +75,10 @@ function eienjs(options = {}) {
|
|
|
75
75
|
overrides: getOverrides(options, "astro"),
|
|
76
76
|
stylistic: stylisticOptions
|
|
77
77
|
}));
|
|
78
|
+
if (enableAdonisjs) configs.push(adonisjs({
|
|
79
|
+
...resolveSubOptions(options, "adonisjs"),
|
|
80
|
+
overrides: getOverrides(options, "adonisjs")
|
|
81
|
+
}));
|
|
78
82
|
if (options.jsonc ?? true) configs.push(jsonc({
|
|
79
83
|
overrides: getOverrides(options, "jsonc"),
|
|
80
84
|
stylistic: stylisticOptions
|
|
@@ -94,7 +98,11 @@ function eienjs(options = {}) {
|
|
|
94
98
|
}));
|
|
95
99
|
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
96
100
|
configs.push(disables());
|
|
97
|
-
if ("files" in options) throw new Error(
|
|
101
|
+
if ("files" in options) throw new Error([
|
|
102
|
+
"[@eienjs/eslint-config] ",
|
|
103
|
+
"The first argument should not contain the \"files\" property as the options are supposed to be global. ",
|
|
104
|
+
"Place it in the second or later config instead."
|
|
105
|
+
].join(""));
|
|
98
106
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
99
107
|
if (key in options) acc[key] = options[key];
|
|
100
108
|
return acc;
|
|
@@ -106,7 +114,7 @@ function eienjs(options = {}) {
|
|
|
106
114
|
"unused-imports/no-unused-imports",
|
|
107
115
|
"test/no-only-tests",
|
|
108
116
|
"prefer-const"
|
|
109
|
-
], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
117
|
+
], { builtinRules: async () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
110
118
|
return composer;
|
|
111
119
|
}
|
|
112
120
|
function resolveSubOptions(options, key) {
|
|
@@ -6,6 +6,16 @@ import { Linter } from "eslint";
|
|
|
6
6
|
|
|
7
7
|
//#region src/typegen.d.ts
|
|
8
8
|
interface RuleOptions {
|
|
9
|
+
/**
|
|
10
|
+
* (Needed for HMR) Prefer lazy controller import over standard import
|
|
11
|
+
* @see https://github.com/adonisjs/eslint-plugin-adonisjs#prefer-lazy-controller-import
|
|
12
|
+
*/
|
|
13
|
+
'@adonisjs/prefer-lazy-controller-import'?: Linter.RuleEntry<[]>;
|
|
14
|
+
/**
|
|
15
|
+
* (Needed for HMR) Prefer lazy listener import over standard import
|
|
16
|
+
* @see https://github.com/adonisjs/eslint-plugin-adonisjs#prefer-lazy-listener-import
|
|
17
|
+
*/
|
|
18
|
+
'@adonisjs/prefer-lazy-listener-import'?: Linter.RuleEntry<[]>;
|
|
9
19
|
/**
|
|
10
20
|
* require a `eslint-enable` comment for every `eslint-disable` comment
|
|
11
21
|
* @see https://eslint-community.github.io/eslint-plugin-eslint-comments/rules/disable-enable-pair.html
|
|
@@ -15354,7 +15364,7 @@ type Yoda = [] | [("always" | "never")] | [("always" | "never"), {
|
|
|
15354
15364
|
onlyEquality?: boolean;
|
|
15355
15365
|
}];
|
|
15356
15366
|
// Names of all the configs
|
|
15357
|
-
type ConfigNames = 'eienjs/astro/setup' | 'eienjs/astro/rules' | 'eienjs/eslint-comments/rules' | 'eienjs/formatter/setup' | 'eienjs/imports/rules' | 'eienjs/javascript/setup' | 'eienjs/javascript/rules' | 'eienjs/jsdoc/rules' | 'eienjs/jsonc/setup' | 'eienjs/jsonc/rules' | 'eienjs/markdown/setup' | 'eienjs/markdown/processor' | 'eienjs/markdown/parser' | 'eienjs/markdown/disables' | 'eienjs/node/rules' | 'eienjs/perfectionist/setup' | 'eienjs/sort/package-json' | 'eienjs/stylistic/rules' | 'eienjs/test/setup' | 'eienjs/test/rules' | 'eienjs/toml/setup' | 'eienjs/toml/rules' | 'eienjs/regexp/rules' | 'eienjs/typescript/setup' | 'eienjs/typescript/parser' | 'eienjs/typescript/rules' | 'eienjs/unicorn/rules' | 'eienjs/vue/setup' | 'eienjs/vue/rules' | 'eienjs/yaml/setup' | 'eienjs/yaml/rules' | 'eienjs/yaml/pnpm-workspace';
|
|
15367
|
+
type ConfigNames = 'eienjs/adonisjs/rules' | 'eienjs/adonisjs/disables' | 'eienjs/adonisjs/database-disables' | 'eienjs/adonisjs/bin-disables' | 'eienjs/adonisjs/commands-disables' | 'eienjs/adonisjs/middleware-disables' | 'eienjs/adonisjs/exceptions-disables' | 'eienjs/adonisjs/controllers-disables' | 'eienjs/adonisjs/config-disables' | 'eienjs/adonisjs/providers-disables' | 'eienjs/adonisjs/tests-disables' | 'eienjs/astro/setup' | 'eienjs/astro/rules' | 'eienjs/eslint-comments/rules' | 'eienjs/formatter/setup' | 'eienjs/imports/rules' | 'eienjs/javascript/setup' | 'eienjs/javascript/rules' | 'eienjs/jsdoc/rules' | 'eienjs/jsonc/setup' | 'eienjs/jsonc/rules' | 'eienjs/markdown/setup' | 'eienjs/markdown/processor' | 'eienjs/markdown/parser' | 'eienjs/markdown/disables' | 'eienjs/node/rules' | 'eienjs/perfectionist/setup' | 'eienjs/sort/package-json' | 'eienjs/stylistic/rules' | 'eienjs/test/setup' | 'eienjs/test/rules' | 'eienjs/toml/setup' | 'eienjs/toml/rules' | 'eienjs/regexp/rules' | 'eienjs/typescript/setup' | 'eienjs/typescript/parser' | 'eienjs/typescript/rules' | 'eienjs/unicorn/rules' | 'eienjs/vue/setup' | 'eienjs/vue/rules' | 'eienjs/yaml/setup' | 'eienjs/yaml/rules' | 'eienjs/yaml/pnpm-workspace';
|
|
15358
15368
|
//#endregion
|
|
15359
15369
|
//#region src/vendored/prettier_types.d.ts
|
|
15360
15370
|
/**
|
|
@@ -15498,11 +15508,31 @@ type TypedFlatConfigItem = Omit<Linter.Config, 'plugins' | 'rules'> & {
|
|
|
15498
15508
|
*/
|
|
15499
15509
|
rules?: Rules;
|
|
15500
15510
|
};
|
|
15501
|
-
interface
|
|
15502
|
-
/**
|
|
15503
|
-
* Override the `
|
|
15504
|
-
*/
|
|
15505
|
-
|
|
15511
|
+
interface OptionsAdonisJS extends OptionsOverrides {
|
|
15512
|
+
/**
|
|
15513
|
+
* Override the `dirs` option to provide custom directories of adonisjs app.
|
|
15514
|
+
*/
|
|
15515
|
+
dirs?: {
|
|
15516
|
+
root?: string;
|
|
15517
|
+
bin?: string;
|
|
15518
|
+
controllers?: string;
|
|
15519
|
+
exceptions?: string;
|
|
15520
|
+
models?: string;
|
|
15521
|
+
mails?: string;
|
|
15522
|
+
services?: string;
|
|
15523
|
+
listeners?: string;
|
|
15524
|
+
events?: string;
|
|
15525
|
+
middleware?: string;
|
|
15526
|
+
validators?: string;
|
|
15527
|
+
providers?: string;
|
|
15528
|
+
policies?: string;
|
|
15529
|
+
abilities?: string;
|
|
15530
|
+
database?: string;
|
|
15531
|
+
start?: string;
|
|
15532
|
+
tests?: string;
|
|
15533
|
+
config?: string;
|
|
15534
|
+
commands?: string;
|
|
15535
|
+
};
|
|
15506
15536
|
}
|
|
15507
15537
|
interface OptionsVue extends OptionsOverrides {
|
|
15508
15538
|
/**
|
|
@@ -15608,6 +15638,12 @@ interface StylisticConfig extends Pick<StylisticCustomizeOptions, 'indent' | 'qu
|
|
|
15608
15638
|
interface OptionsOverrides {
|
|
15609
15639
|
overrides?: TypedFlatConfigItem['rules'];
|
|
15610
15640
|
}
|
|
15641
|
+
interface OptionsFiles {
|
|
15642
|
+
/**
|
|
15643
|
+
* Override the `files` option to provide custom globs.
|
|
15644
|
+
*/
|
|
15645
|
+
files?: string[];
|
|
15646
|
+
}
|
|
15611
15647
|
interface OptionsRegExp {
|
|
15612
15648
|
/**
|
|
15613
15649
|
* Override rulelevels
|
|
@@ -15742,6 +15778,15 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
15742
15778
|
* @default auto-detect based on the process.env
|
|
15743
15779
|
*/
|
|
15744
15780
|
isInEditor?: boolean;
|
|
15781
|
+
/**
|
|
15782
|
+
* Enable AdonisJS support.
|
|
15783
|
+
*
|
|
15784
|
+
* Requires installing:
|
|
15785
|
+
* - `@adonisjs/eslint-plugin`
|
|
15786
|
+
*
|
|
15787
|
+
* @default false
|
|
15788
|
+
*/
|
|
15789
|
+
adonisjs?: boolean | OptionsAdonisJS;
|
|
15745
15790
|
}
|
|
15746
15791
|
//#endregion
|
|
15747
|
-
export { Awaitable, type ConfigNames, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem };
|
|
15792
|
+
export { Awaitable, type ConfigNames, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eienjs/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "EienJS ESLint Config",
|
|
6
6
|
"author": "Fernando Isidro <luffynando@gmail.com> (https://github.com/luffynando/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"url": "https://github.com/eienjs/eslint-config/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
-
"eslint-config"
|
|
17
|
+
"eslint-config",
|
|
18
|
+
"adonisjs",
|
|
19
|
+
"astro"
|
|
18
20
|
],
|
|
19
21
|
"exports": {
|
|
20
22
|
".": "./dist/index.js",
|
|
@@ -22,13 +24,16 @@
|
|
|
22
24
|
},
|
|
23
25
|
"main": "./dist/index.js",
|
|
24
26
|
"types": "./dist/index.d.ts",
|
|
27
|
+
"bin": "./bin/index.js",
|
|
25
28
|
"files": [
|
|
29
|
+
"bin",
|
|
26
30
|
"dist"
|
|
27
31
|
],
|
|
28
32
|
"engines": {
|
|
29
33
|
"node": ">=20.11"
|
|
30
34
|
},
|
|
31
35
|
"peerDependencies": {
|
|
36
|
+
"@adonisjs/eslint-plugin": "^2.0.0",
|
|
32
37
|
"@prettier/plugin-xml": "^3.4.2",
|
|
33
38
|
"astro-eslint-parser": "^1.2.2",
|
|
34
39
|
"eslint": "^9.32.0",
|
|
@@ -37,6 +42,9 @@
|
|
|
37
42
|
"prettier-plugin-astro": "^0.14.1"
|
|
38
43
|
},
|
|
39
44
|
"peerDependenciesMeta": {
|
|
45
|
+
"@adonisjs/eslint-plugin": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
40
48
|
"@prettier/plugin-xml": {
|
|
41
49
|
"optional": true
|
|
42
50
|
},
|
|
@@ -62,13 +70,15 @@
|
|
|
62
70
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
63
71
|
"@typescript-eslint/parser": "^8.38.0",
|
|
64
72
|
"@vitest/eslint-plugin": "^1.3.4",
|
|
73
|
+
"ansis": "^4.1.0",
|
|
74
|
+
"cac": "^6.7.14",
|
|
65
75
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
66
76
|
"eslint-flat-config-utils": "^2.1.1",
|
|
67
77
|
"eslint-merge-processors": "^2.0.0",
|
|
68
78
|
"eslint-plugin-antfu": "^3.1.1",
|
|
69
79
|
"eslint-plugin-command": "^3.3.1",
|
|
70
80
|
"eslint-plugin-import-lite": "^0.3.0",
|
|
71
|
-
"eslint-plugin-jsdoc": "^52.0.
|
|
81
|
+
"eslint-plugin-jsdoc": "^52.0.2",
|
|
72
82
|
"eslint-plugin-jsonc": "^2.20.1",
|
|
73
83
|
"eslint-plugin-n": "^17.21.3",
|
|
74
84
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
@@ -84,11 +94,14 @@
|
|
|
84
94
|
"globals": "^16.3.0",
|
|
85
95
|
"jsonc-eslint-parser": "^2.4.0",
|
|
86
96
|
"local-pkg": "^1.1.1",
|
|
97
|
+
"parse-gitignore": "^2.0.0",
|
|
98
|
+
"pathe": "^2.0.3",
|
|
87
99
|
"toml-eslint-parser": "^0.10.0",
|
|
88
100
|
"vue-eslint-parser": "^10.2.0",
|
|
89
101
|
"yaml-eslint-parser": "^1.3.0"
|
|
90
102
|
},
|
|
91
103
|
"devDependencies": {
|
|
104
|
+
"@adonisjs/eslint-plugin": "^2.0.0",
|
|
92
105
|
"@commitlint/cli": "^19.8.1",
|
|
93
106
|
"@commitlint/config-conventional": "^19.8.1",
|
|
94
107
|
"@eslint/config-inspector": "^1.1.0",
|
|
@@ -103,9 +116,9 @@
|
|
|
103
116
|
"husky": "^9.1.7",
|
|
104
117
|
"np": "^10.2.0",
|
|
105
118
|
"prettier-plugin-astro": "^0.14.1",
|
|
106
|
-
"tsdown": "^0.13.
|
|
119
|
+
"tsdown": "^0.13.1",
|
|
107
120
|
"tsx": "^4.20.3",
|
|
108
|
-
"typescript": "
|
|
121
|
+
"typescript": ">=4.8.4 <5.9.0"
|
|
109
122
|
},
|
|
110
123
|
"resolutions": {
|
|
111
124
|
"eslint": "catalog:peer"
|
|
@@ -136,7 +149,7 @@
|
|
|
136
149
|
"dev": "npx @eslint/config-inspector --config eslint.config.ts",
|
|
137
150
|
"build:inspector": "pnpm build && npx @eslint/config-inspector build",
|
|
138
151
|
"watch": "tsdown --watch",
|
|
139
|
-
"gen": "tsx scripts/typegen.ts",
|
|
152
|
+
"gen": "tsx scripts/typegen.ts && tsx scripts/versiongen.ts",
|
|
140
153
|
"changelog": "auto-changelog -p && git add CHANGELOG.md",
|
|
141
154
|
"release": "np",
|
|
142
155
|
"version": "pnpm build && pnpm changelog",
|