@ivanmaxlogiudice/eslint-config 3.0.0-beta.4 → 3.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +17 -16
- package/dist/index.d.ts +2 -3
- package/dist/index.js +12 -22
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ import c from "picocolors";
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "@ivanmaxlogiudice/eslint-config",
|
|
14
|
-
version: "3.0.0-beta.
|
|
14
|
+
version: "3.0.0-beta.5",
|
|
15
15
|
packageManager: "bun@1.1.24",
|
|
16
16
|
description: "Personal ESLint config",
|
|
17
17
|
type: "module",
|
|
@@ -101,6 +101,7 @@ var package_default = {
|
|
|
101
101
|
"eslint-plugin-unused-imports": "^4.1.3",
|
|
102
102
|
globals: "^15.9.0",
|
|
103
103
|
"jsonc-eslint-parser": "^2.4.0",
|
|
104
|
+
"local-pkg": "^0.5.0",
|
|
104
105
|
picocolors: "^1.0.1",
|
|
105
106
|
yargs: "^17.7.2"
|
|
106
107
|
},
|
|
@@ -351,15 +352,12 @@ async function run(options = {}) {
|
|
|
351
352
|
};
|
|
352
353
|
if (!argSkipPrompt) {
|
|
353
354
|
result = await p4.group({
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
message: c5.reset(message),
|
|
361
|
-
options: extraOptions,
|
|
362
|
-
required: false
|
|
355
|
+
uncommittedConfirmed: () => {
|
|
356
|
+
if (argSkipPrompt || isGitClean())
|
|
357
|
+
return Promise.resolve(true);
|
|
358
|
+
return p4.confirm({
|
|
359
|
+
initialValue: false,
|
|
360
|
+
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
363
361
|
});
|
|
364
362
|
},
|
|
365
363
|
frameworks: ({ results }) => {
|
|
@@ -373,12 +371,15 @@ async function run(options = {}) {
|
|
|
373
371
|
required: false
|
|
374
372
|
});
|
|
375
373
|
},
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
374
|
+
extra: ({ results }) => {
|
|
375
|
+
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
|
|
376
|
+
if (!results.uncommittedConfirmed || isArgExtraValid)
|
|
377
|
+
return;
|
|
378
|
+
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
|
|
379
|
+
return p4.multiselect({
|
|
380
|
+
message: c5.reset(message),
|
|
381
|
+
options: extraOptions,
|
|
382
|
+
required: false
|
|
382
383
|
});
|
|
383
384
|
},
|
|
384
385
|
updateVscodeSettings: ({ results }) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -13483,10 +13483,9 @@ declare const GLOB_EXCLUDE: string[];
|
|
|
13483
13483
|
*/
|
|
13484
13484
|
declare function combine(...configs: Awaitable<Linter.Config | Linter.Config[]>[]): Promise<Linter.Config[]>;
|
|
13485
13485
|
declare function renameRules(rules: Record<string, any>, from: string, to: string): Record<string, any>;
|
|
13486
|
-
declare function clearPackageCache(): void;
|
|
13487
13486
|
declare function hasSomePackage(names: string[]): boolean;
|
|
13487
|
+
declare function isPackageInScope(name: string): boolean;
|
|
13488
13488
|
declare function findUp(file: string, cwd?: string, depth?: number): string | null;
|
|
13489
|
-
declare function packageExists(name: string): boolean;
|
|
13490
13489
|
declare function ensurePackages(packages: string[]): Promise<void>;
|
|
13491
13490
|
declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
13492
13491
|
default: infer U;
|
|
@@ -13497,4 +13496,4 @@ declare function spawnAsync(command: string, args?: readonly string[], options?:
|
|
|
13497
13496
|
stderr: string;
|
|
13498
13497
|
}>;
|
|
13499
13498
|
|
|
13500
|
-
export { GLOB_ALL_SRC, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SRC, GLOB_SRC_EXT, GLOB_TESTS, GLOB_TS, GLOB_VUE, GLOB_YAML, type ResolvedOptions,
|
|
13499
|
+
export { GLOB_ALL_SRC, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_SRC, GLOB_SRC_EXT, GLOB_TESTS, GLOB_TS, GLOB_VUE, GLOB_YAML, type ResolvedOptions, combine, comments, config, config as default, ensurePackages, findUp, getOverrides, hasSomePackage, ignores, imports, interopDefault, isInEditorEnv, isPackageInScope, javascript, jsdoc, jsonc, markdown, node, perfectionist, regexp, renameRules, resolveSubOptions, restrictedSyntaxJs, sortPackageJson, sortTsconfig, spawnAsync, stylistic, test, typescript, unicorn, unocss, vue, yaml };
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,10 @@ import { spawn } from "node:child_process";
|
|
|
85
85
|
import fs from "node:fs";
|
|
86
86
|
import path from "node:path";
|
|
87
87
|
import process from "node:process";
|
|
88
|
-
|
|
88
|
+
import { fileURLToPath } from "node:url";
|
|
89
|
+
import { isPackageExists } from "local-pkg";
|
|
90
|
+
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
91
|
+
var isCwdInScope = isPackageExists("@ivanmaxlogiudice/eslint-config");
|
|
89
92
|
async function combine(...configs) {
|
|
90
93
|
const resolved = await Promise.all(configs);
|
|
91
94
|
return resolved.flat();
|
|
@@ -101,11 +104,11 @@ function renameRules(rules, from, to) {
|
|
|
101
104
|
}
|
|
102
105
|
return renamed;
|
|
103
106
|
}
|
|
104
|
-
function clearPackageCache() {
|
|
105
|
-
cachePkg = void 0;
|
|
106
|
-
}
|
|
107
107
|
function hasSomePackage(names) {
|
|
108
|
-
return names.some((name) =>
|
|
108
|
+
return names.some((name) => isPackageInScope(name));
|
|
109
|
+
}
|
|
110
|
+
function isPackageInScope(name) {
|
|
111
|
+
return isPackageExists(name, { paths: [scopeUrl] });
|
|
109
112
|
}
|
|
110
113
|
function findUp(file, cwd = process.cwd(), depth = 3) {
|
|
111
114
|
let currentPath = cwd;
|
|
@@ -118,21 +121,10 @@ function findUp(file, cwd = process.cwd(), depth = 3) {
|
|
|
118
121
|
}
|
|
119
122
|
return null;
|
|
120
123
|
}
|
|
121
|
-
function packageExists(name) {
|
|
122
|
-
if (!cachePkg) {
|
|
123
|
-
const pkgPath = findUp("package.json");
|
|
124
|
-
if (!pkgPath) {
|
|
125
|
-
throw new Error('Can not found "package.json".');
|
|
126
|
-
}
|
|
127
|
-
const pkgContent = fs.readFileSync(pkgPath, "utf-8");
|
|
128
|
-
cachePkg = JSON.parse(pkgContent);
|
|
129
|
-
}
|
|
130
|
-
return cachePkg?.dependencies?.[name] !== void 0 || cachePkg?.devDependencies?.[name] !== void 0;
|
|
131
|
-
}
|
|
132
124
|
async function ensurePackages(packages) {
|
|
133
|
-
if (process.env.CI || process.stdout.isTTY === false)
|
|
125
|
+
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
|
|
134
126
|
return;
|
|
135
|
-
const missingPackages = packages.filter((i) => i && !
|
|
127
|
+
const missingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
136
128
|
if (missingPackages.length === 0)
|
|
137
129
|
return;
|
|
138
130
|
console.log(`
|
|
@@ -1332,12 +1324,11 @@ async function yaml(options = {}) {
|
|
|
1332
1324
|
|
|
1333
1325
|
// src/factory.ts
|
|
1334
1326
|
async function config2(options = {}, ...userConfigs) {
|
|
1335
|
-
clearPackageCache();
|
|
1336
1327
|
const {
|
|
1337
1328
|
componentExts = [],
|
|
1338
1329
|
isInEditor = isInEditorEnv(),
|
|
1339
1330
|
regexp: enableRegexp = false,
|
|
1340
|
-
typescript: enableTypeScript =
|
|
1331
|
+
typescript: enableTypeScript = isPackageInScope("typescript"),
|
|
1341
1332
|
unocss: enableUnoCSS = hasSomePackage(["unocss", "@unocss/nuxt"]),
|
|
1342
1333
|
vue: enableVue = hasSomePackage(["vue", "nuxt", "vitepress", "@slidev/cli"])
|
|
1343
1334
|
} = options;
|
|
@@ -1443,7 +1434,6 @@ export {
|
|
|
1443
1434
|
GLOB_TS,
|
|
1444
1435
|
GLOB_VUE,
|
|
1445
1436
|
GLOB_YAML,
|
|
1446
|
-
clearPackageCache,
|
|
1447
1437
|
combine,
|
|
1448
1438
|
comments,
|
|
1449
1439
|
config2 as config,
|
|
@@ -1456,12 +1446,12 @@ export {
|
|
|
1456
1446
|
imports,
|
|
1457
1447
|
interopDefault,
|
|
1458
1448
|
isInEditorEnv,
|
|
1449
|
+
isPackageInScope,
|
|
1459
1450
|
javascript,
|
|
1460
1451
|
jsdoc,
|
|
1461
1452
|
jsonc,
|
|
1462
1453
|
markdown,
|
|
1463
1454
|
node,
|
|
1464
|
-
packageExists,
|
|
1465
1455
|
perfectionist,
|
|
1466
1456
|
regexp,
|
|
1467
1457
|
renameRules,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ivanmaxlogiudice/eslint-config",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
4
4
|
"packageManager": "bun@1.1.24",
|
|
5
5
|
"description": "Personal ESLint config",
|
|
6
6
|
"type": "module",
|
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
"eslint-plugin-unused-imports": "^4.1.3",
|
|
91
91
|
"globals": "^15.9.0",
|
|
92
92
|
"jsonc-eslint-parser": "^2.4.0",
|
|
93
|
+
"local-pkg": "^0.5.0",
|
|
93
94
|
"picocolors": "^1.0.1",
|
|
94
95
|
"yargs": "^17.7.2"
|
|
95
96
|
},
|