@eienjs/eslint-config 0.2.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 +1 -1
- package/dist/configs/index.js +1 -1
- package/dist/{configs-ChITrcNN.js → configs-BA3UU5JJ.js} +30 -17
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -7
- package/dist/{types-CBNl8Ios.d.ts → types-B-BVuwa4.d.ts} +1 -1
- package/package.json +10 -3
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,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, OptionsOverrides, OptionsRegExp, OptionsStylistic, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, OptionsVue, StylisticConfig, TypedFlatConfigItem } from "../types-B-BVuwa4.js";
|
|
2
2
|
|
|
3
3
|
//#region src/configs/adonisjs.d.ts
|
|
4
4
|
declare function adonisjs(options?: OptionsAdonisJS): Promise<TypedFlatConfigItem[]>;
|
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, perfectionist, pnpm, regexp, sortPackageJson, sortTsconfig, stylistic, test, toml, typescript, unicorn, vue, yaml } from "../configs-BA3UU5JJ.js";
|
|
2
2
|
|
|
3
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 };
|
|
@@ -145,7 +145,9 @@ async function ensurePackages(packages) {
|
|
|
145
145
|
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
146
146
|
if (nonExistingPackages.length === 0) return;
|
|
147
147
|
const p = await import("@clack/prompts");
|
|
148
|
-
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?` });
|
|
149
151
|
if (result) await import("@antfu/install-pkg").then(async (i) => i.installPackage(nonExistingPackages, { dev: true }));
|
|
150
152
|
}
|
|
151
153
|
function isInEditorEnv() {
|
|
@@ -184,7 +186,7 @@ async function adonisjs(options = {}) {
|
|
|
184
186
|
dirs.config = dirs.config || `${dirs.root}/config`;
|
|
185
187
|
dirs.commands = dirs.commands || `${dirs.root}/commands`;
|
|
186
188
|
const nestedGlobPattern = `**/*.${GLOB_SRC_EXT}`;
|
|
187
|
-
const fileRoutes = Object.values(dirs).map((dir) => join(dir, nestedGlobPattern));
|
|
189
|
+
const fileRoutes = [...Object.values(dirs).map((dir) => join(dir, nestedGlobPattern)), `${dirs.root}/ace.js`];
|
|
188
190
|
const commonRulesSet = {
|
|
189
191
|
"@typescript-eslint/require-await": "off",
|
|
190
192
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
@@ -204,7 +206,7 @@ async function adonisjs(options = {}) {
|
|
|
204
206
|
}
|
|
205
207
|
},
|
|
206
208
|
{
|
|
207
|
-
files:
|
|
209
|
+
files: fileRoutes,
|
|
208
210
|
name: "eienjs/adonisjs/disables",
|
|
209
211
|
rules: { "antfu/no-top-level-await": "off" }
|
|
210
212
|
},
|
|
@@ -253,6 +255,14 @@ async function adonisjs(options = {}) {
|
|
|
253
255
|
files: [join(dirs.providers, nestedGlobPattern)],
|
|
254
256
|
name: "eienjs/adonisjs/providers-disables",
|
|
255
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
|
+
}
|
|
256
266
|
}
|
|
257
267
|
];
|
|
258
268
|
}
|
|
@@ -343,6 +353,15 @@ async function disables() {
|
|
|
343
353
|
"@typescript-eslint/explicit-function-return-type": "off"
|
|
344
354
|
}
|
|
345
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
|
+
},
|
|
346
365
|
{
|
|
347
366
|
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
348
367
|
name: "eienjs/disables/bin",
|
|
@@ -365,11 +384,6 @@ async function disables() {
|
|
|
365
384
|
name: "eienjs/disables/cjs",
|
|
366
385
|
rules: { "@typescript-eslint/no-require-imports": "off" }
|
|
367
386
|
},
|
|
368
|
-
{
|
|
369
|
-
files: [GLOB_MARKDOWN],
|
|
370
|
-
name: "eienjs/disables/markdown",
|
|
371
|
-
rules: { "unicorn/filename-case": "off" }
|
|
372
|
-
},
|
|
373
387
|
{
|
|
374
388
|
files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
|
|
375
389
|
name: "eienjs/disables/config-files",
|
|
@@ -386,8 +400,7 @@ async function disables() {
|
|
|
386
400
|
//#region src/configs/stylistic.ts
|
|
387
401
|
const StylisticConfigDefaults = {
|
|
388
402
|
indent: 2,
|
|
389
|
-
quotes: "single"
|
|
390
|
-
maxLineLength: 120
|
|
403
|
+
quotes: "single"
|
|
391
404
|
};
|
|
392
405
|
async function stylistic(options = {}) {
|
|
393
406
|
const { indent, overrides = {}, quotes, maxLineLength = 120 } = {
|
|
@@ -410,7 +423,6 @@ async function stylistic(options = {}) {
|
|
|
410
423
|
...config.rules,
|
|
411
424
|
"antfu/consistent-chaining": "error",
|
|
412
425
|
"antfu/consistent-list-newline": "error",
|
|
413
|
-
"antfu/top-level-function": "error",
|
|
414
426
|
"@stylistic/arrow-parens": ["error", "always"],
|
|
415
427
|
"@stylistic/brace-style": [
|
|
416
428
|
"error",
|
|
@@ -418,9 +430,8 @@ async function stylistic(options = {}) {
|
|
|
418
430
|
{ allowSingleLine: true }
|
|
419
431
|
],
|
|
420
432
|
"@stylistic/max-len": ["error", {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
"ignoreComments": true
|
|
433
|
+
code: maxLineLength,
|
|
434
|
+
ignoreComments: true
|
|
424
435
|
}],
|
|
425
436
|
"@stylistic/padding-line-between-statements": [
|
|
426
437
|
"error",
|
|
@@ -661,6 +672,7 @@ async function javascript(options = {}) {
|
|
|
661
672
|
}],
|
|
662
673
|
"block-scoped-var": "error",
|
|
663
674
|
"constructor-super": "error",
|
|
675
|
+
"curly": "error",
|
|
664
676
|
"default-case-last": "error",
|
|
665
677
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
666
678
|
"eqeqeq": ["error", "smart"],
|
|
@@ -1045,6 +1057,7 @@ async function markdown(options = {}) {
|
|
|
1045
1057
|
"no-unused-expressions": "off",
|
|
1046
1058
|
"no-unused-labels": "off",
|
|
1047
1059
|
"no-unused-vars": "off",
|
|
1060
|
+
"unicode-bom": "off",
|
|
1048
1061
|
"n/prefer-global/process": "off",
|
|
1049
1062
|
"@stylistic/comma-dangle": "off",
|
|
1050
1063
|
"@stylistic/eol-last": "off",
|
|
@@ -1058,9 +1071,9 @@ async function markdown(options = {}) {
|
|
|
1058
1071
|
"@typescript-eslint/no-unused-expressions": "off",
|
|
1059
1072
|
"@typescript-eslint/no-unused-vars": "off",
|
|
1060
1073
|
"@typescript-eslint/no-use-before-define": "off",
|
|
1061
|
-
"unicode-bom": "off",
|
|
1062
1074
|
"unused-imports/no-unused-imports": "off",
|
|
1063
1075
|
"unused-imports/no-unused-vars": "off",
|
|
1076
|
+
"unicorn/filename-case": "off",
|
|
1064
1077
|
...overrides
|
|
1065
1078
|
}
|
|
1066
1079
|
}
|
|
@@ -1587,8 +1600,7 @@ async function typescript(options = {}) {
|
|
|
1587
1600
|
"@typescript-eslint/restrict-plus-operands": "error",
|
|
1588
1601
|
"@typescript-eslint/restrict-template-expressions": "error",
|
|
1589
1602
|
"@typescript-eslint/return-await": ["error", "in-try-catch"],
|
|
1590
|
-
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }]
|
|
1591
|
-
"@typescript-eslint/unbound-method": "error"
|
|
1603
|
+
"@typescript-eslint/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }]
|
|
1592
1604
|
};
|
|
1593
1605
|
const [pluginTs, parserTs] = await Promise.all([interopDefault(import("@typescript-eslint/eslint-plugin")), interopDefault(import("@typescript-eslint/parser"))]);
|
|
1594
1606
|
function makeParser(typeAware, files$1, ignores$1) {
|
|
@@ -1710,6 +1722,7 @@ async function unicorn(options = {}) {
|
|
|
1710
1722
|
"unicorn/expiring-todo-comments": "off",
|
|
1711
1723
|
"unicorn/no-array-reduce": "off",
|
|
1712
1724
|
"unicorn/prefer-export-from": "off",
|
|
1725
|
+
"unicorn/prefer-top-level-await": "off",
|
|
1713
1726
|
...overrides
|
|
1714
1727
|
}
|
|
1715
1728
|
}];
|
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, 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
|
|
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_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
|
|
|
@@ -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
|
|
@@ -93,12 +97,12 @@ function eienjs(options = {}) {
|
|
|
93
97
|
overrides: getOverrides(options, "markdown")
|
|
94
98
|
}));
|
|
95
99
|
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
100
|
configs.push(disables());
|
|
101
|
-
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(""));
|
|
102
106
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
103
107
|
if (key in options) acc[key] = options[key];
|
|
104
108
|
return acc;
|
|
@@ -110,7 +114,7 @@ function eienjs(options = {}) {
|
|
|
110
114
|
"unused-imports/no-unused-imports",
|
|
111
115
|
"test/no-only-tests",
|
|
112
116
|
"prefer-const"
|
|
113
|
-
], { 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) });
|
|
114
118
|
return composer;
|
|
115
119
|
}
|
|
116
120
|
function resolveSubOptions(options, key) {
|
|
@@ -15364,7 +15364,7 @@ type Yoda = [] | [("always" | "never")] | [("always" | "never"), {
|
|
|
15364
15364
|
onlyEquality?: boolean;
|
|
15365
15365
|
}];
|
|
15366
15366
|
// 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';
|
|
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';
|
|
15368
15368
|
//#endregion
|
|
15369
15369
|
//#region src/vendored/prettier_types.d.ts
|
|
15370
15370
|
/**
|
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,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": {
|
|
@@ -66,6 +70,8 @@
|
|
|
66
70
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
67
71
|
"@typescript-eslint/parser": "^8.38.0",
|
|
68
72
|
"@vitest/eslint-plugin": "^1.3.4",
|
|
73
|
+
"ansis": "^4.1.0",
|
|
74
|
+
"cac": "^6.7.14",
|
|
69
75
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
70
76
|
"eslint-flat-config-utils": "^2.1.1",
|
|
71
77
|
"eslint-merge-processors": "^2.0.0",
|
|
@@ -88,6 +94,7 @@
|
|
|
88
94
|
"globals": "^16.3.0",
|
|
89
95
|
"jsonc-eslint-parser": "^2.4.0",
|
|
90
96
|
"local-pkg": "^1.1.1",
|
|
97
|
+
"parse-gitignore": "^2.0.0",
|
|
91
98
|
"pathe": "^2.0.3",
|
|
92
99
|
"toml-eslint-parser": "^0.10.0",
|
|
93
100
|
"vue-eslint-parser": "^10.2.0",
|
|
@@ -142,7 +149,7 @@
|
|
|
142
149
|
"dev": "npx @eslint/config-inspector --config eslint.config.ts",
|
|
143
150
|
"build:inspector": "pnpm build && npx @eslint/config-inspector build",
|
|
144
151
|
"watch": "tsdown --watch",
|
|
145
|
-
"gen": "tsx scripts/typegen.ts",
|
|
152
|
+
"gen": "tsx scripts/typegen.ts && tsx scripts/versiongen.ts",
|
|
146
153
|
"changelog": "auto-changelog -p && git add CHANGELOG.md",
|
|
147
154
|
"release": "np",
|
|
148
155
|
"version": "pnpm build && pnpm changelog",
|