uilint 0.2.158 → 0.2.160

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.
@@ -27,6 +27,9 @@ import {
27
27
  loadSkill,
28
28
  toInstallSpecifier
29
29
  } from "./chunk-JWSZKDZY.js";
30
+ import {
31
+ loadSelectedRules
32
+ } from "./chunk-EBGFEMCH.js";
30
33
  import {
31
34
  detectPackageManager,
32
35
  installDependencies,
@@ -3017,7 +3020,11 @@ var skillInstaller = {
3017
3020
 
3018
3021
  // src/commands/init/installers/eslint.ts
3019
3022
  import { join as join14 } from "path";
3020
- import { ruleRegistry, getRulesByCategory, getCategoryMeta } from "uilint-eslint";
3023
+ import {
3024
+ ruleRegistry,
3025
+ getRulesByCategory,
3026
+ getCategoryMeta
3027
+ } from "uilint-eslint";
3021
3028
 
3022
3029
  // src/commands/init/installers/ai-hooks.ts
3023
3030
  import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
@@ -3362,8 +3369,12 @@ var eslintInstaller = {
3362
3369
  } else {
3363
3370
  const staticCat = getCategoryMeta("static");
3364
3371
  const semanticCat = getCategoryMeta("semantic");
3365
- log(pc.dim(`
3366
- ${staticCat?.icon ?? "\u{1F4CB}"} ${staticCat?.name ?? "Static rules"} (${staticCat?.description ?? "pattern-based, fast"}):`));
3372
+ log(
3373
+ pc.dim(
3374
+ `
3375
+ ${staticCat?.icon ?? "\u{1F4CB}"} ${staticCat?.name ?? "Static rules"} (${staticCat?.description ?? "pattern-based, fast"}):`
3376
+ )
3377
+ );
3367
3378
  const selectedStaticIds = await multiselect({
3368
3379
  message: "Select static rules to enable:",
3369
3380
  options: staticRules.map(formatRuleOption),
@@ -3378,13 +3389,17 @@ ${staticCat?.icon ?? "\u{1F4CB}"} ${staticCat?.name ?? "Static rules"} (${static
3378
3389
  let selectedSemanticIds = [];
3379
3390
  if (includeSemanticRules) {
3380
3391
  log(
3381
- pc.dim(`
3382
- ${semanticCat?.icon ?? "\u{1F9E0}"} ${semanticCat?.name ?? "Semantic rules"} (${semanticCat?.description ?? "LLM-powered, slower"}):`)
3392
+ pc.dim(
3393
+ `
3394
+ ${semanticCat?.icon ?? "\u{1F9E0}"} ${semanticCat?.name ?? "Semantic rules"} (${semanticCat?.description ?? "LLM-powered, slower"}):`
3395
+ )
3383
3396
  );
3384
3397
  selectedSemanticIds = await multiselect({
3385
3398
  message: "Select semantic rules:",
3386
3399
  options: semanticRules.map(formatRuleOption),
3387
- initialValues: semanticRules.filter((r) => r.defaultEnabled ?? semanticCat?.defaultEnabled ?? false).map((r) => r.id)
3400
+ initialValues: semanticRules.filter(
3401
+ (r) => r.defaultEnabled ?? semanticCat?.defaultEnabled ?? false
3402
+ ).map((r) => r.id)
3388
3403
  });
3389
3404
  }
3390
3405
  selectedRuleIds = [...selectedStaticIds, ...selectedSemanticIds];
@@ -3476,7 +3491,9 @@ ${semanticCat?.icon ?? "\u{1F9E0}"} ${semanticCat?.name ?? "Semantic rules"} (${
3476
3491
  }
3477
3492
  if (cr.rule.postInstallInstructions) {
3478
3493
  log(
3479
- pc.cyan(` \u2139\uFE0F ${cr.rule.name}: ${cr.rule.postInstallInstructions}`)
3494
+ pc.cyan(
3495
+ ` \u2139\uFE0F ${cr.rule.name}: ${cr.rule.postInstallInstructions}`
3496
+ )
3480
3497
  );
3481
3498
  }
3482
3499
  }
@@ -3512,7 +3529,9 @@ ${semanticCat?.icon ?? "\u{1F9E0}"} ${semanticCat?.name ?? "Semantic rules"} (${
3512
3529
  initialValues: [],
3513
3530
  required: false
3514
3531
  });
3515
- aiHooks = selectedHooks.filter((h) => h === "claude" || h === "cursor");
3532
+ aiHooks = selectedHooks.filter(
3533
+ (h) => h === "claude" || h === "cursor"
3534
+ );
3516
3535
  if (aiHooks.length > 0) {
3517
3536
  log(
3518
3537
  pc.dim(` \u2192 Will install hooks for: ${aiHooks.join(", ")}`)
@@ -3543,6 +3562,53 @@ ${semanticCat?.icon ?? "\u{1F9E0}"} ${semanticCat?.name ?? "Semantic rules"} (${
3543
3562
  type: "create_directory",
3544
3563
  path: rulesDir
3545
3564
  });
3565
+ const localRules = configuredRules.filter(
3566
+ (cr) => !cr.rule.eslintImport && !cr.rule.plugin
3567
+ );
3568
+ const isTypeScriptConfig = pkgInfo.eslintConfigPath.endsWith(".ts");
3569
+ const ruleFiles = loadSelectedRules(
3570
+ localRules.map((cr) => cr.rule.id),
3571
+ { typescript: isTypeScriptConfig }
3572
+ );
3573
+ for (const ruleFile of ruleFiles) {
3574
+ if (ruleFile.additionalFiles && ruleFile.additionalFiles.length > 0) {
3575
+ const ruleDir = join14(rulesDir, ruleFile.ruleId);
3576
+ actions.push({
3577
+ type: "create_directory",
3578
+ path: ruleDir
3579
+ });
3580
+ const hasLibFiles = ruleFile.additionalFiles.some(
3581
+ (f) => f.relativePath.includes("/lib/")
3582
+ );
3583
+ if (hasLibFiles) {
3584
+ actions.push({
3585
+ type: "create_directory",
3586
+ path: join14(ruleDir, "lib")
3587
+ });
3588
+ }
3589
+ }
3590
+ actions.push({
3591
+ type: "create_file",
3592
+ path: join14(rulesDir, ruleFile.implementation.relativePath),
3593
+ content: ruleFile.implementation.content
3594
+ });
3595
+ if (ruleFile.additionalFiles) {
3596
+ for (const additionalFile of ruleFile.additionalFiles) {
3597
+ actions.push({
3598
+ type: "create_file",
3599
+ path: join14(rulesDir, additionalFile.relativePath),
3600
+ content: additionalFile.content
3601
+ });
3602
+ }
3603
+ }
3604
+ if (ruleFile.test && isTypeScriptConfig) {
3605
+ actions.push({
3606
+ type: "create_file",
3607
+ path: join14(rulesDir, ruleFile.test.relativePath),
3608
+ content: ruleFile.test.content
3609
+ });
3610
+ }
3611
+ }
3546
3612
  const ruleNpmDeps = /* @__PURE__ */ new Set();
3547
3613
  for (const cr of configuredRules) {
3548
3614
  if (cr.rule.npmDependencies) {
@@ -3586,6 +3652,15 @@ ${semanticCat?.icon ?? "\u{1F9E0}"} ${semanticCat?.name ?? "Semantic rules"} (${
3586
3652
  rules: rulesWithSeverity,
3587
3653
  hasExistingRules: pkgInfo.hasUilintRules
3588
3654
  });
3655
+ const ruleVersions = {};
3656
+ for (const cr of configuredRules) {
3657
+ ruleVersions[cr.rule.id] = cr.rule.version ?? "1.0.0";
3658
+ }
3659
+ actions.push({
3660
+ type: "update_manifest",
3661
+ projectPath: target.path,
3662
+ rules: ruleVersions
3663
+ });
3589
3664
  }
3590
3665
  const gitignorePath = join14(project.workspaceRoot, ".gitignore");
3591
3666
  actions.push({
@@ -4167,4 +4242,4 @@ export {
4167
4242
  execute,
4168
4243
  getInjectionPoints
4169
4244
  };
4170
- //# sourceMappingURL=chunk-5EDE3J6O.js.map
4245
+ //# sourceMappingURL=chunk-UDLE6YHE.js.map