@ariestools/toolchain 9.2.1 → 10.0.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/dist/actions/cleanRuleCatalog.d.ts +2 -10
- package/dist/actions/cleanRuleCatalog.d.ts.map +1 -1
- package/dist/actions/dead/dead.d.ts.map +1 -1
- package/dist/actions/dead/evaluateRules.d.ts +1 -0
- package/dist/actions/dead/evaluateRules.d.ts.map +1 -1
- package/dist/actions/dead/ruleChecks.d.ts +32 -0
- package/dist/actions/dead/ruleChecks.d.ts.map +1 -0
- package/dist/actions/dead/runDeadAnalysis.d.ts +4 -3
- package/dist/actions/dead/runDeadAnalysis.d.ts.map +1 -1
- package/dist/actions/package/cleanRules.d.ts +4 -0
- package/dist/actions/package/cleanRules.d.ts.map +1 -1
- package/dist/actions/ruleCatalog.d.ts +1 -1
- package/dist/actions/ruleCatalog.d.ts.map +1 -1
- package/dist/actions/ruleCatalogRender.d.ts +12 -0
- package/dist/actions/ruleCatalogRender.d.ts.map +1 -1
- package/dist/actions/ruleRunner.d.ts +15 -1
- package/dist/actions/ruleRunner.d.ts.map +1 -1
- package/dist/bin/package/build.mjs +0 -4
- package/dist/bin/package/build.mjs.map +1 -1
- package/dist/bin/package/clean.mjs +34 -29
- package/dist/bin/package/clean.mjs.map +1 -1
- package/dist/bin/package/publint.mjs +0 -4
- package/dist/bin/package/publint.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +34 -29
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/xy.mjs +290 -351
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/bin/xyex.mjs +290 -351
- package/dist/bin/xyex.mjs.map +1 -1
- package/dist/lib/ruleCommandRegistry.d.ts +0 -4
- package/dist/lib/ruleCommandRegistry.d.ts.map +1 -1
- package/dist/xy/common/gitlintCommand.d.ts +0 -1
- package/dist/xy/common/gitlintCommand.d.ts.map +1 -1
- package/dist/xy/common/index.d.ts.map +1 -1
- package/dist/xy/lint/index.d.ts.map +1 -1
- package/dist/xy/lint/lintlintCommand.d.ts +0 -1
- package/dist/xy/lint/lintlintCommand.d.ts.map +1 -1
- package/dist/xy/lint/nodeLintCommand.d.ts +0 -1
- package/dist/xy/lint/nodeLintCommand.d.ts.map +1 -1
- package/dist/xy/stability.d.ts +0 -4
- package/dist/xy/stability.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/bin/xyex.mjs
CHANGED
|
@@ -11875,7 +11875,6 @@ const RULE_COMMANDS = {
|
|
|
11875
11875
|
title: "Fix Rules"
|
|
11876
11876
|
},
|
|
11877
11877
|
gitLint: {
|
|
11878
|
-
aliases: ["gitlint"],
|
|
11879
11878
|
command: "git lint",
|
|
11880
11879
|
configKey: "gitLint",
|
|
11881
11880
|
includeInRoot: true,
|
|
@@ -11888,14 +11887,12 @@ const RULE_COMMANDS = {
|
|
|
11888
11887
|
title: "Lint Rules"
|
|
11889
11888
|
},
|
|
11890
11889
|
lintLint: {
|
|
11891
|
-
aliases: ["lintlint"],
|
|
11892
11890
|
command: "lint lint",
|
|
11893
11891
|
configKey: "lintLint",
|
|
11894
11892
|
includeInRoot: true,
|
|
11895
11893
|
title: "Lint Lint Rules"
|
|
11896
11894
|
},
|
|
11897
11895
|
nodeLint: {
|
|
11898
|
-
aliases: ["node-lint"],
|
|
11899
11896
|
command: "node lint",
|
|
11900
11897
|
configKey: "nodeLint",
|
|
11901
11898
|
includeInRoot: true,
|
|
@@ -11914,7 +11911,6 @@ const RULE_COMMANDS = {
|
|
|
11914
11911
|
title: "Plan Lint Rules"
|
|
11915
11912
|
},
|
|
11916
11913
|
publint: {
|
|
11917
|
-
aliases: ["republint"],
|
|
11918
11914
|
command: "publint",
|
|
11919
11915
|
configKey: "publint",
|
|
11920
11916
|
includeInRoot: true,
|
|
@@ -24424,7 +24420,7 @@ const DEFAULT_AEI_THRESHOLDS = {
|
|
|
24424
24420
|
probablyPeerMax: 179,
|
|
24425
24421
|
reviewMax: 119
|
|
24426
24422
|
};
|
|
24427
|
-
const RULE_LEVELS$
|
|
24423
|
+
const RULE_LEVELS$1 = /* @__PURE__ */ new Set([
|
|
24428
24424
|
"error",
|
|
24429
24425
|
"off",
|
|
24430
24426
|
"warn"
|
|
@@ -24435,8 +24431,8 @@ function isRecord$9(value) {
|
|
|
24435
24431
|
function isValidWeight(value) {
|
|
24436
24432
|
return value === "infinite" || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
24437
24433
|
}
|
|
24438
|
-
function isRuleLevel$
|
|
24439
|
-
return typeof value === "string" && RULE_LEVELS$
|
|
24434
|
+
function isRuleLevel$4(value) {
|
|
24435
|
+
return typeof value === "string" && RULE_LEVELS$1.has(value);
|
|
24440
24436
|
}
|
|
24441
24437
|
function parseWeight(location, weight) {
|
|
24442
24438
|
if (!isValidWeight(weight)) throw new TypeError(`${location} must be a non-negative finite number or "infinite"`);
|
|
@@ -24445,7 +24441,7 @@ function parseWeight(location, weight) {
|
|
|
24445
24441
|
function parseTupleRuleSetting(location, setting) {
|
|
24446
24442
|
if (setting.length !== 2) throw new TypeError(`${location} tuple must be [level, options]`);
|
|
24447
24443
|
const [level, options] = setting;
|
|
24448
|
-
if (!isRuleLevel$
|
|
24444
|
+
if (!isRuleLevel$4(level)) throw new TypeError(`${location} level must be "error", "warn", or "off"`);
|
|
24449
24445
|
if (!isRecord$9(options)) throw new TypeError(`${location} options must be an object`);
|
|
24450
24446
|
return {
|
|
24451
24447
|
enabled: level !== "off",
|
|
@@ -24460,7 +24456,7 @@ function parseObjectRuleSetting(location, setting) {
|
|
|
24460
24456
|
"weight"
|
|
24461
24457
|
].includes(key)) throw new TypeError(`${location} has unknown option "${key}"`);
|
|
24462
24458
|
if (setting.enabled !== void 0 && typeof setting.enabled !== "boolean") throw new TypeError(`${location}.enabled must be a boolean`);
|
|
24463
|
-
if (setting.level !== void 0 && !isRuleLevel$
|
|
24459
|
+
if (setting.level !== void 0 && !isRuleLevel$4(setting.level)) throw new TypeError(`${location}.level must be "error", "warn", or "off"`);
|
|
24464
24460
|
const level = setting.level;
|
|
24465
24461
|
return {
|
|
24466
24462
|
enabled: level === void 0 ? setting.enabled : level !== "off",
|
|
@@ -24470,7 +24466,7 @@ function parseObjectRuleSetting(location, setting) {
|
|
|
24470
24466
|
}
|
|
24471
24467
|
function parseRuleSetting(location, setting) {
|
|
24472
24468
|
if (typeof setting === "boolean") return { enabled: setting };
|
|
24473
|
-
if (isRuleLevel$
|
|
24469
|
+
if (isRuleLevel$4(setting)) return {
|
|
24474
24470
|
enabled: setting !== "off",
|
|
24475
24471
|
level: setting
|
|
24476
24472
|
};
|
|
@@ -28231,7 +28227,7 @@ const BUILT_IN_RULE_OPTION_KEYS = {
|
|
|
28231
28227
|
function isRecord$7(value) {
|
|
28232
28228
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28233
28229
|
}
|
|
28234
|
-
function isRuleLevel$
|
|
28230
|
+
function isRuleLevel$3(value) {
|
|
28235
28231
|
return typeof value === "string" && VALID_RULE_LEVELS$1.has(value);
|
|
28236
28232
|
}
|
|
28237
28233
|
function severityFromLevel$1(level) {
|
|
@@ -28254,7 +28250,7 @@ function warnDeprecatedDeplintRuleId(ruleId, canonicalRuleId) {
|
|
|
28254
28250
|
}
|
|
28255
28251
|
function parseRuleConfig$1(ruleId, value) {
|
|
28256
28252
|
if (typeof value === "string") {
|
|
28257
|
-
if (!isRuleLevel$
|
|
28253
|
+
if (!isRuleLevel$3(value)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} must be one of "off", "warn", or "error"`);
|
|
28258
28254
|
return {
|
|
28259
28255
|
level: value,
|
|
28260
28256
|
options: {}
|
|
@@ -28263,7 +28259,7 @@ function parseRuleConfig$1(ruleId, value) {
|
|
|
28263
28259
|
if (Array.isArray(value)) {
|
|
28264
28260
|
if (value.length !== 2) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} tuple must be [level, options]`);
|
|
28265
28261
|
const level = value[0];
|
|
28266
|
-
if (!isRuleLevel$
|
|
28262
|
+
if (!isRuleLevel$3(level)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} level must be one of "off", "warn", or "error"`);
|
|
28267
28263
|
const options = value[1];
|
|
28268
28264
|
if (!isRecord$7(options)) throw new TypeError(`${formatRuleConfigLocation$1(ruleId)} options must be an object`);
|
|
28269
28265
|
return {
|
|
@@ -34773,38 +34769,154 @@ function resolveSafeCleanPatterns(patterns, baseDir, rootDir) {
|
|
|
34773
34769
|
return resolvedPatterns;
|
|
34774
34770
|
}
|
|
34775
34771
|
//#endregion
|
|
34776
|
-
//#region src/actions/
|
|
34777
|
-
const RULE_LEVELS
|
|
34772
|
+
//#region src/actions/ruleRunner.ts
|
|
34773
|
+
const RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
34778
34774
|
"error",
|
|
34779
34775
|
"off",
|
|
34780
34776
|
"warn"
|
|
34781
34777
|
]);
|
|
34782
|
-
function isRuleLevel$
|
|
34783
|
-
return typeof value === "string" && RULE_LEVELS
|
|
34778
|
+
function isRuleLevel$2(value) {
|
|
34779
|
+
return typeof value === "string" && RULE_LEVELS.has(value);
|
|
34784
34780
|
}
|
|
34785
|
-
function
|
|
34786
|
-
if (setting
|
|
34787
|
-
|
|
34788
|
-
|
|
34781
|
+
function parseRuleLevelSetting(location, setting, defaultLevel) {
|
|
34782
|
+
if (setting === void 0) return defaultLevel;
|
|
34783
|
+
if (typeof setting === "boolean") return setting ? "warn" : "off";
|
|
34784
|
+
if (isRuleLevel$2(setting)) return setting;
|
|
34785
|
+
if (Array.isArray(setting) && setting.length > 0) {
|
|
34786
|
+
const [level] = setting;
|
|
34787
|
+
if (isRuleLevel$2(level)) return level;
|
|
34789
34788
|
}
|
|
34790
|
-
if (setting
|
|
34791
|
-
|
|
34792
|
-
|
|
34789
|
+
if (typeof setting === "object" && setting !== null && !Array.isArray(setting)) {
|
|
34790
|
+
const record = setting;
|
|
34791
|
+
if (record.level !== void 0) {
|
|
34792
|
+
if (!isRuleLevel$2(record.level)) throw new TypeError(`${location}.level must be "error", "warn", or "off"`);
|
|
34793
|
+
return record.level;
|
|
34794
|
+
}
|
|
34795
|
+
if (record.enabled !== void 0) {
|
|
34796
|
+
if (typeof record.enabled !== "boolean") throw new TypeError(`${location}.enabled must be a boolean`);
|
|
34797
|
+
return record.enabled ? defaultLevel : "off";
|
|
34798
|
+
}
|
|
34793
34799
|
}
|
|
34794
34800
|
throw new TypeError(`${location} must be a rule level, boolean, [level, options], or { level?, enabled? } object`);
|
|
34795
34801
|
}
|
|
34796
|
-
|
|
34797
|
-
|
|
34798
|
-
|
|
34799
|
-
|
|
34800
|
-
|
|
34801
|
-
|
|
34802
|
-
|
|
34803
|
-
|
|
34804
|
-
|
|
34805
|
-
|
|
34806
|
-
|
|
34802
|
+
function validateConfiguredRuleIds(commandName, configKey, rules, config) {
|
|
34803
|
+
const known = new Set(rules.flatMap((rule) => [rule.id, ...rule.aliases ?? []]));
|
|
34804
|
+
const unknown = Object.keys(config?.rules ?? {}).filter((id) => !known.has(id));
|
|
34805
|
+
if (unknown.length > 0) throw new TypeError(`Unknown ${commandName} rule ${unknown.map((id) => `"${id}"`).join(", ")} in commands.${configKey}.rules`);
|
|
34806
|
+
}
|
|
34807
|
+
function diagnosticsForRule(rule, level, isExplicit, diagnostics) {
|
|
34808
|
+
return (diagnostics ?? []).map((diagnostic) => ({
|
|
34809
|
+
...diagnostic,
|
|
34810
|
+
level: isExplicit ? level : diagnostic.level ?? level,
|
|
34811
|
+
rule: diagnostic.rule ?? rule.id
|
|
34812
|
+
}));
|
|
34813
|
+
}
|
|
34814
|
+
const deprecatedRuleAliasWarnings = /* @__PURE__ */ new Set();
|
|
34815
|
+
function warnDeprecatedRuleAlias(configKey, alias, ruleId) {
|
|
34816
|
+
const key = `${configKey}:${alias}:${ruleId}`;
|
|
34817
|
+
if (deprecatedRuleAliasWarnings.has(key)) return;
|
|
34818
|
+
deprecatedRuleAliasWarnings.add(key);
|
|
34819
|
+
console.warn(chalk.yellow(`Deprecated: commands.${configKey}.rules["${alias}"] is deprecated; use commands.${configKey}.rules["${ruleId}"] instead.`));
|
|
34820
|
+
}
|
|
34821
|
+
function configuredRuleSetting(configKey, rule, config) {
|
|
34822
|
+
const rules = config?.rules;
|
|
34823
|
+
if (rules === void 0) return { setting: void 0 };
|
|
34824
|
+
const setting = rules[rule.id];
|
|
34825
|
+
if (setting !== void 0) return { setting };
|
|
34826
|
+
const aliases = rule.aliases ?? [];
|
|
34827
|
+
for (const alias of aliases) {
|
|
34828
|
+
const aliasSetting = rules[alias];
|
|
34829
|
+
if (aliasSetting === void 0) continue;
|
|
34830
|
+
warnDeprecatedRuleAlias(configKey, alias, rule.id);
|
|
34831
|
+
return { setting: aliasSetting };
|
|
34832
|
+
}
|
|
34833
|
+
return { setting: void 0 };
|
|
34834
|
+
}
|
|
34835
|
+
function resolveRuleLevel(configKey, rule, config) {
|
|
34836
|
+
const { setting } = configuredRuleSetting(configKey, rule, config);
|
|
34837
|
+
return {
|
|
34838
|
+
isExplicit: setting !== void 0,
|
|
34839
|
+
level: parseRuleLevelSetting(ruleConfigPath(configKey, rule.id), setting, rule.defaultLevel)
|
|
34840
|
+
};
|
|
34841
|
+
}
|
|
34842
|
+
function buildRunResult(report, strict) {
|
|
34843
|
+
const errors = report.diagnostics.filter((diagnostic) => diagnostic.level === "error");
|
|
34844
|
+
const warnings = report.diagnostics.filter((diagnostic) => diagnostic.level === "warn");
|
|
34845
|
+
const exitCode = report.errorCount > 0 || strict && report.warningCount > 0 ? 1 : 0;
|
|
34846
|
+
const result = actionResult({
|
|
34847
|
+
errorCount: report.errorCount,
|
|
34848
|
+
exitCode,
|
|
34849
|
+
warningCount: report.warningCount
|
|
34850
|
+
});
|
|
34851
|
+
if (typeof result === "number") return {
|
|
34852
|
+
envelope: {
|
|
34853
|
+
data: report,
|
|
34854
|
+
errorCount: 0,
|
|
34855
|
+
warningCount: 0
|
|
34856
|
+
},
|
|
34857
|
+
exitCode: 0
|
|
34858
|
+
};
|
|
34859
|
+
return {
|
|
34860
|
+
envelope: {
|
|
34861
|
+
...result.envelope,
|
|
34862
|
+
data: report,
|
|
34863
|
+
errors,
|
|
34864
|
+
warnings
|
|
34865
|
+
},
|
|
34866
|
+
exitCode: result.exitCode
|
|
34867
|
+
};
|
|
34807
34868
|
}
|
|
34869
|
+
function defaultRuleReporter() {
|
|
34870
|
+
return {
|
|
34871
|
+
diagnostic: (diagnostic) => {
|
|
34872
|
+
const marker = diagnostic.level === "error" ? "✗" : "⚠";
|
|
34873
|
+
const color = diagnostic.level === "error" ? chalk.red : chalk.yellow;
|
|
34874
|
+
console.log(color(` ${marker} ${diagnostic.message}`));
|
|
34875
|
+
},
|
|
34876
|
+
fixed: (rule, fixedCount) => {
|
|
34877
|
+
console.log(chalk.green(` ✔ ${rule.id}: fixed ${fixedCount} issue(s)`));
|
|
34878
|
+
},
|
|
34879
|
+
passed: (rule) => {
|
|
34880
|
+
console.log(chalk.green(` ✓ ${rule.id}`));
|
|
34881
|
+
}
|
|
34882
|
+
};
|
|
34883
|
+
}
|
|
34884
|
+
function recordRuleOutcome(report, rule, diagnostics, fixedCount, reporter) {
|
|
34885
|
+
report.fixedCount += fixedCount;
|
|
34886
|
+
for (const diagnostic of diagnostics) {
|
|
34887
|
+
report.diagnostics.push(diagnostic);
|
|
34888
|
+
if (diagnostic.level === "error") report.errorCount += 1;
|
|
34889
|
+
else report.warningCount += 1;
|
|
34890
|
+
reporter?.diagnostic?.(diagnostic);
|
|
34891
|
+
}
|
|
34892
|
+
if (fixedCount > 0) reporter?.fixed?.(rule, fixedCount);
|
|
34893
|
+
if (fixedCount === 0 && diagnostics.length === 0) reporter?.passed?.(rule);
|
|
34894
|
+
}
|
|
34895
|
+
async function runRuleChecks({ commandName, configKey = commandName, config, context, fix = false, levelOverrides, reporter, rules, strict = isStrictMode() }) {
|
|
34896
|
+
validateConfiguredRuleIds(commandName, configKey, rules, config);
|
|
34897
|
+
const report = {
|
|
34898
|
+
diagnostics: [],
|
|
34899
|
+
errorCount: 0,
|
|
34900
|
+
fixedCount: 0,
|
|
34901
|
+
warningCount: 0
|
|
34902
|
+
};
|
|
34903
|
+
for (const rule of rules) {
|
|
34904
|
+
const resolved = resolveRuleLevel(configKey, rule, config);
|
|
34905
|
+
const override = levelOverrides?.[rule.id];
|
|
34906
|
+
const level = override ?? resolved.level;
|
|
34907
|
+
if (level === "off") continue;
|
|
34908
|
+
const isExplicit = resolved.isExplicit || override !== void 0;
|
|
34909
|
+
const outcome = await rule.check(context, {
|
|
34910
|
+
fix,
|
|
34911
|
+
isExplicit,
|
|
34912
|
+
level
|
|
34913
|
+
});
|
|
34914
|
+
recordRuleOutcome(report, rule, diagnosticsForRule(rule, level, isExplicit, outcome.diagnostics), outcome.fixedCount ?? 0, reporter);
|
|
34915
|
+
}
|
|
34916
|
+
return buildRunResult(report, strict);
|
|
34917
|
+
}
|
|
34918
|
+
//#endregion
|
|
34919
|
+
//#region src/actions/package/cleanRules.ts
|
|
34808
34920
|
/**
|
|
34809
34921
|
Hard safety rules — always enforced; cannot be disabled via config.
|
|
34810
34922
|
*/
|
|
@@ -34827,7 +34939,6 @@ const CLEAN_CONFIGURABLE_RULES = [{
|
|
|
34827
34939
|
description: "Also delete every path under the package that is matched by .gitignore",
|
|
34828
34940
|
id: "clean.gitignored-all"
|
|
34829
34941
|
}];
|
|
34830
|
-
const CONFIGURABLE_RULE_IDS = new Set(CLEAN_CONFIGURABLE_RULES.map((rule) => rule.id));
|
|
34831
34942
|
const HARD_RULE_IDS = new Set(CLEAN_HARD_RULES.map((rule) => rule.id));
|
|
34832
34943
|
/**
|
|
34833
34944
|
Immutable exclude entries — always skipped by clean, cannot be overridden.
|
|
@@ -34849,21 +34960,26 @@ const CLEAN_DEFAULT_EXCLUDE = [
|
|
|
34849
34960
|
function isCleanRuleEnabled(level) {
|
|
34850
34961
|
return level !== "off";
|
|
34851
34962
|
}
|
|
34852
|
-
function defaultLevelForRule(ruleId) {
|
|
34963
|
+
function defaultLevelForRule$1(ruleId) {
|
|
34853
34964
|
return CLEAN_CONFIGURABLE_RULES.find((rule) => rule.id === ruleId)?.defaultLevel ?? "off";
|
|
34854
34965
|
}
|
|
34855
34966
|
/**
|
|
34967
|
+
* Reject config references to hard (non-configurable) safety rules.
|
|
34968
|
+
*/
|
|
34969
|
+
function assertCleanConfigurableRules(config) {
|
|
34970
|
+
const configured = Object.keys(config?.rules ?? {});
|
|
34971
|
+
for (const ruleId of configured) if (HARD_RULE_IDS.has(ruleId)) throw new TypeError(`commands.clean.rules["${ruleId}"] cannot be configured — hard safety rules are always enforced`);
|
|
34972
|
+
}
|
|
34973
|
+
/**
|
|
34856
34974
|
* Resolve configurable clean rule levels from config. Throws if the config
|
|
34857
34975
|
* references hard (non-configurable) rules or unknown rule ids.
|
|
34858
34976
|
*/
|
|
34859
34977
|
function resolveCleanRules(config) {
|
|
34860
34978
|
const rules = config?.rules ?? {};
|
|
34861
|
-
|
|
34862
|
-
|
|
34863
|
-
if (!CONFIGURABLE_RULE_IDS.has(ruleId)) throw new TypeError(`Unknown clean rule "${ruleId}" in commands.clean.rules. Configurable rules: ${[...CONFIGURABLE_RULE_IDS].join(", ")}`);
|
|
34864
|
-
}
|
|
34979
|
+
assertCleanConfigurableRules(config);
|
|
34980
|
+
validateConfiguredRuleIds("clean", "clean", CLEAN_CONFIGURABLE_RULES, config);
|
|
34865
34981
|
const level = (ruleId, setting) => {
|
|
34866
|
-
return
|
|
34982
|
+
return parseRuleLevelSetting(`commands.clean.rules["${ruleId}"]`, setting, defaultLevelForRule$1(ruleId));
|
|
34867
34983
|
};
|
|
34868
34984
|
return {
|
|
34869
34985
|
gitignoredAll: level("clean.gitignored-all", rules["clean.gitignored-all"]),
|
|
@@ -36260,7 +36376,7 @@ function normalizePublintRuleName(location, value) {
|
|
|
36260
36376
|
if (!isPublintCheckName(bareName)) throw new TypeError(`Unknown publint rule "${value}" in ${location}`);
|
|
36261
36377
|
return bareName;
|
|
36262
36378
|
}
|
|
36263
|
-
function isRuleLevel$
|
|
36379
|
+
function isRuleLevel$1(value) {
|
|
36264
36380
|
return typeof value === "string" && PUBLINT_RULE_LEVELS.has(value);
|
|
36265
36381
|
}
|
|
36266
36382
|
function candidateRuleLevelValue(value) {
|
|
@@ -36275,7 +36391,7 @@ function parseRuleLevel(location, value) {
|
|
|
36275
36391
|
const candidate = candidateRuleLevelValue(value);
|
|
36276
36392
|
if (candidate === true) return "warn";
|
|
36277
36393
|
if (candidate === false) return "off";
|
|
36278
|
-
if (isRuleLevel$
|
|
36394
|
+
if (isRuleLevel$1(candidate)) return candidate;
|
|
36279
36395
|
throw new TypeError(`${location} must be "error", "warn", "off", boolean, [level, options], or { level?, enabled? }`);
|
|
36280
36396
|
}
|
|
36281
36397
|
function normalizePublintRuleNames(location, values) {
|
|
@@ -41372,7 +41488,7 @@ const VALID_RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
|
41372
41488
|
function isRecord$5(value) {
|
|
41373
41489
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41374
41490
|
}
|
|
41375
|
-
function isRuleLevel
|
|
41491
|
+
function isRuleLevel(value) {
|
|
41376
41492
|
return typeof value === "string" && VALID_RULE_LEVELS.has(value);
|
|
41377
41493
|
}
|
|
41378
41494
|
function severityFromLevel(level) {
|
|
@@ -41383,7 +41499,7 @@ function formatRuleConfigLocation(ruleId) {
|
|
|
41383
41499
|
}
|
|
41384
41500
|
function parseRuleConfig(ruleId, value) {
|
|
41385
41501
|
if (typeof value === "string") {
|
|
41386
|
-
if (!isRuleLevel
|
|
41502
|
+
if (!isRuleLevel(value)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} must be one of "off", "warn", or "error"`);
|
|
41387
41503
|
return {
|
|
41388
41504
|
level: value,
|
|
41389
41505
|
options: {}
|
|
@@ -41392,7 +41508,7 @@ function parseRuleConfig(ruleId, value) {
|
|
|
41392
41508
|
if (Array.isArray(value)) {
|
|
41393
41509
|
if (value.length !== 2) throw new TypeError(`${formatRuleConfigLocation(ruleId)} tuple must be [level, options]`);
|
|
41394
41510
|
const level = value[0];
|
|
41395
|
-
if (!isRuleLevel
|
|
41511
|
+
if (!isRuleLevel(level)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} level must be one of "off", "warn", or "error"`);
|
|
41396
41512
|
const options = value[1];
|
|
41397
41513
|
if (!isRecord$5(options)) throw new TypeError(`${formatRuleConfigLocation(ruleId)} options must be an object`);
|
|
41398
41514
|
return {
|
|
@@ -41632,12 +41748,6 @@ function evaluateRuleForAnalysis(analysis, rule, repoUsage, workspaceUsage) {
|
|
|
41632
41748
|
if (workspaceUsage !== void 0 && rule.meta.scope === "workspace") return evaluateWorkspaceRules(analysis, rule, workspaceUsage);
|
|
41633
41749
|
return [];
|
|
41634
41750
|
}
|
|
41635
|
-
function evaluateDeadRules(analyses, rules, repoUsage, workspaceUsage) {
|
|
41636
|
-
const findings = [];
|
|
41637
|
-
const enabledRules = rules.filter((rule) => rule.enabled);
|
|
41638
|
-
for (const analysis of analyses) for (const rule of enabledRules) findings.push(...evaluateRuleForAnalysis(analysis, rule, repoUsage, workspaceUsage));
|
|
41639
|
-
return dedupeToNarrowestScope(findings);
|
|
41640
|
-
}
|
|
41641
41751
|
function getDisabledWorkspaceRules(rules, hasCodeWorkspace) {
|
|
41642
41752
|
if (hasCodeWorkspace) return [];
|
|
41643
41753
|
return rules.filter((rule) => rule.requiresCodeWorkspace === true && rule.enabled).map((rule) => rule.id);
|
|
@@ -42166,6 +42276,73 @@ function loadDeadRules(config, options) {
|
|
|
42166
42276
|
return options?.deprecated === true ? enableDeprecatedRules(rules) : rules;
|
|
42167
42277
|
}
|
|
42168
42278
|
//#endregion
|
|
42279
|
+
//#region src/actions/dead/ruleChecks.ts
|
|
42280
|
+
function severityToEngineLevel(severity) {
|
|
42281
|
+
return severity === "error" ? "error" : "warn";
|
|
42282
|
+
}
|
|
42283
|
+
function defaultLevelForRule(rule) {
|
|
42284
|
+
return rule.enabled ? severityToEngineLevel(rule.meta.severity) : "off";
|
|
42285
|
+
}
|
|
42286
|
+
/**
|
|
42287
|
+
* Effective levels for every rule, derived from normalized rules (config
|
|
42288
|
+
* levels, `--deprecated` enables, workspace gating). The engine resolves
|
|
42289
|
+
* purely from these overrides, so dead's config dialect stays in
|
|
42290
|
+
* `normalizeDeadRules` and is never reinterpreted by the engine.
|
|
42291
|
+
*/
|
|
42292
|
+
function deadRuleLevelOverrides(rules) {
|
|
42293
|
+
return Object.fromEntries(rules.map((rule) => [rule.id, rule.enabled ? severityToEngineLevel(rule.meta.severity) : "off"]));
|
|
42294
|
+
}
|
|
42295
|
+
function findingToDiagnostic(finding, level) {
|
|
42296
|
+
return {
|
|
42297
|
+
file: finding.file,
|
|
42298
|
+
level,
|
|
42299
|
+
line: finding.line,
|
|
42300
|
+
message: finding.detail ?? finding.symbol
|
|
42301
|
+
};
|
|
42302
|
+
}
|
|
42303
|
+
function checkDeadRule(rule, ctx, level) {
|
|
42304
|
+
const effective = ctx.analysis.effectiveRules.find((candidate) => candidate.id === rule.id) ?? rule;
|
|
42305
|
+
const findings = [];
|
|
42306
|
+
for (const analysis of ctx.analysis.analyses) {
|
|
42307
|
+
const repoUsage = ctx.analysis.repoUsageByPackageName.get(analysis.packageName) ?? /* @__PURE__ */ new Map();
|
|
42308
|
+
const [enriched] = applyMonorepoUsage([analysis], repoUsage);
|
|
42309
|
+
findings.push(...evaluateRuleForAnalysis(enriched ?? analysis, effective, repoUsage, ctx.analysis.workspaceUsage));
|
|
42310
|
+
}
|
|
42311
|
+
ctx.collected.push(...findings);
|
|
42312
|
+
return { diagnostics: findings.map((finding) => findingToDiagnostic(finding, level)) };
|
|
42313
|
+
}
|
|
42314
|
+
const DEAD_RULE_CHECKS = DEAD_RULES.map((rule) => ({
|
|
42315
|
+
defaultLevel: defaultLevelForRule(rule),
|
|
42316
|
+
description: rule.meta.description,
|
|
42317
|
+
id: rule.id,
|
|
42318
|
+
check: (ctx, { level }) => checkDeadRule(rule, ctx, level)
|
|
42319
|
+
}));
|
|
42320
|
+
function compareFindings(left, right) {
|
|
42321
|
+
return left.pkg.localeCompare(right.pkg) || left.file.localeCompare(right.file) || left.line - right.line || left.column - right.column || left.symbol.localeCompare(right.symbol) || left.rule.localeCompare(right.rule);
|
|
42322
|
+
}
|
|
42323
|
+
/**
|
|
42324
|
+
* Run all dead rules through the shared engine. Findings keep insertion
|
|
42325
|
+
* through the context side-channel, then go through the same
|
|
42326
|
+
* narrowest-scope dedupe as direct evaluation, sorted for stable output.
|
|
42327
|
+
*/
|
|
42328
|
+
async function runDeadChecks(context) {
|
|
42329
|
+
const checkContext = {
|
|
42330
|
+
analysis: context,
|
|
42331
|
+
collected: []
|
|
42332
|
+
};
|
|
42333
|
+
return {
|
|
42334
|
+
exitCode: (await runRuleChecks({
|
|
42335
|
+
commandName: "dead",
|
|
42336
|
+
configKey: "dead",
|
|
42337
|
+
context: checkContext,
|
|
42338
|
+
fix: false,
|
|
42339
|
+
levelOverrides: deadRuleLevelOverrides(context.effectiveRules),
|
|
42340
|
+
rules: DEAD_RULE_CHECKS
|
|
42341
|
+
})).exitCode,
|
|
42342
|
+
findings: dedupeToNarrowestScope(checkContext.collected).toSorted(compareFindings)
|
|
42343
|
+
};
|
|
42344
|
+
}
|
|
42345
|
+
//#endregion
|
|
42169
42346
|
//#region src/actions/dead/runDeadAnalysis.ts
|
|
42170
42347
|
function getPackageFolderCandidates(folder) {
|
|
42171
42348
|
const candidates = [];
|
|
@@ -42312,13 +42489,9 @@ async function buildDeadAnalysisContext(targets, workspace, isVerbose, includeDe
|
|
|
42312
42489
|
};
|
|
42313
42490
|
}
|
|
42314
42491
|
function evaluateFindings(context) {
|
|
42315
|
-
return
|
|
42316
|
-
const repoUsage = context.repoUsageByPackageName.get(analysis.packageName) ?? /* @__PURE__ */ new Map();
|
|
42317
|
-
const [enrichedAnalysis] = applyMonorepoUsage([analysis], repoUsage);
|
|
42318
|
-
return evaluateDeadRules([enrichedAnalysis ?? analysis], context.effectiveRules, repoUsage, context.workspaceUsage);
|
|
42319
|
-
}));
|
|
42492
|
+
return runDeadChecks(context);
|
|
42320
42493
|
}
|
|
42321
|
-
function refreshFindingsAfterRemoval(context) {
|
|
42494
|
+
async function refreshFindingsAfterRemoval(context) {
|
|
42322
42495
|
const refreshedAnalyses = context.targets.map(analyzePackage);
|
|
42323
42496
|
const repoWorkspaces = getPackageManager().listWorkspaces();
|
|
42324
42497
|
const refreshedPropagationAnalyses = buildPropagationAnalyses(refreshedAnalyses, context.targets, repoWorkspaces);
|
|
@@ -42373,7 +42546,7 @@ const dead = async (options = {}) => {
|
|
|
42373
42546
|
const targets = resolveTargets(options.pkg);
|
|
42374
42547
|
if (!targets || targets.length === 0) return errorEnvelope(options.pkg != null && options.pkg.length > 0 ? `Workspace not found: ${options.pkg}` : "No workspaces found");
|
|
42375
42548
|
const context = await buildDeadAnalysisContext(targets, options.workspace, options.verbose === true, options.deprecated === true);
|
|
42376
|
-
let findings = evaluateFindings(context);
|
|
42549
|
+
let { exitCode: checkExitCode, findings } = await evaluateFindings(context);
|
|
42377
42550
|
let fixApplied;
|
|
42378
42551
|
let fixSkipped;
|
|
42379
42552
|
let fixMode;
|
|
@@ -42382,7 +42555,11 @@ const dead = async (options = {}) => {
|
|
|
42382
42555
|
const fixResult = applyDeadFixes(findings, context.analyses, fixMode, options.verbose === true);
|
|
42383
42556
|
fixApplied = fixResult.applied;
|
|
42384
42557
|
fixSkipped = fixResult.skipped;
|
|
42385
|
-
if (fixResult.applied > 0)
|
|
42558
|
+
if (fixResult.applied > 0) {
|
|
42559
|
+
const refreshed = await refreshFindingsAfterRemoval(context);
|
|
42560
|
+
findings = refreshed.findings;
|
|
42561
|
+
checkExitCode = refreshed.exitCode;
|
|
42562
|
+
}
|
|
42386
42563
|
}
|
|
42387
42564
|
const { errorCount, warningCount } = countBySeverity(findings, context.effectiveRules);
|
|
42388
42565
|
const summary = {
|
|
@@ -42407,7 +42584,7 @@ const dead = async (options = {}) => {
|
|
|
42407
42584
|
errorCount,
|
|
42408
42585
|
warningCount
|
|
42409
42586
|
},
|
|
42410
|
-
exitCode:
|
|
42587
|
+
exitCode: checkExitCode
|
|
42411
42588
|
};
|
|
42412
42589
|
};
|
|
42413
42590
|
//#endregion
|
|
@@ -42919,150 +43096,6 @@ function writeToolchainCacheEntry(rootDir) {
|
|
|
42919
43096
|
return true;
|
|
42920
43097
|
}
|
|
42921
43098
|
//#endregion
|
|
42922
|
-
//#region src/actions/ruleRunner.ts
|
|
42923
|
-
const RULE_LEVELS = /* @__PURE__ */ new Set([
|
|
42924
|
-
"error",
|
|
42925
|
-
"off",
|
|
42926
|
-
"warn"
|
|
42927
|
-
]);
|
|
42928
|
-
function isRuleLevel(value) {
|
|
42929
|
-
return typeof value === "string" && RULE_LEVELS.has(value);
|
|
42930
|
-
}
|
|
42931
|
-
function parseRuleLevelSetting(location, setting, defaultLevel) {
|
|
42932
|
-
if (setting === void 0) return defaultLevel;
|
|
42933
|
-
if (typeof setting === "boolean") return setting ? "warn" : "off";
|
|
42934
|
-
if (isRuleLevel(setting)) return setting;
|
|
42935
|
-
if (Array.isArray(setting) && setting.length > 0) {
|
|
42936
|
-
const [level] = setting;
|
|
42937
|
-
if (isRuleLevel(level)) return level;
|
|
42938
|
-
}
|
|
42939
|
-
if (typeof setting === "object" && setting !== null && !Array.isArray(setting)) {
|
|
42940
|
-
const record = setting;
|
|
42941
|
-
if (record.level !== void 0) {
|
|
42942
|
-
if (!isRuleLevel(record.level)) throw new TypeError(`${location}.level must be "error", "warn", or "off"`);
|
|
42943
|
-
return record.level;
|
|
42944
|
-
}
|
|
42945
|
-
if (record.enabled !== void 0) {
|
|
42946
|
-
if (typeof record.enabled !== "boolean") throw new TypeError(`${location}.enabled must be a boolean`);
|
|
42947
|
-
return record.enabled ? defaultLevel : "off";
|
|
42948
|
-
}
|
|
42949
|
-
}
|
|
42950
|
-
throw new TypeError(`${location} must be a rule level, boolean, [level, options], or { level?, enabled? } object`);
|
|
42951
|
-
}
|
|
42952
|
-
function validateConfiguredRuleIds(commandName, configKey, rules, config) {
|
|
42953
|
-
const known = new Set(rules.flatMap((rule) => [rule.id, ...rule.aliases ?? []]));
|
|
42954
|
-
const unknown = Object.keys(config?.rules ?? {}).filter((id) => !known.has(id));
|
|
42955
|
-
if (unknown.length > 0) throw new TypeError(`Unknown ${commandName} rule ${unknown.map((id) => `"${id}"`).join(", ")} in commands.${configKey}.rules`);
|
|
42956
|
-
}
|
|
42957
|
-
function diagnosticsForRule(rule, level, isExplicit, diagnostics) {
|
|
42958
|
-
return (diagnostics ?? []).map((diagnostic) => ({
|
|
42959
|
-
...diagnostic,
|
|
42960
|
-
level: isExplicit ? level : diagnostic.level ?? level,
|
|
42961
|
-
rule: diagnostic.rule ?? rule.id
|
|
42962
|
-
}));
|
|
42963
|
-
}
|
|
42964
|
-
const deprecatedRuleAliasWarnings = /* @__PURE__ */ new Set();
|
|
42965
|
-
function warnDeprecatedRuleAlias(configKey, alias, ruleId) {
|
|
42966
|
-
const key = `${configKey}:${alias}:${ruleId}`;
|
|
42967
|
-
if (deprecatedRuleAliasWarnings.has(key)) return;
|
|
42968
|
-
deprecatedRuleAliasWarnings.add(key);
|
|
42969
|
-
console.warn(chalk.yellow(`Deprecated: commands.${configKey}.rules["${alias}"] is deprecated; use commands.${configKey}.rules["${ruleId}"] instead.`));
|
|
42970
|
-
}
|
|
42971
|
-
function configuredRuleSetting(configKey, rule, config) {
|
|
42972
|
-
const rules = config?.rules;
|
|
42973
|
-
if (rules === void 0) return { setting: void 0 };
|
|
42974
|
-
const setting = rules[rule.id];
|
|
42975
|
-
if (setting !== void 0) return { setting };
|
|
42976
|
-
const aliases = rule.aliases ?? [];
|
|
42977
|
-
for (const alias of aliases) {
|
|
42978
|
-
const aliasSetting = rules[alias];
|
|
42979
|
-
if (aliasSetting === void 0) continue;
|
|
42980
|
-
warnDeprecatedRuleAlias(configKey, alias, rule.id);
|
|
42981
|
-
return { setting: aliasSetting };
|
|
42982
|
-
}
|
|
42983
|
-
return { setting: void 0 };
|
|
42984
|
-
}
|
|
42985
|
-
function resolveRuleLevel(configKey, rule, config) {
|
|
42986
|
-
const { setting } = configuredRuleSetting(configKey, rule, config);
|
|
42987
|
-
return {
|
|
42988
|
-
isExplicit: setting !== void 0,
|
|
42989
|
-
level: parseRuleLevelSetting(ruleConfigPath(configKey, rule.id), setting, rule.defaultLevel)
|
|
42990
|
-
};
|
|
42991
|
-
}
|
|
42992
|
-
function buildRunResult(report, strict) {
|
|
42993
|
-
const errors = report.diagnostics.filter((diagnostic) => diagnostic.level === "error");
|
|
42994
|
-
const warnings = report.diagnostics.filter((diagnostic) => diagnostic.level === "warn");
|
|
42995
|
-
const exitCode = report.errorCount > 0 || strict && report.warningCount > 0 ? 1 : 0;
|
|
42996
|
-
const result = actionResult({
|
|
42997
|
-
errorCount: report.errorCount,
|
|
42998
|
-
exitCode,
|
|
42999
|
-
warningCount: report.warningCount
|
|
43000
|
-
});
|
|
43001
|
-
if (typeof result === "number") return {
|
|
43002
|
-
envelope: {
|
|
43003
|
-
data: report,
|
|
43004
|
-
errorCount: 0,
|
|
43005
|
-
warningCount: 0
|
|
43006
|
-
},
|
|
43007
|
-
exitCode: 0
|
|
43008
|
-
};
|
|
43009
|
-
return {
|
|
43010
|
-
envelope: {
|
|
43011
|
-
...result.envelope,
|
|
43012
|
-
data: report,
|
|
43013
|
-
errors,
|
|
43014
|
-
warnings
|
|
43015
|
-
},
|
|
43016
|
-
exitCode: result.exitCode
|
|
43017
|
-
};
|
|
43018
|
-
}
|
|
43019
|
-
function defaultRuleReporter() {
|
|
43020
|
-
return {
|
|
43021
|
-
diagnostic: (diagnostic) => {
|
|
43022
|
-
const marker = diagnostic.level === "error" ? "✗" : "⚠";
|
|
43023
|
-
const color = diagnostic.level === "error" ? chalk.red : chalk.yellow;
|
|
43024
|
-
console.log(color(` ${marker} ${diagnostic.message}`));
|
|
43025
|
-
},
|
|
43026
|
-
fixed: (rule, fixedCount) => {
|
|
43027
|
-
console.log(chalk.green(` ✔ ${rule.id}: fixed ${fixedCount} issue(s)`));
|
|
43028
|
-
},
|
|
43029
|
-
passed: (rule) => {
|
|
43030
|
-
console.log(chalk.green(` ✓ ${rule.id}`));
|
|
43031
|
-
}
|
|
43032
|
-
};
|
|
43033
|
-
}
|
|
43034
|
-
function recordRuleOutcome(report, rule, diagnostics, fixedCount, reporter) {
|
|
43035
|
-
report.fixedCount += fixedCount;
|
|
43036
|
-
for (const diagnostic of diagnostics) {
|
|
43037
|
-
report.diagnostics.push(diagnostic);
|
|
43038
|
-
if (diagnostic.level === "error") report.errorCount += 1;
|
|
43039
|
-
else report.warningCount += 1;
|
|
43040
|
-
reporter?.diagnostic?.(diagnostic);
|
|
43041
|
-
}
|
|
43042
|
-
if (fixedCount > 0) reporter?.fixed?.(rule, fixedCount);
|
|
43043
|
-
if (fixedCount === 0 && diagnostics.length === 0) reporter?.passed?.(rule);
|
|
43044
|
-
}
|
|
43045
|
-
async function runRuleChecks({ commandName, configKey = commandName, config, context, fix = false, reporter, rules, strict = isStrictMode() }) {
|
|
43046
|
-
validateConfiguredRuleIds(commandName, configKey, rules, config);
|
|
43047
|
-
const report = {
|
|
43048
|
-
diagnostics: [],
|
|
43049
|
-
errorCount: 0,
|
|
43050
|
-
fixedCount: 0,
|
|
43051
|
-
warningCount: 0
|
|
43052
|
-
};
|
|
43053
|
-
for (const rule of rules) {
|
|
43054
|
-
const { isExplicit, level } = resolveRuleLevel(configKey, rule, config);
|
|
43055
|
-
if (level === "off") continue;
|
|
43056
|
-
const outcome = await rule.check(context, {
|
|
43057
|
-
fix,
|
|
43058
|
-
isExplicit,
|
|
43059
|
-
level
|
|
43060
|
-
});
|
|
43061
|
-
recordRuleOutcome(report, rule, diagnosticsForRule(rule, level, isExplicit, outcome.diagnostics), outcome.fixedCount ?? 0, reporter);
|
|
43062
|
-
}
|
|
43063
|
-
return buildRunResult(report, strict);
|
|
43064
|
-
}
|
|
43065
|
-
//#endregion
|
|
43066
43099
|
//#region src/actions/gitlint.ts
|
|
43067
43100
|
const GITLINT_RULES = [
|
|
43068
43101
|
{
|
|
@@ -48028,42 +48061,6 @@ const retest = ({ target } = {}) => {
|
|
|
48028
48061
|
return runSteps("Re-Test", [["vitest", ["--clearCache"]], ["vitest", [target ?? "."]]]);
|
|
48029
48062
|
};
|
|
48030
48063
|
//#endregion
|
|
48031
|
-
//#region src/actions/cleanRuleCatalog.ts
|
|
48032
|
-
async function loadCommandConfig$1(commandName, pkg) {
|
|
48033
|
-
if (pkg !== void 0 && pkg.length > 0) {
|
|
48034
|
-
const workspace = getPackageManager().findWorkspace(pkg);
|
|
48035
|
-
if (workspace === void 0) throw new Error(`Workspace not found: ${pkg}`);
|
|
48036
|
-
return loadWorkspaceCommandConfig(workspace.dir, commandName);
|
|
48037
|
-
}
|
|
48038
|
-
return loadWorkspaceCommandConfig(process.cwd(), commandName);
|
|
48039
|
-
}
|
|
48040
|
-
function sortRules$1(rules) {
|
|
48041
|
-
return rules.toSorted((left, right) => {
|
|
48042
|
-
const command = left.command.localeCompare(right.command);
|
|
48043
|
-
return command === 0 ? left.id.localeCompare(right.id) : command;
|
|
48044
|
-
});
|
|
48045
|
-
}
|
|
48046
|
-
async function getCleanRuleCatalog(pkg) {
|
|
48047
|
-
const resolved = resolveCleanRules(await loadCommandConfig$1("clean", pkg));
|
|
48048
|
-
const hard = CLEAN_HARD_RULES.map((rule) => ({
|
|
48049
|
-
command: RULE_COMMANDS.clean.command,
|
|
48050
|
-
defaultLevel: "error",
|
|
48051
|
-
description: `${rule.description} (always enforced)`,
|
|
48052
|
-
fixable: false,
|
|
48053
|
-
id: rule.id,
|
|
48054
|
-
level: "error"
|
|
48055
|
-
}));
|
|
48056
|
-
const configurable = CLEAN_CONFIGURABLE_RULES.map((rule) => ({
|
|
48057
|
-
command: RULE_COMMANDS.clean.command,
|
|
48058
|
-
defaultLevel: rule.defaultLevel,
|
|
48059
|
-
description: rule.description,
|
|
48060
|
-
fixable: false,
|
|
48061
|
-
id: rule.id,
|
|
48062
|
-
level: rule.id === "clean.gitignored-only" ? resolved.gitignoredOnly : resolved.gitignoredAll
|
|
48063
|
-
}));
|
|
48064
|
-
return sortRules$1([...hard, ...configurable]);
|
|
48065
|
-
}
|
|
48066
|
-
//#endregion
|
|
48067
48064
|
//#region ../../node_modules/.pnpm/ansi-regex@5.0.1/node_modules/ansi-regex/index.js
|
|
48068
48065
|
var require_ansi_regex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
48069
48066
|
module.exports = ({ onlyFirst = false } = {}) => {
|
|
@@ -54017,6 +54014,27 @@ function sortRules(rules) {
|
|
|
54017
54014
|
return command === 0 ? left.id.localeCompare(right.id) : command;
|
|
54018
54015
|
});
|
|
54019
54016
|
}
|
|
54017
|
+
/**
|
|
54018
|
+
* Build catalog entries for rule definitions against user config. Validates
|
|
54019
|
+
* that configured ids are known, then resolves each rule's effective level.
|
|
54020
|
+
*/
|
|
54021
|
+
function runtimeRuleCatalog(command, configKey, definitions, config) {
|
|
54022
|
+
const ruleSettings = config?.rules ?? {};
|
|
54023
|
+
validateConfiguredRuleIds(command, configKey, definitions, config);
|
|
54024
|
+
const resolveSetting = (rule) => {
|
|
54025
|
+
if (ruleSettings[rule.id] !== void 0) return ruleSettings[rule.id];
|
|
54026
|
+
const aliases = rule.aliases ?? [];
|
|
54027
|
+
for (const alias of aliases) if (ruleSettings[alias] !== void 0) return ruleSettings[alias];
|
|
54028
|
+
};
|
|
54029
|
+
return definitions.map((rule) => ({
|
|
54030
|
+
command,
|
|
54031
|
+
defaultLevel: rule.defaultLevel,
|
|
54032
|
+
description: rule.description,
|
|
54033
|
+
fixable: rule.fixable === true,
|
|
54034
|
+
id: rule.id,
|
|
54035
|
+
level: parseRuleLevelSetting(ruleConfigPath(configKey, rule.id), resolveSetting(rule), rule.defaultLevel)
|
|
54036
|
+
}));
|
|
54037
|
+
}
|
|
54020
54038
|
function maxWidth$1(header, values, max = Infinity) {
|
|
54021
54039
|
return Math.min(max, Math.max(header.length, ...values.map((value) => value.length)));
|
|
54022
54040
|
}
|
|
@@ -54131,6 +54149,26 @@ function ruleCatalogResult(rules, title) {
|
|
|
54131
54149
|
};
|
|
54132
54150
|
}
|
|
54133
54151
|
//#endregion
|
|
54152
|
+
//#region src/actions/cleanRuleCatalog.ts
|
|
54153
|
+
async function loadCommandConfig$1(commandName, pkg) {
|
|
54154
|
+
if (pkg !== void 0 && pkg.length > 0) {
|
|
54155
|
+
const workspace = getPackageManager().findWorkspace(pkg);
|
|
54156
|
+
if (workspace === void 0) throw new Error(`Workspace not found: ${pkg}`);
|
|
54157
|
+
return loadWorkspaceCommandConfig(workspace.dir, commandName);
|
|
54158
|
+
}
|
|
54159
|
+
return loadWorkspaceCommandConfig(process.cwd(), commandName);
|
|
54160
|
+
}
|
|
54161
|
+
async function getCleanRuleCatalog(pkg) {
|
|
54162
|
+
const config = await loadCommandConfig$1("clean", pkg);
|
|
54163
|
+
assertCleanConfigurableRules(config);
|
|
54164
|
+
const hard = CLEAN_HARD_RULES.map((rule) => ({
|
|
54165
|
+
defaultLevel: "error",
|
|
54166
|
+
description: `${rule.description} (always enforced)`,
|
|
54167
|
+
id: rule.id
|
|
54168
|
+
}));
|
|
54169
|
+
return sortRules(runtimeRuleCatalog(RULE_COMMANDS.clean.command, "clean", [...hard, ...CLEAN_CONFIGURABLE_RULES], config));
|
|
54170
|
+
}
|
|
54171
|
+
//#endregion
|
|
54134
54172
|
//#region src/actions/secure/dependabotRules.ts
|
|
54135
54173
|
/**
|
|
54136
54174
|
Severity → default level. Alerts are overwhelmingly transitive lockfile
|
|
@@ -55974,25 +56012,6 @@ async function loadCommandConfig(commandName, pkg) {
|
|
|
55974
56012
|
}
|
|
55975
56013
|
return loadWorkspaceCommandConfig(process.cwd(), commandName);
|
|
55976
56014
|
}
|
|
55977
|
-
function runtimeRuleCatalog(command, configKey, definitions, config) {
|
|
55978
|
-
const ruleSettings = config?.rules ?? {};
|
|
55979
|
-
const known = new Set(definitions.flatMap((rule) => [rule.id, ...rule.aliases ?? []]));
|
|
55980
|
-
const unknown = Object.keys(ruleSettings).filter((id) => !known.has(id));
|
|
55981
|
-
if (unknown.length > 0) throw new TypeError(`Unknown ${command} rule ${unknown.map((id) => `"${id}"`).join(", ")} in commands.${configKey}.rules`);
|
|
55982
|
-
const resolveSetting = (rule) => {
|
|
55983
|
-
if (ruleSettings[rule.id] !== void 0) return ruleSettings[rule.id];
|
|
55984
|
-
const aliases = rule.aliases ?? [];
|
|
55985
|
-
for (const alias of aliases) if (ruleSettings[alias] !== void 0) return ruleSettings[alias];
|
|
55986
|
-
};
|
|
55987
|
-
return definitions.map((rule) => ({
|
|
55988
|
-
command,
|
|
55989
|
-
defaultLevel: rule.defaultLevel,
|
|
55990
|
-
description: rule.description,
|
|
55991
|
-
fixable: rule.fixable === true,
|
|
55992
|
-
id: rule.id,
|
|
55993
|
-
level: parseRuleLevelSetting(ruleConfigPath(configKey, rule.id), resolveSetting(rule), rule.defaultLevel)
|
|
55994
|
-
}));
|
|
55995
|
-
}
|
|
55996
56015
|
function commandPrefix(prefix, rules) {
|
|
55997
56016
|
return rules.map((rule) => ({
|
|
55998
56017
|
...rule,
|
|
@@ -57525,11 +57544,6 @@ const enableCommand = {
|
|
|
57525
57544
|
handler: () => {}
|
|
57526
57545
|
};
|
|
57527
57546
|
//#endregion
|
|
57528
|
-
//#region src/xy/deprecatedCommand.ts
|
|
57529
|
-
function warnDeprecatedCommand(oldCommand, newCommand) {
|
|
57530
|
-
console.warn(chalk.yellow(`Deprecated: "xy ${oldCommand}" is deprecated; use "xy ${newCommand}" instead.`));
|
|
57531
|
-
}
|
|
57532
|
-
//#endregion
|
|
57533
57547
|
//#region src/xy/common/gitlintCommand.ts
|
|
57534
57548
|
function gitLintBuilder(yargs) {
|
|
57535
57549
|
return yargs.option("fix", {
|
|
@@ -57559,15 +57573,6 @@ const gitLintCommand = {
|
|
|
57559
57573
|
describe: "Lint git config",
|
|
57560
57574
|
handler: handleGitLintCommand
|
|
57561
57575
|
};
|
|
57562
|
-
const gitlintCommand = {
|
|
57563
|
-
builder: gitLintBuilder,
|
|
57564
|
-
command: "gitlint",
|
|
57565
|
-
describe: "Deprecated: use \"xy git lint\"",
|
|
57566
|
-
handler: async (argv) => {
|
|
57567
|
-
warnDeprecatedCommand("gitlint", "git lint");
|
|
57568
|
-
await handleGitLintCommand(argv);
|
|
57569
|
-
}
|
|
57570
|
-
};
|
|
57571
57576
|
//#endregion
|
|
57572
57577
|
//#region src/xy/common/gitCommand.ts
|
|
57573
57578
|
const gitCommand = {
|
|
@@ -58597,7 +58602,7 @@ const workCommand = {
|
|
|
58597
58602
|
//#region src/xy/common/index.ts
|
|
58598
58603
|
/** Stable common commands registered on both `xy` and `xyex`. */
|
|
58599
58604
|
const xyCommonStableCommands = (args, channel) => {
|
|
58600
|
-
return args.command(checkCommand).command(licenseCommand).command(gitCommand).command(
|
|
58605
|
+
return args.command(checkCommand).command(licenseCommand).command(gitCommand).command(gitignoreCommand).command(npmignoreGenCommand).command(createPackmanCommand(channel)).command(repoCommand).command(retestCommand).command(secureCommand).command(skillsCommand).command(testCommand);
|
|
58601
58606
|
};
|
|
58602
58607
|
const commonExperimentalCommands = [
|
|
58603
58608
|
deadCommand,
|
|
@@ -59040,15 +59045,6 @@ const lintLintSubcommand = {
|
|
|
59040
59045
|
describe: "Check the local ESLint config against toolchain conventions",
|
|
59041
59046
|
handler: handleLintLintCommand
|
|
59042
59047
|
};
|
|
59043
|
-
const lintlintCommand = {
|
|
59044
|
-
builder: lintLintBuilder,
|
|
59045
|
-
command: "lintlint",
|
|
59046
|
-
describe: "Deprecated: use \"xy lint lint\"",
|
|
59047
|
-
handler: async (argv) => {
|
|
59048
|
-
warnDeprecatedCommand("lintlint", "lint lint");
|
|
59049
|
-
await handleLintLintCommand(argv);
|
|
59050
|
-
}
|
|
59051
|
-
};
|
|
59052
59048
|
//#endregion
|
|
59053
59049
|
//#region src/xy/lint/lint/configCommand.ts
|
|
59054
59050
|
const configGetCommand = {
|
|
@@ -59242,15 +59238,6 @@ const nodeLintSubcommand = {
|
|
|
59242
59238
|
describe: "Check volta node pin and package engines.node settings",
|
|
59243
59239
|
handler: handleNodeLintCommand
|
|
59244
59240
|
};
|
|
59245
|
-
const nodeLintCommand = {
|
|
59246
|
-
builder: nodeLintBuilder,
|
|
59247
|
-
command: "node-lint",
|
|
59248
|
-
describe: "Deprecated: use \"xy node lint\"",
|
|
59249
|
-
handler: async (argv) => {
|
|
59250
|
-
warnDeprecatedCommand("node-lint", "node lint");
|
|
59251
|
-
await handleNodeLintCommand(argv);
|
|
59252
|
-
}
|
|
59253
|
-
};
|
|
59254
59241
|
//#endregion
|
|
59255
59242
|
//#region src/xy/lint/nodeCommand.ts
|
|
59256
59243
|
const nodeCommand = {
|
|
@@ -59263,7 +59250,7 @@ const nodeCommand = {
|
|
|
59263
59250
|
};
|
|
59264
59251
|
//#endregion
|
|
59265
59252
|
//#region src/xy/lint/publintCommand.ts
|
|
59266
|
-
const PUBLINT_CHECK_NOTE
|
|
59253
|
+
const PUBLINT_CHECK_NOTE = `Available checks: ${ALL_PUBLINT_CHECKS.join(", ")}. "peerDeps" runs only for all-workspace publint runs.`;
|
|
59267
59254
|
const publintCommand = {
|
|
59268
59255
|
command: "publint [package]",
|
|
59269
59256
|
describe: "Run publint",
|
|
@@ -59274,10 +59261,10 @@ const publintCommand = {
|
|
|
59274
59261
|
default: false
|
|
59275
59262
|
}).option("exclude", {
|
|
59276
59263
|
alias: "e",
|
|
59277
|
-
description: `Checks to skip (comma-separated). ${PUBLINT_CHECK_NOTE
|
|
59264
|
+
description: `Checks to skip (comma-separated). ${PUBLINT_CHECK_NOTE}`,
|
|
59278
59265
|
type: "string"
|
|
59279
59266
|
}).option("include", {
|
|
59280
|
-
description: `Only run these checks (comma-separated). ${PUBLINT_CHECK_NOTE
|
|
59267
|
+
description: `Only run these checks (comma-separated). ${PUBLINT_CHECK_NOTE}`,
|
|
59281
59268
|
type: "string"
|
|
59282
59269
|
}).option("fresh", {
|
|
59283
59270
|
default: false,
|
|
@@ -59324,6 +59311,11 @@ const publintCommand = {
|
|
|
59324
59311
|
}
|
|
59325
59312
|
};
|
|
59326
59313
|
//#endregion
|
|
59314
|
+
//#region src/xy/deprecatedCommand.ts
|
|
59315
|
+
function warnDeprecatedCommand(oldCommand, newCommand) {
|
|
59316
|
+
console.warn(chalk.yellow(`Deprecated: "xy ${oldCommand}" is deprecated; use "xy ${newCommand}" instead.`));
|
|
59317
|
+
}
|
|
59318
|
+
//#endregion
|
|
59327
59319
|
//#region src/xy/lint/relintCommand.ts
|
|
59328
59320
|
const relintCommand = {
|
|
59329
59321
|
command: "relint [package]",
|
|
@@ -59373,55 +59365,6 @@ const relintCommand = {
|
|
|
59373
59365
|
}
|
|
59374
59366
|
};
|
|
59375
59367
|
//#endregion
|
|
59376
|
-
//#region src/xy/lint/republintCommand.ts
|
|
59377
|
-
const PUBLINT_CHECK_NOTE = `Available checks: ${ALL_PUBLINT_CHECKS.join(", ")}. "peerDeps" runs only for all-workspace publint runs.`;
|
|
59378
|
-
const republintCommand = {
|
|
59379
|
-
command: "republint [package]",
|
|
59380
|
-
describe: "Deprecated: use \"xy publint --fresh\"",
|
|
59381
|
-
builder: (yargs) => {
|
|
59382
|
-
return packagePositionalParam(yargs).option("fix", {
|
|
59383
|
-
describe: "Auto-fix XY custom issues before running upstream publint",
|
|
59384
|
-
type: "boolean",
|
|
59385
|
-
default: false
|
|
59386
|
-
}).option("exclude", {
|
|
59387
|
-
alias: "e",
|
|
59388
|
-
description: `Checks to skip (comma-separated). ${PUBLINT_CHECK_NOTE}`,
|
|
59389
|
-
type: "string"
|
|
59390
|
-
}).option("include", {
|
|
59391
|
-
description: `Only run these checks (comma-separated). ${PUBLINT_CHECK_NOTE}`,
|
|
59392
|
-
type: "string"
|
|
59393
|
-
}).option("pack", {
|
|
59394
|
-
description: "Run pack before publint to verify published files (default: true)",
|
|
59395
|
-
type: "boolean"
|
|
59396
|
-
}).option("rules", {
|
|
59397
|
-
default: false,
|
|
59398
|
-
description: "List supported publint checks and their effective levels",
|
|
59399
|
-
type: "boolean"
|
|
59400
|
-
});
|
|
59401
|
-
},
|
|
59402
|
-
handler: async (argv) => {
|
|
59403
|
-
warnDeprecatedCommand("republint", "publint --fresh");
|
|
59404
|
-
if (Boolean(argv.verbose)) console.log("Republint");
|
|
59405
|
-
const pkg = argv.package;
|
|
59406
|
-
if (argv.rules === true) {
|
|
59407
|
-
await withEnvelope("publint rules", async () => ruleCatalogResult(await getPublintRuleCatalog(RULE_COMMANDS.publint.command, pkg), RULE_COMMANDS.publint.title));
|
|
59408
|
-
return;
|
|
59409
|
-
}
|
|
59410
|
-
const parseList = (raw) => raw?.split(",").map((v) => v.trim()).filter(Boolean);
|
|
59411
|
-
await withEnvelope("publint", async () => {
|
|
59412
|
-
return await republint({
|
|
59413
|
-
cliExclude: parseList(argv.exclude),
|
|
59414
|
-
cliInclude: parseList(argv.include),
|
|
59415
|
-
fix: !!Boolean(argv.fix),
|
|
59416
|
-
jobs: argv.jobs,
|
|
59417
|
-
pack: argv.pack,
|
|
59418
|
-
pkg,
|
|
59419
|
-
verbose: !!Boolean(argv.verbose)
|
|
59420
|
-
});
|
|
59421
|
-
});
|
|
59422
|
-
}
|
|
59423
|
-
};
|
|
59424
|
-
//#endregion
|
|
59425
59368
|
//#region src/xy/lint/sonarCommand.ts
|
|
59426
59369
|
const sonarCommand = {
|
|
59427
59370
|
command: "sonar",
|
|
@@ -59437,7 +59380,7 @@ const sonarCommand = {
|
|
|
59437
59380
|
//#endregion
|
|
59438
59381
|
//#region src/xy/lint/index.ts
|
|
59439
59382
|
const xyLintStableCommands = (args) => {
|
|
59440
|
-
return args.command(apiExposureCommand).command(cycleCommand).command(lintCommand).command(
|
|
59383
|
+
return args.command(apiExposureCommand).command(cycleCommand).command(lintCommand).command(deplintCommand).command(nodeCommand).command(fixCommand).command(relintCommand).command(publintCommand);
|
|
59441
59384
|
};
|
|
59442
59385
|
const lintExperimentalCommands = [sonarCommand];
|
|
59443
59386
|
const xyLintExperimentalCommands = (args, channel) => {
|
|
@@ -59560,14 +59503,11 @@ const COMMAND_STABILITY = {
|
|
|
59560
59503
|
"copy-assets": "stable",
|
|
59561
59504
|
"tsc-validate": "experimental",
|
|
59562
59505
|
"lint": "stable",
|
|
59563
|
-
"lintlint": "deprecated",
|
|
59564
59506
|
"fix": "stable",
|
|
59565
59507
|
"relint": "deprecated",
|
|
59566
59508
|
"deplint": "stable",
|
|
59567
59509
|
"node": "stable",
|
|
59568
|
-
"node-lint": "deprecated",
|
|
59569
59510
|
"publint": "stable",
|
|
59570
|
-
"republint": "deprecated",
|
|
59571
59511
|
"api-exposure": "stable",
|
|
59572
59512
|
"cycle": "stable",
|
|
59573
59513
|
"sonar": "experimental",
|
|
@@ -59584,7 +59524,6 @@ const COMMAND_STABILITY = {
|
|
|
59584
59524
|
"dead": "experimental",
|
|
59585
59525
|
"enable": "experimental",
|
|
59586
59526
|
"git": "stable",
|
|
59587
|
-
"gitlint": "deprecated",
|
|
59588
59527
|
"gitignore": "stable",
|
|
59589
59528
|
"npmignore-gen": "stable",
|
|
59590
59529
|
"orphan": "experimental",
|