@eienjs/eslint-config 0.2.0 → 0.4.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 +293 -0
- package/dist/configs/index.d.ts +5 -2
- package/dist/configs/index.js +2 -2
- package/dist/{configs-ChITrcNN.js → configs-CIPkS6TK.js} +158 -18
- package/dist/index.d.ts +3 -2
- package/dist/index.js +18 -9
- package/dist/{types-CBNl8Ios.d.ts → types-Cd5vIRtv.d.ts} +82 -2
- package/package.json +17 -5
package/bin/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,293 @@
|
|
|
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.4.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
|
+
label: c.greenBright("Nuxt"),
|
|
66
|
+
value: "nuxt"
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
const frameworks = frameworkOptions.map(({ value }) => value);
|
|
70
|
+
const extraOptions = [{
|
|
71
|
+
hint: "Use external formatters (Prettier) to format files that ESLint cannot handle yet (.css, .html, etc)",
|
|
72
|
+
label: c.red("Formatter"),
|
|
73
|
+
value: "formatter"
|
|
74
|
+
}];
|
|
75
|
+
const extra = extraOptions.map(({ value }) => value);
|
|
76
|
+
const dependenciesMap = {
|
|
77
|
+
astro: ["eslint-plugin-astro", "astro-eslint-parser"],
|
|
78
|
+
formatter: ["eslint-plugin-format"],
|
|
79
|
+
formatterAstro: ["prettier-plugin-astro"],
|
|
80
|
+
vue: [],
|
|
81
|
+
adonisjs: ["@adonisjs/eslint-plugin"],
|
|
82
|
+
nuxt: ["@nuxt/eslint-plugin"]
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/cli/utils.ts
|
|
87
|
+
function isGitClean() {
|
|
88
|
+
try {
|
|
89
|
+
execSync("git diff-index --quiet HEAD --");
|
|
90
|
+
return true;
|
|
91
|
+
} catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function getEslintConfigContent(mainConfig) {
|
|
96
|
+
return `
|
|
97
|
+
import eienjs from '@eienjs/eslint-config';
|
|
98
|
+
|
|
99
|
+
export default eienjs({
|
|
100
|
+
${mainConfig}
|
|
101
|
+
});
|
|
102
|
+
`.trimStart();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/cli/stages/update_eslint_files.ts
|
|
107
|
+
async function updateEslintFiles(result) {
|
|
108
|
+
const cwd = process.cwd();
|
|
109
|
+
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
110
|
+
const pathPackageJSON = path.join(cwd, "package.json");
|
|
111
|
+
const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
|
|
112
|
+
const pkg = JSON.parse(pkgContent);
|
|
113
|
+
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
114
|
+
const pathFlatConfig = path.join(cwd, configFileName);
|
|
115
|
+
const eslintIgnores = [];
|
|
116
|
+
if (fs.existsSync(pathESLintIgnore)) {
|
|
117
|
+
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
118
|
+
const content = await fsp.readFile(pathESLintIgnore, "utf8");
|
|
119
|
+
const parsed = parse(content);
|
|
120
|
+
const globs = parsed.globs();
|
|
121
|
+
for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
|
122
|
+
else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
123
|
+
}
|
|
124
|
+
const configLines = [];
|
|
125
|
+
if (eslintIgnores.length > 0) configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
126
|
+
if (result.extra.includes("formatter")) configLines.push("formatters: true,");
|
|
127
|
+
for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
|
|
128
|
+
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
129
|
+
const eslintConfigContent = getEslintConfigContent(mainConfig);
|
|
130
|
+
await fsp.writeFile(pathFlatConfig, eslintConfigContent);
|
|
131
|
+
p.log.success(c.green`Created ${configFileName}`);
|
|
132
|
+
const files = fs.readdirSync(cwd);
|
|
133
|
+
const legacyConfig = [];
|
|
134
|
+
for (const file of files) if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) legacyConfig.push(file);
|
|
135
|
+
if (legacyConfig.length > 0) p.note(c.dim(legacyConfig.join(", ")), "You can now remove those files manually");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/cli/constants_generated.ts
|
|
140
|
+
const versionsMap = {
|
|
141
|
+
"@adonisjs/eslint-plugin": "^2.0.0",
|
|
142
|
+
"@nuxt/eslint-plugin": "^1.7.1",
|
|
143
|
+
"astro-eslint-parser": "^1.2.2",
|
|
144
|
+
"eslint": "^9.32.0",
|
|
145
|
+
"eslint-plugin-astro": "^1.3.1",
|
|
146
|
+
"eslint-plugin-format": "^1.0.1",
|
|
147
|
+
"prettier-plugin-astro": "^0.14.1"
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/cli/stages/update_package_json.ts
|
|
152
|
+
async function updatePackageJson(result) {
|
|
153
|
+
const cwd = process.cwd();
|
|
154
|
+
const pathPackageJSON = path.join(cwd, "package.json");
|
|
155
|
+
p.log.step(c.cyan`Bumping @eienjs/eslint-config to v${version}`);
|
|
156
|
+
const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
|
|
157
|
+
const pkg = JSON.parse(pkgContent);
|
|
158
|
+
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
159
|
+
pkg.devDependencies["@eienjs/eslint-config"] = `^${version}`;
|
|
160
|
+
pkg.devDependencies.eslint = pkg.devDependencies.eslint ?? versionsMap.eslint;
|
|
161
|
+
const addedPackages = [];
|
|
162
|
+
if (result.extra.length > 0) {
|
|
163
|
+
const extraPackages = result.extra;
|
|
164
|
+
for (const item of extraPackages) switch (item) {
|
|
165
|
+
case "formatter":
|
|
166
|
+
for (const f of [...dependenciesMap.formatter, ...result.frameworks.includes("astro") ? dependenciesMap.formatterAstro : []]) {
|
|
167
|
+
if (!f) continue;
|
|
168
|
+
pkg.devDependencies[f] = versionsMap[f];
|
|
169
|
+
addedPackages.push(f);
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
for (const framework of result.frameworks) {
|
|
175
|
+
const deps = dependenciesMap[framework];
|
|
176
|
+
if (deps) for (const f of deps) {
|
|
177
|
+
pkg.devDependencies[f] = versionsMap[f];
|
|
178
|
+
addedPackages.push(f);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (addedPackages.length > 0) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
182
|
+
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
183
|
+
p.log.success(c.green`Changes wrote to package.json`);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/cli/stages/update_vscode_settings.ts
|
|
188
|
+
async function updateVscodeSettings(result) {
|
|
189
|
+
const cwd = process.cwd();
|
|
190
|
+
if (!result.updateVscodeSettings) return;
|
|
191
|
+
const dotVscodePath = path.join(cwd, ".vscode");
|
|
192
|
+
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
193
|
+
if (!fs.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
|
|
194
|
+
if (fs.existsSync(settingsPath)) {
|
|
195
|
+
let settingsContent = await fsp.readFile(settingsPath, "utf8");
|
|
196
|
+
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
197
|
+
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
198
|
+
settingsContent += `${vscodeSettingsString}}\n`;
|
|
199
|
+
await fsp.writeFile(settingsPath, settingsContent, "utf8");
|
|
200
|
+
p.log.success(green`Updated .vscode/settings.json`);
|
|
201
|
+
} else {
|
|
202
|
+
await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf8");
|
|
203
|
+
p.log.success(green`Created .vscode/settings.json`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/cli/run.ts
|
|
209
|
+
async function run(options = {}) {
|
|
210
|
+
const argSkipPrompt = Boolean(process.env.SKIP_PROMPT) || options.yes;
|
|
211
|
+
const argTemplate = options.frameworks?.map((m) => m?.trim()).filter(Boolean);
|
|
212
|
+
const argExtra = options.extra?.map((m) => m?.trim()).filter(Boolean);
|
|
213
|
+
if (fs.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
214
|
+
p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`);
|
|
215
|
+
return process.exit(1);
|
|
216
|
+
}
|
|
217
|
+
let result = {
|
|
218
|
+
extra: argExtra ?? [],
|
|
219
|
+
frameworks: argTemplate ?? [],
|
|
220
|
+
uncommittedConfirmed: false,
|
|
221
|
+
updateVscodeSettings: true
|
|
222
|
+
};
|
|
223
|
+
if (!argSkipPrompt) {
|
|
224
|
+
result = await p.group({
|
|
225
|
+
uncommittedConfirmed: async () => {
|
|
226
|
+
if (argSkipPrompt || isGitClean()) return true;
|
|
227
|
+
return p.confirm({
|
|
228
|
+
initialValue: false,
|
|
229
|
+
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
frameworks: async ({ results }) => {
|
|
233
|
+
const isArgTemplateValid = typeof argTemplate === "string" && Boolean(frameworks.includes(argTemplate));
|
|
234
|
+
if (!results.uncommittedConfirmed || isArgTemplateValid) return;
|
|
235
|
+
const message = !isArgTemplateValid && argTemplate ? `"${argTemplate.toString()}" isn't a valid template. Please choose from below: ` : "Select a framework:";
|
|
236
|
+
return p.multiselect({
|
|
237
|
+
message: c.reset(message),
|
|
238
|
+
options: frameworkOptions,
|
|
239
|
+
required: false
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
extra: async ({ results }) => {
|
|
243
|
+
const isArgExtraValid = argExtra?.length && argExtra.filter((element) => !extra.includes(element)).length === 0;
|
|
244
|
+
if (!results.uncommittedConfirmed || isArgExtraValid) return;
|
|
245
|
+
const message = !isArgExtraValid && argExtra ? `"${argExtra.toString()}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
|
|
246
|
+
return p.multiselect({
|
|
247
|
+
message: c.reset(message),
|
|
248
|
+
options: extraOptions,
|
|
249
|
+
required: false
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
updateVscodeSettings: async ({ results }) => {
|
|
253
|
+
if (!results.uncommittedConfirmed) return;
|
|
254
|
+
return p.confirm({
|
|
255
|
+
initialValue: true,
|
|
256
|
+
message: "Update .vscode/settings.json for better VS Code experience?"
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}, { onCancel: () => {
|
|
260
|
+
p.cancel("Operation cancelled.");
|
|
261
|
+
process.exit(0);
|
|
262
|
+
} });
|
|
263
|
+
if (!result.uncommittedConfirmed) return process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
await updatePackageJson(result);
|
|
266
|
+
await updateEslintFiles(result);
|
|
267
|
+
await updateVscodeSettings(result);
|
|
268
|
+
p.log.success(c.green`Setup completed`);
|
|
269
|
+
p.outro(`Now you can update the dependencies by run ${c.blue("pnpm install")} and run ${c.blue("eslint --fix")}\n`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/cli/index.ts
|
|
274
|
+
function header() {
|
|
275
|
+
console.log("\n");
|
|
276
|
+
p.intro(`${c.green`@eienjs/eslint-config `}${c.dim`v${version}`}`);
|
|
277
|
+
}
|
|
278
|
+
const cli = cac("@eienjs/eslint-config");
|
|
279
|
+
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) => {
|
|
280
|
+
header();
|
|
281
|
+
try {
|
|
282
|
+
await run(args);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
p.log.error(c.inverse.red(" Failed to migrate "));
|
|
285
|
+
p.log.error(c.red`✘ ${String(error)}`);
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
cli.help();
|
|
290
|
+
cli.version(version);
|
|
291
|
+
cli.parse();
|
|
292
|
+
|
|
293
|
+
//#endregion
|
package/dist/configs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OptionsAdonisJS, OptionsComponentExts, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsVue, StylisticConfig, TypedFlatConfigItem } from "../types-
|
|
1
|
+
import { OptionsAdonisJS, OptionsComponentExts, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsVue, StylisticConfig, TypedFlatConfigItem } from "../types-Cd5vIRtv.js";
|
|
2
2
|
|
|
3
3
|
//#region src/configs/adonisjs.d.ts
|
|
4
4
|
declare function adonisjs(options?: OptionsAdonisJS): Promise<TypedFlatConfigItem[]>;
|
|
@@ -39,6 +39,9 @@ declare function markdown(options?: OptionsFiles & OptionsComponentExts & Option
|
|
|
39
39
|
//#region src/configs/node.d.ts
|
|
40
40
|
declare function node(): Promise<TypedFlatConfigItem[]>;
|
|
41
41
|
//#endregion
|
|
42
|
+
//#region src/configs/nuxt.d.ts
|
|
43
|
+
declare function nuxt(options?: OptionsNuxt & OptionsStylistic): Promise<TypedFlatConfigItem[]>;
|
|
44
|
+
//#endregion
|
|
42
45
|
//#region src/configs/perfectionist.d.ts
|
|
43
46
|
/**
|
|
44
47
|
* Perfectionist plugin for props and items sorting.
|
|
@@ -90,4 +93,4 @@ declare function vue(options?: OptionsVue & OptionsHasTypeScript & OptionsOverri
|
|
|
90
93
|
//#region src/configs/yaml.d.ts
|
|
91
94
|
declare function yaml(options?: OptionsOverrides & OptionsStylistic & OptionsFiles): Promise<TypedFlatConfigItem[]>;
|
|
92
95
|
//#endregion
|
|
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 };
|
|
96
|
+
export { StylisticConfigDefaults, StylisticOptions, adonisjs, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, nuxt, 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, 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-
|
|
1
|
+
import { StylisticConfigDefaults, adonisjs, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, nuxt, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml } from "../configs-CIPkS6TK.js";
|
|
2
2
|
|
|
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 };
|
|
3
|
+
export { StylisticConfigDefaults, adonisjs, astro, command, comments, disables, formatters, ignores, imports, javascript, jsdoc, jsonc, markdown, node, nuxt, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml };
|
|
@@ -39,6 +39,7 @@ const GLOB_SVG = "**/*.svg";
|
|
|
39
39
|
const GLOB_HTML = "**/*.htm?(l)";
|
|
40
40
|
const GLOB_ASTRO = "**/*.astro";
|
|
41
41
|
const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
42
|
+
const GLOB_EXTS = "{js,ts,jsx,tsx,vue}";
|
|
42
43
|
const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
43
44
|
const GLOB_TESTS = [
|
|
44
45
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -145,7 +146,9 @@ async function ensurePackages(packages) {
|
|
|
145
146
|
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
146
147
|
if (nonExistingPackages.length === 0) return;
|
|
147
148
|
const p = await import("@clack/prompts");
|
|
148
|
-
const
|
|
149
|
+
const packagesMissing = nonExistingPackages.join(", ");
|
|
150
|
+
const packagesMissingPlural = nonExistingPackages.length === 1 ? "Package is" : "Packages are";
|
|
151
|
+
const result = await p.confirm({ message: `${packagesMissingPlural} required for this config: ${packagesMissing}. Do you want to install them?` });
|
|
149
152
|
if (result) await import("@antfu/install-pkg").then(async (i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
150
153
|
}
|
|
151
154
|
function isInEditorEnv() {
|
|
@@ -184,7 +187,7 @@ async function adonisjs(options = {}) {
|
|
|
184
187
|
dirs.config = dirs.config || `${dirs.root}/config`;
|
|
185
188
|
dirs.commands = dirs.commands || `${dirs.root}/commands`;
|
|
186
189
|
const nestedGlobPattern = `**/*.${GLOB_SRC_EXT}`;
|
|
187
|
-
const fileRoutes = Object.values(dirs).map((dir) => join(dir, nestedGlobPattern));
|
|
190
|
+
const fileRoutes = [...Object.values(dirs).map((dir) => join(dir, nestedGlobPattern)), `${dirs.root}/ace.js`];
|
|
188
191
|
const commonRulesSet = {
|
|
189
192
|
"@typescript-eslint/require-await": "off",
|
|
190
193
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
@@ -204,7 +207,7 @@ async function adonisjs(options = {}) {
|
|
|
204
207
|
}
|
|
205
208
|
},
|
|
206
209
|
{
|
|
207
|
-
files:
|
|
210
|
+
files: fileRoutes,
|
|
208
211
|
name: "eienjs/adonisjs/disables",
|
|
209
212
|
rules: { "antfu/no-top-level-await": "off" }
|
|
210
213
|
},
|
|
@@ -253,6 +256,14 @@ async function adonisjs(options = {}) {
|
|
|
253
256
|
files: [join(dirs.providers, nestedGlobPattern)],
|
|
254
257
|
name: "eienjs/adonisjs/providers-disables",
|
|
255
258
|
rules: { "@typescript-eslint/consistent-type-definitions": "off" }
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
files: [join(dirs.tests, nestedGlobPattern)],
|
|
262
|
+
name: "eienjs/adonisjs/tests-disables",
|
|
263
|
+
rules: {
|
|
264
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
265
|
+
"@typescript-eslint/explicit-module-boundary-types": "off"
|
|
266
|
+
}
|
|
256
267
|
}
|
|
257
268
|
];
|
|
258
269
|
}
|
|
@@ -343,6 +354,15 @@ async function disables() {
|
|
|
343
354
|
"@typescript-eslint/explicit-function-return-type": "off"
|
|
344
355
|
}
|
|
345
356
|
},
|
|
357
|
+
{
|
|
358
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
359
|
+
name: "eienjs/disables/cli",
|
|
360
|
+
rules: {
|
|
361
|
+
"antfu/no-top-level-await": "off",
|
|
362
|
+
"no-console": "off",
|
|
363
|
+
"unicorn/no-process-exit": "off"
|
|
364
|
+
}
|
|
365
|
+
},
|
|
346
366
|
{
|
|
347
367
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
348
368
|
name: "eienjs/disables/bin",
|
|
@@ -365,11 +385,6 @@ async function disables() {
|
|
|
365
385
|
name: "eienjs/disables/cjs",
|
|
366
386
|
rules: { "@typescript-eslint/no-require-imports": "off" }
|
|
367
387
|
},
|
|
368
|
-
{
|
|
369
|
-
files: [GLOB_MARKDOWN],
|
|
370
|
-
name: "eienjs/disables/markdown",
|
|
371
|
-
rules: { "unicorn/filename-case": "off" }
|
|
372
|
-
},
|
|
373
388
|
{
|
|
374
389
|
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
375
390
|
name: "eienjs/disables/config-files",
|
|
@@ -386,8 +401,7 @@ async function disables() {
|
|
|
386
401
|
//#region src/configs/stylistic.ts
|
|
387
402
|
const StylisticConfigDefaults = {
|
|
388
403
|
indent: 2,
|
|
389
|
-
quotes: "single"
|
|
390
|
-
maxLineLength: 120
|
|
404
|
+
quotes: "single"
|
|
391
405
|
};
|
|
392
406
|
async function stylistic(options = {}) {
|
|
393
407
|
const { indent, overrides = {}, quotes, maxLineLength = 120 } = {
|
|
@@ -410,7 +424,6 @@ async function stylistic(options = {}) {
|
|
|
410
424
|
...config.rules,
|
|
411
425
|
"antfu/consistent-chaining": "error",
|
|
412
426
|
"antfu/consistent-list-newline": "error",
|
|
413
|
-
"antfu/top-level-function": "error",
|
|
414
427
|
"@stylistic/arrow-parens": ["error", "always"],
|
|
415
428
|
"@stylistic/brace-style": [
|
|
416
429
|
"error",
|
|
@@ -418,9 +431,8 @@ async function stylistic(options = {}) {
|
|
|
418
431
|
{ allowSingleLine: true }
|
|
419
432
|
],
|
|
420
433
|
"@stylistic/max-len": ["error", {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
"ignoreComments": true
|
|
434
|
+
code: maxLineLength,
|
|
435
|
+
ignoreComments: true
|
|
424
436
|
}],
|
|
425
437
|
"@stylistic/padding-line-between-statements": [
|
|
426
438
|
"error",
|
|
@@ -661,6 +673,7 @@ async function javascript(options = {}) {
|
|
|
661
673
|
}],
|
|
662
674
|
"block-scoped-var": "error",
|
|
663
675
|
"constructor-super": "error",
|
|
676
|
+
"curly": "error",
|
|
664
677
|
"default-case-last": "error",
|
|
665
678
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
666
679
|
"eqeqeq": ["error", "smart"],
|
|
@@ -1045,6 +1058,7 @@ async function markdown(options = {}) {
|
|
|
1045
1058
|
"no-unused-expressions": "off",
|
|
1046
1059
|
"no-unused-labels": "off",
|
|
1047
1060
|
"no-unused-vars": "off",
|
|
1061
|
+
"unicode-bom": "off",
|
|
1048
1062
|
"n/prefer-global/process": "off",
|
|
1049
1063
|
"@stylistic/comma-dangle": "off",
|
|
1050
1064
|
"@stylistic/eol-last": "off",
|
|
@@ -1058,9 +1072,9 @@ async function markdown(options = {}) {
|
|
|
1058
1072
|
"@typescript-eslint/no-unused-expressions": "off",
|
|
1059
1073
|
"@typescript-eslint/no-unused-vars": "off",
|
|
1060
1074
|
"@typescript-eslint/no-use-before-define": "off",
|
|
1061
|
-
"unicode-bom": "off",
|
|
1062
1075
|
"unused-imports/no-unused-imports": "off",
|
|
1063
1076
|
"unused-imports/no-unused-vars": "off",
|
|
1077
|
+
"unicorn/filename-case": "off",
|
|
1064
1078
|
...overrides
|
|
1065
1079
|
}
|
|
1066
1080
|
}
|
|
@@ -1086,6 +1100,132 @@ async function node() {
|
|
|
1086
1100
|
}];
|
|
1087
1101
|
}
|
|
1088
1102
|
|
|
1103
|
+
//#endregion
|
|
1104
|
+
//#region src/configs/nuxt.ts
|
|
1105
|
+
async function nuxt(options = {}) {
|
|
1106
|
+
const { overrides = {}, dirs = {}, version = 4, stylistic: stylistic$1 = true } = options;
|
|
1107
|
+
const { sortConfigKeys = Boolean(stylistic$1) } = options;
|
|
1108
|
+
await ensurePackages(["@nuxt/eslint-plugin"]);
|
|
1109
|
+
const pluginNuxt = await interopDefault(import("@nuxt/eslint-plugin"));
|
|
1110
|
+
dirs.root = dirs.root ?? [version === 4 ? "./app" : "."];
|
|
1111
|
+
dirs.src = dirs.src ?? dirs.root;
|
|
1112
|
+
dirs.pages = dirs.pages ?? dirs.src.map((src) => `${src}/pages`);
|
|
1113
|
+
dirs.layouts = dirs.layouts ?? dirs.src.map((src) => `${src}/layouts`);
|
|
1114
|
+
dirs.components = dirs.components ?? dirs.src.map((src) => `${src}/components`);
|
|
1115
|
+
dirs.composables = dirs.composables ?? dirs.src.map((src) => `${src}/composables`);
|
|
1116
|
+
dirs.plugins = dirs.plugins ?? dirs.src.map((src) => `${src}/plugins`);
|
|
1117
|
+
dirs.modules = dirs.modules ?? dirs.src.map((src) => `${src}/modules`);
|
|
1118
|
+
dirs.middleware = dirs.middleware ?? dirs.src.map((src) => `${src}/middleware`);
|
|
1119
|
+
dirs.servers = dirs.servers ?? dirs.src.map((src) => `${src}/servers`);
|
|
1120
|
+
dirs.componentsPrefixed = dirs.componentsPrefixed ?? [];
|
|
1121
|
+
const fileSingleRoot = [
|
|
1122
|
+
...dirs.layouts?.map((layoutsDir) => join(layoutsDir, `**/*.${GLOB_EXTS}`)) || [],
|
|
1123
|
+
...dirs.pages?.map((pagesDir) => join(pagesDir, `**/*.${GLOB_EXTS}`)) || [],
|
|
1124
|
+
...dirs.components?.map((componentsDir) => join(componentsDir, `**/*.server.${GLOB_EXTS}`)) || []
|
|
1125
|
+
].sort();
|
|
1126
|
+
const INLINE_ELEMENTS = [
|
|
1127
|
+
"a",
|
|
1128
|
+
"abbr",
|
|
1129
|
+
"audio",
|
|
1130
|
+
"b",
|
|
1131
|
+
"bdi",
|
|
1132
|
+
"bdo",
|
|
1133
|
+
"canvas",
|
|
1134
|
+
"cite",
|
|
1135
|
+
"code",
|
|
1136
|
+
"data",
|
|
1137
|
+
"del",
|
|
1138
|
+
"dfn",
|
|
1139
|
+
"em",
|
|
1140
|
+
"i",
|
|
1141
|
+
"iframe",
|
|
1142
|
+
"ins",
|
|
1143
|
+
"kbd",
|
|
1144
|
+
"label",
|
|
1145
|
+
"map",
|
|
1146
|
+
"mark",
|
|
1147
|
+
"noscript",
|
|
1148
|
+
"object",
|
|
1149
|
+
"output",
|
|
1150
|
+
"picture",
|
|
1151
|
+
"q",
|
|
1152
|
+
"ruby",
|
|
1153
|
+
"s",
|
|
1154
|
+
"samp",
|
|
1155
|
+
"small",
|
|
1156
|
+
"span",
|
|
1157
|
+
"strong",
|
|
1158
|
+
"sub",
|
|
1159
|
+
"sup",
|
|
1160
|
+
"svg",
|
|
1161
|
+
"time",
|
|
1162
|
+
"u",
|
|
1163
|
+
"var",
|
|
1164
|
+
"video"
|
|
1165
|
+
];
|
|
1166
|
+
return [
|
|
1167
|
+
{
|
|
1168
|
+
name: "eienjs/nuxt/setup",
|
|
1169
|
+
plugins: { nuxt: pluginNuxt },
|
|
1170
|
+
languageOptions: { globals: { $fetch: "readonly" } }
|
|
1171
|
+
},
|
|
1172
|
+
...fileSingleRoot.length > 0 ? [{
|
|
1173
|
+
files: fileSingleRoot,
|
|
1174
|
+
name: "eienjs/nuxt/vue/single-root",
|
|
1175
|
+
rules: { "vue/no-multiple-template-root": "error" }
|
|
1176
|
+
}] : [],
|
|
1177
|
+
{
|
|
1178
|
+
name: "eienjs/nuxt/rules",
|
|
1179
|
+
rules: {
|
|
1180
|
+
"nuxt/prefer-import-meta": "error",
|
|
1181
|
+
...overrides
|
|
1182
|
+
}
|
|
1183
|
+
},
|
|
1184
|
+
...sortConfigKeys ? [{
|
|
1185
|
+
files: ["**/nuxt.config.?([cm])[jt]s?(x)"],
|
|
1186
|
+
name: "eienjs/nuxt/sort-config",
|
|
1187
|
+
rules: { "nuxt/nuxt-config-keys-order": "error" }
|
|
1188
|
+
}] : [],
|
|
1189
|
+
...stylistic$1 ? [{
|
|
1190
|
+
files: [GLOB_VUE],
|
|
1191
|
+
name: "eienjs/nuxt/vue/rules",
|
|
1192
|
+
rules: {
|
|
1193
|
+
"vue/multiline-html-element-content-newline": ["error", {
|
|
1194
|
+
ignoreWhenEmpty: true,
|
|
1195
|
+
ignores: [
|
|
1196
|
+
"pre",
|
|
1197
|
+
"textarea",
|
|
1198
|
+
"router-link",
|
|
1199
|
+
"RouterLink",
|
|
1200
|
+
"nuxt-link",
|
|
1201
|
+
"NuxtLink",
|
|
1202
|
+
"u-link",
|
|
1203
|
+
"ULink",
|
|
1204
|
+
...INLINE_ELEMENTS
|
|
1205
|
+
],
|
|
1206
|
+
allowEmptyLines: false
|
|
1207
|
+
}],
|
|
1208
|
+
"vue/singleline-html-element-content-newline": ["error", {
|
|
1209
|
+
ignoreWhenNoAttributes: true,
|
|
1210
|
+
ignoreWhenEmpty: true,
|
|
1211
|
+
ignores: [
|
|
1212
|
+
"pre",
|
|
1213
|
+
"textarea",
|
|
1214
|
+
"router-link",
|
|
1215
|
+
"RouterLink",
|
|
1216
|
+
"nuxt-link",
|
|
1217
|
+
"NuxtLink",
|
|
1218
|
+
"u-link",
|
|
1219
|
+
"ULink",
|
|
1220
|
+
...INLINE_ELEMENTS
|
|
1221
|
+
],
|
|
1222
|
+
externalIgnores: []
|
|
1223
|
+
}]
|
|
1224
|
+
}
|
|
1225
|
+
}] : []
|
|
1226
|
+
];
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1089
1229
|
//#endregion
|
|
1090
1230
|
//#region src/configs/perfectionist.ts
|
|
1091
1231
|
/**
|
|
@@ -1587,8 +1727,7 @@ async function typescript(options = {}) {
|
|
|
1587
1727
|
"@typescript-eslint/restrict-plus-operands": "error",
|
|
1588
1728
|
"@typescript-eslint/restrict-template-expressions": "error",
|
|
1589
1729
|
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
1590
|
-
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }]
|
|
1591
|
-
"@typescript-eslint/unbound-method": "error"
|
|
1730
|
+
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }]
|
|
1592
1731
|
};
|
|
1593
1732
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1594
1733
|
function makeParser(typeAware, files$1, ignores$1) {
|
|
@@ -1710,6 +1849,7 @@ async function unicorn(options = {}) {
|
|
|
1710
1849
|
"unicorn/expiring-todo-comments": "off",
|
|
1711
1850
|
"unicorn/no-array-reduce": "off",
|
|
1712
1851
|
"unicorn/prefer-export-from": "off",
|
|
1852
|
+
"unicorn/prefer-top-level-await": "off",
|
|
1713
1853
|
...overrides
|
|
1714
1854
|
}
|
|
1715
1855
|
}];
|
|
@@ -1986,4 +2126,4 @@ async function yaml(options = {}) {
|
|
|
1986
2126
|
}
|
|
1987
2127
|
|
|
1988
2128
|
//#endregion
|
|
1989
|
-
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 };
|
|
2129
|
+
export { 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, StylisticConfigDefaults, adonisjs, astro, combine, command, comments, disables, ensurePackages, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, nuxt, 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, OptionsAdonisJS, 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, OptionsNuxt, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem } from "./types-Cd5vIRtv.js";
|
|
2
2
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
3
3
|
import { Linter } from "eslint";
|
|
4
4
|
|
|
@@ -38,6 +38,7 @@ declare const GLOB_SVG = "**/*.svg";
|
|
|
38
38
|
declare const GLOB_HTML = "**/*.htm?(l)";
|
|
39
39
|
declare const GLOB_ASTRO = "**/*.astro";
|
|
40
40
|
declare const GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
41
|
+
declare const GLOB_EXTS = "{js,ts,jsx,tsx,vue}";
|
|
41
42
|
declare const GLOB_MARKDOWN_CODE = "**/*.md/**/*.?([cm])[jt]s?(x)";
|
|
42
43
|
declare const GLOB_TESTS: string[];
|
|
43
44
|
declare const GLOB_ALL_SRC: string[];
|
|
@@ -82,4 +83,4 @@ declare function ensurePackages(packages: (string | undefined)[]): Promise<void>
|
|
|
82
83
|
declare function isInEditorEnv(): boolean;
|
|
83
84
|
declare function isInGitHooksOrLintStaged(): boolean;
|
|
84
85
|
//#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, 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 };
|
|
86
|
+
export { Awaitable, 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, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, 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, 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-
|
|
1
|
+
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, adonisjs, astro, combine, command, comments, disables, ensurePackages, formatters, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, nuxt, parserPlain, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toArray, toml, typescript, unicorn, vue, yaml } from "./configs-CIPkS6TK.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)), adonisjs: enableAdonisjs = false } = 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, nuxt: enableNuxt = false } = options;
|
|
28
28
|
let { isInEditor } = options;
|
|
29
29
|
if (isInEditor == null) {
|
|
30
30
|
isInEditor = isInEditorEnv();
|
|
@@ -75,6 +75,15 @@ 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
|
+
}));
|
|
82
|
+
if (enableNuxt) configs.push(nuxt({
|
|
83
|
+
...resolveSubOptions(options, "nuxt"),
|
|
84
|
+
overrides: getOverrides(options, "nuxt"),
|
|
85
|
+
stylistic: stylisticOptions
|
|
86
|
+
}));
|
|
78
87
|
if (options.jsonc ?? true) configs.push(jsonc({
|
|
79
88
|
overrides: getOverrides(options, "jsonc"),
|
|
80
89
|
stylistic: stylisticOptions
|
|
@@ -93,12 +102,12 @@ function eienjs(options = {}) {
|
|
|
93
102
|
overrides: getOverrides(options, "markdown")
|
|
94
103
|
}));
|
|
95
104
|
if (options.formatters) configs.push(formatters(options.formatters, typeof stylisticOptions === "boolean" ? {} : stylisticOptions));
|
|
96
|
-
if (enableAdonisjs) configs.push(adonisjs({
|
|
97
|
-
...resolveSubOptions(options, "adonisjs"),
|
|
98
|
-
overrides: getOverrides(options, "adonisjs")
|
|
99
|
-
}));
|
|
100
105
|
configs.push(disables());
|
|
101
|
-
if ("files" in options) throw new Error(
|
|
106
|
+
if ("files" in options) throw new Error([
|
|
107
|
+
"[@eienjs/eslint-config] ",
|
|
108
|
+
"The first argument should not contain the \"files\" property as the options are supposed to be global. ",
|
|
109
|
+
"Place it in the second or later config instead."
|
|
110
|
+
].join(""));
|
|
102
111
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
103
112
|
if (key in options) acc[key] = options[key];
|
|
104
113
|
return acc;
|
|
@@ -110,7 +119,7 @@ function eienjs(options = {}) {
|
|
|
110
119
|
"unused-imports/no-unused-imports",
|
|
111
120
|
"test/no-only-tests",
|
|
112
121
|
"prefer-const"
|
|
113
|
-
], { builtinRules: () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
122
|
+
], { builtinRules: async () => import(["eslint", "use-at-your-own-risk"].join("/")).then((r) => r.builtinRules) });
|
|
114
123
|
return composer;
|
|
115
124
|
}
|
|
116
125
|
function resolveSubOptions(options, key) {
|
|
@@ -126,4 +135,4 @@ function getOverrides(options, key) {
|
|
|
126
135
|
var src_default = eienjs;
|
|
127
136
|
|
|
128
137
|
//#endregion
|
|
129
|
-
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, combine, src_default as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
|
138
|
+
export { 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, combine, src_default as default, defaultPluginRenaming, eienjs, ensurePackages, getOverrides, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, parserPlain, resolveSubOptions, toArray };
|
|
@@ -3601,6 +3601,16 @@ interface RuleOptions {
|
|
|
3601
3601
|
* @deprecated
|
|
3602
3602
|
*/
|
|
3603
3603
|
'nonblock-statement-body-position'?: Linter.RuleEntry<NonblockStatementBodyPosition>;
|
|
3604
|
+
/**
|
|
3605
|
+
* Prefer recommended order of Nuxt config properties
|
|
3606
|
+
* @see https://eslint.nuxt.com/packages/plugin#nuxtnuxt-config-keys-order
|
|
3607
|
+
*/
|
|
3608
|
+
'nuxt/nuxt-config-keys-order'?: Linter.RuleEntry<[]>;
|
|
3609
|
+
/**
|
|
3610
|
+
* Prefer using `import.meta.*` over `process.*`
|
|
3611
|
+
* @see https://eslint.nuxt.com/packages/plugin#nuxtprefer-import-meta
|
|
3612
|
+
*/
|
|
3613
|
+
'nuxt/prefer-import-meta'?: Linter.RuleEntry<[]>;
|
|
3604
3614
|
/**
|
|
3605
3615
|
* Enforce consistent line breaks after opening and before closing braces
|
|
3606
3616
|
* @see https://eslint.org/docs/latest/rules/object-curly-newline
|
|
@@ -15364,7 +15374,7 @@ type Yoda = [] | [("always" | "never")] | [("always" | "never"), {
|
|
|
15364
15374
|
onlyEquality?: boolean;
|
|
15365
15375
|
}];
|
|
15366
15376
|
// Names of all the configs
|
|
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/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';
|
|
15377
|
+
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/nuxt/setup' | 'eienjs/nuxt/vue/single-root' | 'eienjs/nuxt/rules' | 'eienjs/nuxt/sort-config' | 'eienjs/nuxt/vue/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';
|
|
15368
15378
|
//#endregion
|
|
15369
15379
|
//#region src/vendored/prettier_types.d.ts
|
|
15370
15380
|
/**
|
|
@@ -15508,6 +15518,67 @@ type TypedFlatConfigItem = Omit<Linter.Config, 'plugins' | 'rules'> & {
|
|
|
15508
15518
|
*/
|
|
15509
15519
|
rules?: Rules;
|
|
15510
15520
|
};
|
|
15521
|
+
interface OptionsNuxt extends OptionsOverrides {
|
|
15522
|
+
/**
|
|
15523
|
+
* Version of Nuxt
|
|
15524
|
+
*
|
|
15525
|
+
* @default 4
|
|
15526
|
+
*/
|
|
15527
|
+
version?: 3 | 4;
|
|
15528
|
+
/**
|
|
15529
|
+
* Sort keys in nuxt.config to maintain a consistent order
|
|
15530
|
+
*
|
|
15531
|
+
* @default true when `stylistic` is enabled
|
|
15532
|
+
*/
|
|
15533
|
+
sortConfigKeys?: boolean;
|
|
15534
|
+
dirs?: {
|
|
15535
|
+
/**
|
|
15536
|
+
* Nuxt source directory
|
|
15537
|
+
*/
|
|
15538
|
+
src?: string[];
|
|
15539
|
+
/**
|
|
15540
|
+
* Root directory for nuxt project
|
|
15541
|
+
*/
|
|
15542
|
+
root?: string[];
|
|
15543
|
+
/**
|
|
15544
|
+
* Directory for pages
|
|
15545
|
+
*/
|
|
15546
|
+
pages?: string[];
|
|
15547
|
+
/**
|
|
15548
|
+
* Directory for layouts
|
|
15549
|
+
*/
|
|
15550
|
+
layouts?: string[];
|
|
15551
|
+
/**
|
|
15552
|
+
* Directory for components
|
|
15553
|
+
*/
|
|
15554
|
+
components?: string[];
|
|
15555
|
+
/**
|
|
15556
|
+
* Directory for components with prefix
|
|
15557
|
+
* Ignore `vue/multi-word-component-names`
|
|
15558
|
+
*/
|
|
15559
|
+
componentsPrefixed?: string[];
|
|
15560
|
+
/**
|
|
15561
|
+
* Directory for composobles
|
|
15562
|
+
*/
|
|
15563
|
+
composables?: string[];
|
|
15564
|
+
/**
|
|
15565
|
+
* Directory for plugins
|
|
15566
|
+
*/
|
|
15567
|
+
plugins?: string[];
|
|
15568
|
+
/**
|
|
15569
|
+
* Directory for modules
|
|
15570
|
+
*/
|
|
15571
|
+
modules?: string[];
|
|
15572
|
+
/**
|
|
15573
|
+
* Directory for middleware
|
|
15574
|
+
*/
|
|
15575
|
+
middleware?: string[];
|
|
15576
|
+
/**
|
|
15577
|
+
* Directory for server
|
|
15578
|
+
*/
|
|
15579
|
+
servers?: string[];
|
|
15580
|
+
};
|
|
15581
|
+
}
|
|
15511
15582
|
interface OptionsAdonisJS extends OptionsOverrides {
|
|
15512
15583
|
/**
|
|
15513
15584
|
* Override the `dirs` option to provide custom directories of adonisjs app.
|
|
@@ -15787,6 +15858,15 @@ interface OptionsConfig extends OptionsComponentExts {
|
|
|
15787
15858
|
* @default false
|
|
15788
15859
|
*/
|
|
15789
15860
|
adonisjs?: boolean | OptionsAdonisJS;
|
|
15861
|
+
/**
|
|
15862
|
+
* Enable Nuxt support.
|
|
15863
|
+
*
|
|
15864
|
+
* Requires installing:
|
|
15865
|
+
* - `@nuxt/eslint-plugin`
|
|
15866
|
+
*
|
|
15867
|
+
* @default false
|
|
15868
|
+
*/
|
|
15869
|
+
nuxt?: boolean | OptionsNuxt;
|
|
15790
15870
|
}
|
|
15791
15871
|
//#endregion
|
|
15792
|
-
export { Awaitable, type ConfigNames, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsTypescript, OptionsVue, RuleOptions, Rules, StylisticConfig, TypedFlatConfigItem };
|
|
15872
|
+
export { Awaitable, type ConfigNames, OptionsAdonisJS, OptionsComponentExts, OptionsConfig, OptionsFiles, OptionsFormatters, OptionsHasTypeScript, OptionsIsInEditor, OptionsNuxt, 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.4.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,7 +24,9 @@
|
|
|
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": {
|
|
@@ -30,6 +34,7 @@
|
|
|
30
34
|
},
|
|
31
35
|
"peerDependencies": {
|
|
32
36
|
"@adonisjs/eslint-plugin": "^2.0.0",
|
|
37
|
+
"@nuxt/eslint-plugin": " ^1.7.1",
|
|
33
38
|
"@prettier/plugin-xml": "^3.4.2",
|
|
34
39
|
"astro-eslint-parser": "^1.2.2",
|
|
35
40
|
"eslint": "^9.32.0",
|
|
@@ -41,6 +46,9 @@
|
|
|
41
46
|
"@adonisjs/eslint-plugin": {
|
|
42
47
|
"optional": true
|
|
43
48
|
},
|
|
49
|
+
"@nuxt/eslint-plugin": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
44
52
|
"@prettier/plugin-xml": {
|
|
45
53
|
"optional": true
|
|
46
54
|
},
|
|
@@ -66,6 +74,8 @@
|
|
|
66
74
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
67
75
|
"@typescript-eslint/parser": "^8.38.0",
|
|
68
76
|
"@vitest/eslint-plugin": "^1.3.4",
|
|
77
|
+
"ansis": "^4.1.0",
|
|
78
|
+
"cac": "^6.7.14",
|
|
69
79
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
70
80
|
"eslint-flat-config-utils": "^2.1.1",
|
|
71
81
|
"eslint-merge-processors": "^2.0.0",
|
|
@@ -78,7 +88,7 @@
|
|
|
78
88
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
79
89
|
"eslint-plugin-perfectionist": "^4.15.0",
|
|
80
90
|
"eslint-plugin-pnpm": "^1.1.0",
|
|
81
|
-
"eslint-plugin-regexp": "^2.9.
|
|
91
|
+
"eslint-plugin-regexp": "^2.9.1",
|
|
82
92
|
"eslint-plugin-toml": "^0.12.0",
|
|
83
93
|
"eslint-plugin-unicorn": "^60.0.0",
|
|
84
94
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
@@ -88,6 +98,7 @@
|
|
|
88
98
|
"globals": "^16.3.0",
|
|
89
99
|
"jsonc-eslint-parser": "^2.4.0",
|
|
90
100
|
"local-pkg": "^1.1.1",
|
|
101
|
+
"parse-gitignore": "^2.0.0",
|
|
91
102
|
"pathe": "^2.0.3",
|
|
92
103
|
"toml-eslint-parser": "^0.10.0",
|
|
93
104
|
"vue-eslint-parser": "^10.2.0",
|
|
@@ -98,6 +109,7 @@
|
|
|
98
109
|
"@commitlint/cli": "^19.8.1",
|
|
99
110
|
"@commitlint/config-conventional": "^19.8.1",
|
|
100
111
|
"@eslint/config-inspector": "^1.1.0",
|
|
112
|
+
"@nuxt/eslint-plugin": "^1.7.1",
|
|
101
113
|
"@prettier/plugin-xml": "^3.4.2",
|
|
102
114
|
"@types/node": "^22.17.0",
|
|
103
115
|
"astro-eslint-parser": "^1.2.2",
|
|
@@ -109,7 +121,7 @@
|
|
|
109
121
|
"husky": "^9.1.7",
|
|
110
122
|
"np": "^10.2.0",
|
|
111
123
|
"prettier-plugin-astro": "^0.14.1",
|
|
112
|
-
"tsdown": "^0.13.
|
|
124
|
+
"tsdown": "^0.13.2",
|
|
113
125
|
"tsx": "^4.20.3",
|
|
114
126
|
"typescript": ">=4.8.4 <5.9.0"
|
|
115
127
|
},
|
|
@@ -142,7 +154,7 @@
|
|
|
142
154
|
"dev": "npx @eslint/config-inspector --config eslint.config.ts",
|
|
143
155
|
"build:inspector": "pnpm build && npx @eslint/config-inspector build",
|
|
144
156
|
"watch": "tsdown --watch",
|
|
145
|
-
"gen": "tsx scripts/typegen.ts",
|
|
157
|
+
"gen": "tsx scripts/typegen.ts && tsx scripts/versiongen.ts",
|
|
146
158
|
"changelog": "auto-changelog -p && git add CHANGELOG.md",
|
|
147
159
|
"release": "np",
|
|
148
160
|
"version": "pnpm build && pnpm changelog",
|