pasika 0.10.106 → 0.10.108

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.
@@ -38,8 +38,8 @@ function memberPropertyName(node) {
38
38
  }
39
39
  return void 0;
40
40
  }
41
- function importedContractMember(expression, propertyName6, imports) {
42
- if (expression?.type !== "MemberExpression" || memberPropertyName(expression) !== propertyName6 || expression.object.type !== "Identifier" || !imports.has(expression.object.name)) {
41
+ function importedContractMember(expression, propertyName7, imports) {
42
+ if (expression?.type !== "MemberExpression" || memberPropertyName(expression) !== propertyName7 || expression.object.type !== "Identifier" || !imports.has(expression.object.name)) {
43
43
  return void 0;
44
44
  }
45
45
  return expression.object.name;
@@ -5727,6 +5727,69 @@ function getSemanticLiteralIndex(index) {
5727
5727
  return result;
5728
5728
  }
5729
5729
 
5730
+ // eslint/rules/next-font-literals.ts
5731
+ var fontLoaderOptions = /* @__PURE__ */ new Set([
5732
+ "subsets",
5733
+ "weight",
5734
+ "style",
5735
+ "display",
5736
+ "variable",
5737
+ "fallback",
5738
+ "adjustFontFallback",
5739
+ "axes",
5740
+ "src",
5741
+ "declarations"
5742
+ ]);
5743
+ function propertyName3(key) {
5744
+ if (typeof key !== "object" || key === null || !("type" in key)) return void 0;
5745
+ if (key.type === "Identifier" && "name" in key && typeof key.name === "string") return key.name;
5746
+ if (key.type === "Literal" && "value" in key && typeof key.value === "string") return key.value;
5747
+ return void 0;
5748
+ }
5749
+ function isImportedNextFont(context, node, callee) {
5750
+ if (typeof callee !== "object" || callee === null || !("type" in callee) || callee.type !== "Identifier" || !("name" in callee) || typeof callee.name !== "string") {
5751
+ return false;
5752
+ }
5753
+ let scope = context.sourceCode.getScope(node);
5754
+ for (; ; ) {
5755
+ const variable = scope.set.get(callee.name);
5756
+ if (variable) {
5757
+ return variable.defs.some((definition) => {
5758
+ if (definition.type !== "ImportBinding") return false;
5759
+ const module = definition.parent.source.value;
5760
+ return module === "next/font/google" && definition.node.type === "ImportSpecifier" || module === "next/font/local" && definition.node.type === "ImportDefaultSpecifier";
5761
+ });
5762
+ }
5763
+ if (scope.upper === null) return false;
5764
+ scope = scope.upper;
5765
+ }
5766
+ }
5767
+ function isStaticNextFontLiteral(node, context) {
5768
+ let current = node;
5769
+ let option;
5770
+ while (current.parent) {
5771
+ const parent = current.parent;
5772
+ if (parent.type === "ArrayExpression" && Array.isArray(parent.elements) && parent.elements.includes(current)) {
5773
+ current = parent;
5774
+ continue;
5775
+ }
5776
+ if (parent.type === "Property" && parent.value === current && parent.computed === false) {
5777
+ const owner = parent.parent;
5778
+ if (owner?.type === "ObjectExpression" && owner.parent?.type === "CallExpression") {
5779
+ option = propertyName3(parent.key);
5780
+ }
5781
+ current = parent;
5782
+ continue;
5783
+ }
5784
+ if (parent.type === "ObjectExpression" && Array.isArray(parent.properties) && parent.properties.includes(current)) {
5785
+ current = parent;
5786
+ continue;
5787
+ }
5788
+ return parent.type === "CallExpression" && current.type === "ObjectExpression" && Array.isArray(parent.arguments) && parent.arguments[0] === current && option !== void 0 && fontLoaderOptions.has(option) && isImportedNextFont(context, node, parent.callee);
5789
+ }
5790
+ return false;
5791
+ }
5792
+
5730
5793
  // eslint/rules/no-inline-runtime-literal.ts
5731
5794
  var DOC5 = "See docs/next-codebase-guide/rules/constants-rule.md";
5732
5795
  var MESSAGE2 = `Every runtime string or numeric value must use a named constant or enum member, including single-use values. Inline JSX className/data-component, canonical locale strings, and static Next.js matchers are exempt. ${DOC5}`;
@@ -5849,7 +5912,7 @@ var noInlineRuntimeLiteralRule = {
5849
5912
  if (typeof node.value !== "string" && typeof node.value !== "number" && typeof node.value !== "bigint" && !("bigint" in node && typeof node.bigint === "string")) {
5850
5913
  return;
5851
5914
  }
5852
- if (typeof node.value === "string" && (isClassNameProp(node) || isStaticDataComponentMarker(node) || isCanonicalLocaleString(node, root, file)) || isStaticMatcherValue(node, root, file) || isNamedValue(node) || isSyntacticString(node)) {
5915
+ if (typeof node.value === "string" && (isClassNameProp(node) || isStaticDataComponentMarker(node) || isCanonicalLocaleString(node, root, file)) || isStaticMatcherValue(node, root, file) || isStaticNextFontLiteral(node, context) || isNamedValue(node) || isSyntacticString(node)) {
5853
5916
  return;
5854
5917
  }
5855
5918
  context.report({ node, message: MESSAGE2 });
@@ -5888,7 +5951,7 @@ function isStaticValue(value) {
5888
5951
  }
5889
5952
  return false;
5890
5953
  }
5891
- function propertyName3(property) {
5954
+ function propertyName4(property) {
5892
5955
  if (!property.computed && property.key.type === "Identifier") return property.key.name;
5893
5956
  if (property.key.type === "Literal" && typeof property.key.value === "string") return property.key.value;
5894
5957
  return void 0;
@@ -5896,7 +5959,7 @@ function propertyName3(property) {
5896
5959
  function findStaticDeclaration(expression) {
5897
5960
  for (const property of expression.properties) {
5898
5961
  if (property.type !== "Property" || property.kind !== "init") continue;
5899
- const name = propertyName3(property);
5962
+ const name = propertyName4(property);
5900
5963
  if (!name) continue;
5901
5964
  if (isStaticValue(property.value)) return name;
5902
5965
  }
@@ -6136,7 +6199,7 @@ function endpointOwnership(pathValue) {
6136
6199
  function resolvedSymbol(checker, symbol) {
6137
6200
  return symbol.flags === ts10.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
6138
6201
  }
6139
- function propertyName4(node) {
6202
+ function propertyName5(node) {
6140
6203
  if (!node) return void 0;
6141
6204
  if (ts10.isIdentifier(node) || ts10.isStringLiteral(node) || ts10.isNumericLiteral(node)) return node.text;
6142
6205
  return void 0;
@@ -6292,7 +6355,7 @@ var ContractOwnershipIndex = class {
6292
6355
  const schemaExpressions = [];
6293
6356
  for (const property of argument.properties) {
6294
6357
  if (ts10.isPropertyAssignment(property)) {
6295
- const name = propertyName4(property.name);
6358
+ const name = propertyName5(property.name);
6296
6359
  if (name === "path") pathExpression = property.initializer;
6297
6360
  if (name === "requestSchema" || name === "responseSchema") schemaExpressions.push(property.initializer);
6298
6361
  continue;
@@ -6446,9 +6509,9 @@ function aliasMessage(alias, source) {
6446
6509
  function bindingAliasMessage(alias, source) {
6447
6510
  return `"${alias}" renames "${source}" while creating a binding. Keep the original name and map it only at the object boundary. ${DOC6}`;
6448
6511
  }
6449
- function objectPropertyMessage(propertyName6, source) {
6450
- if (source === propertyName6) return `Use property shorthand for "${propertyName6}". ${DOC6}`;
6451
- return `"${propertyName6}" maps the local "${source}". Keep the local name or map directly from its source object instead. ${DOC6}`;
6512
+ function objectPropertyMessage(propertyName7, source) {
6513
+ if (source === propertyName7) return `Use property shorthand for "${propertyName7}". ${DOC6}`;
6514
+ return `"${propertyName7}" maps the local "${source}". Keep the local name or map directly from its source object instead. ${DOC6}`;
6452
6515
  }
6453
6516
  function normalizePropertyName(name) {
6454
6517
  return name.replace(/[-_\s]/g, "").toLowerCase();
@@ -6461,12 +6524,12 @@ function memberPropertyName2(node) {
6461
6524
  }
6462
6525
  return void 0;
6463
6526
  }
6464
- function isNamedMemberValue(propertyName6) {
6465
- return /^[A-Z]/.test(propertyName6);
6527
+ function isNamedMemberValue(propertyName7) {
6528
+ return /^[A-Z]/.test(propertyName7);
6466
6529
  }
6467
- function isQualifiedSourceField(propertyName6, sourceMember, sourcePropertyName) {
6530
+ function isQualifiedSourceField(propertyName7, sourceMember, sourcePropertyName) {
6468
6531
  if (sourceMember.type !== "MemberExpression" || sourceMember.object.type !== "Identifier") return false;
6469
- return normalizePropertyName(propertyName6) === normalizePropertyName(`${sourceMember.object.name}${sourcePropertyName}`);
6532
+ return normalizePropertyName(propertyName7) === normalizePropertyName(`${sourceMember.object.name}${sourcePropertyName}`);
6470
6533
  }
6471
6534
  function isInsideSchemaDeclaration(node) {
6472
6535
  let current = node;
@@ -6478,11 +6541,11 @@ function isInsideSchemaDeclaration(node) {
6478
6541
  }
6479
6542
  return false;
6480
6543
  }
6481
- function semanticMappingMessage(propertyName6, sourcePropertyName) {
6482
- return `"${propertyName6}" maps from "${sourcePropertyName}" between first-party contracts. Use one canonical field name across the contracts. ${DOC6}`;
6544
+ function semanticMappingMessage(propertyName7, sourcePropertyName) {
6545
+ return `"${propertyName7}" maps from "${sourcePropertyName}" between first-party contracts. Use one canonical field name across the contracts. ${DOC6}`;
6483
6546
  }
6484
- function unknownContractOwnershipMessage(propertyName6, sourcePropertyName) {
6485
- return `Cannot determine contract ownership for mapping "${propertyName6}" from "${sourcePropertyName}". Define or propagate a concrete contract, make the boundary schema explicit, or connect a mirrored external schema to its defineApiContract. ${DOC6}`;
6547
+ function unknownContractOwnershipMessage(propertyName7, sourcePropertyName) {
6548
+ return `Cannot determine contract ownership for mapping "${propertyName7}" from "${sourcePropertyName}". Define or propagate a concrete contract, make the boundary schema explicit, or connect a mirrored external schema to its defineApiContract. ${DOC6}`;
6486
6549
  }
6487
6550
  function destructuredBindingSource(context, identifier) {
6488
6551
  const initialScope = context.sourceCode.getScope(identifier);
@@ -6509,7 +6572,7 @@ function destructuredBindingSource(context, identifier) {
6509
6572
  }
6510
6573
  return void 0;
6511
6574
  }
6512
- function contractMappingViolation(propertyName6, sourcePropertyName, sourceResolution, targetResolution) {
6575
+ function contractMappingViolation(propertyName7, sourcePropertyName, sourceResolution, targetResolution) {
6513
6576
  if (sourceResolution.kind === "non-contract" || targetResolution.kind === "non-contract") return void 0;
6514
6577
  if ((sourceResolution.ownership === "third-party" || sourceResolution.ownership === "platform") && targetResolution.kind !== "missing") {
6515
6578
  return void 0;
@@ -6520,11 +6583,11 @@ function contractMappingViolation(propertyName6, sourcePropertyName, sourceResol
6520
6583
  const hasDataContract = sourceResolution.kind === "data-contract" || targetResolution.kind === "data-contract";
6521
6584
  if (!hasDataContract) return void 0;
6522
6585
  if (sourceResolution.kind === "missing" || targetResolution.kind === "missing" || sourceResolution.ownership === "unknown" || targetResolution.ownership === "unknown") {
6523
- return unknownContractOwnershipMessage(propertyName6, sourcePropertyName);
6586
+ return unknownContractOwnershipMessage(propertyName7, sourcePropertyName);
6524
6587
  }
6525
6588
  if (sourceResolution.kind !== "data-contract") return void 0;
6526
6589
  if (sourceResolution.ownership !== "first-party" || targetResolution.ownership !== "first-party") return void 0;
6527
- return semanticMappingMessage(propertyName6, sourcePropertyName);
6590
+ return semanticMappingMessage(propertyName7, sourcePropertyName);
6528
6591
  }
6529
6592
  var noRedundantAliasRule = {
6530
6593
  meta: {
@@ -6553,14 +6616,14 @@ var noRedundantAliasRule = {
6553
6616
  return;
6554
6617
  }
6555
6618
  if (node.init.type !== "MemberExpression") return;
6556
- let propertyName6;
6619
+ let propertyName7;
6557
6620
  if (!node.init.computed && node.init.property.type === "Identifier") {
6558
- propertyName6 = node.init.property.name;
6621
+ propertyName7 = node.init.property.name;
6559
6622
  }
6560
6623
  if (node.init.computed && node.init.property.type === "Literal" && typeof node.init.property.value === "string") {
6561
- propertyName6 = node.init.property.value;
6624
+ propertyName7 = node.init.property.value;
6562
6625
  }
6563
- if (propertyName6 === void 0 || propertyName6 === node.id.name) return;
6626
+ if (propertyName7 === void 0 || propertyName7 === node.id.name) return;
6564
6627
  context.report({
6565
6628
  node,
6566
6629
  message: bindingAliasMessage(node.id.name, context.sourceCode.getText(node.init))
@@ -6568,22 +6631,22 @@ var noRedundantAliasRule = {
6568
6631
  },
6569
6632
  Property(node) {
6570
6633
  if (node.computed) return;
6571
- let propertyName6;
6572
- if (node.key.type === "Identifier") propertyName6 = node.key.name;
6634
+ let propertyName7;
6635
+ if (node.key.type === "Identifier") propertyName7 = node.key.name;
6573
6636
  if (node.key.type === "Literal" && typeof node.key.value === "string") {
6574
- propertyName6 = node.key.value;
6637
+ propertyName7 = node.key.value;
6575
6638
  }
6576
- if (propertyName6 === void 0) return;
6639
+ if (propertyName7 === void 0) return;
6577
6640
  if (node.parent.type === "ObjectPattern") {
6578
6641
  let binding;
6579
6642
  if (node.value.type === "Identifier") binding = node.value;
6580
6643
  if (node.value.type === "AssignmentPattern" && node.value.left.type === "Identifier") {
6581
6644
  binding = node.value.left;
6582
6645
  }
6583
- if (!binding || binding.name === propertyName6) return;
6646
+ if (!binding || binding.name === propertyName7) return;
6584
6647
  context.report({
6585
6648
  node,
6586
- message: bindingAliasMessage(binding.name, propertyName6)
6649
+ message: bindingAliasMessage(binding.name, propertyName7)
6587
6650
  });
6588
6651
  return;
6589
6652
  }
@@ -6592,12 +6655,12 @@ var noRedundantAliasRule = {
6592
6655
  if (node.value.type === "Identifier") {
6593
6656
  if (node.shorthand) return;
6594
6657
  const source = node.value.name;
6595
- if (propertyName6 === source) {
6658
+ if (propertyName7 === source) {
6596
6659
  context.report({
6597
6660
  node,
6598
- message: objectPropertyMessage(propertyName6, source),
6661
+ message: objectPropertyMessage(propertyName7, source),
6599
6662
  fix(fixer) {
6600
- return fixer.replaceText(node, propertyName6);
6663
+ return fixer.replaceText(node, propertyName7);
6601
6664
  }
6602
6665
  });
6603
6666
  return;
@@ -6605,29 +6668,29 @@ var noRedundantAliasRule = {
6605
6668
  const bindingSource = destructuredBindingSource(context, node.value);
6606
6669
  if (!bindingSource || !ownershipResolver) return;
6607
6670
  const sourcePropertyName2 = bindingSource.propertyName;
6608
- if (normalizePropertyName(propertyName6) === normalizePropertyName(sourcePropertyName2)) return;
6609
- if (FRAMEWORK_MAPPING_KEYS.has(propertyName6) || isNamedMemberValue(sourcePropertyName2)) return;
6671
+ if (normalizePropertyName(propertyName7) === normalizePropertyName(sourcePropertyName2)) return;
6672
+ if (FRAMEWORK_MAPPING_KEYS.has(propertyName7) || isNamedMemberValue(sourcePropertyName2)) return;
6610
6673
  const sourceResolution2 = ownershipResolver.sourceBinding(bindingSource.declarator, sourcePropertyName2);
6611
- const targetResolution2 = ownershipResolver.targetProperty(node, propertyName6);
6674
+ const targetResolution2 = ownershipResolver.targetProperty(node, propertyName7);
6612
6675
  const hasDataContract = sourceResolution2.kind === "data-contract" || targetResolution2.kind === "data-contract";
6613
6676
  if (!hasDataContract) return;
6614
6677
  context.report({
6615
6678
  node,
6616
- message: contractMappingViolation(propertyName6, sourcePropertyName2, sourceResolution2, targetResolution2) ?? objectPropertyMessage(propertyName6, source)
6679
+ message: contractMappingViolation(propertyName7, sourcePropertyName2, sourceResolution2, targetResolution2) ?? objectPropertyMessage(propertyName7, source)
6617
6680
  });
6618
6681
  return;
6619
6682
  }
6620
6683
  if (node.value.type !== "MemberExpression") return;
6621
6684
  const sourcePropertyName = memberPropertyName2(node.value);
6622
6685
  if (sourcePropertyName === void 0) return;
6623
- if (normalizePropertyName(propertyName6) === normalizePropertyName(sourcePropertyName)) return;
6624
- if (FRAMEWORK_MAPPING_KEYS.has(propertyName6) || isNamedMemberValue(sourcePropertyName)) return;
6625
- if (isQualifiedSourceField(propertyName6, node.value, sourcePropertyName)) return;
6686
+ if (normalizePropertyName(propertyName7) === normalizePropertyName(sourcePropertyName)) return;
6687
+ if (FRAMEWORK_MAPPING_KEYS.has(propertyName7) || isNamedMemberValue(sourcePropertyName)) return;
6688
+ if (isQualifiedSourceField(propertyName7, node.value, sourcePropertyName)) return;
6626
6689
  if (!ownershipResolver) return;
6627
6690
  const sourceResolution = ownershipResolver.sourceMember(node.value);
6628
- const targetResolution = ownershipResolver.targetProperty(node, propertyName6);
6691
+ const targetResolution = ownershipResolver.targetProperty(node, propertyName7);
6629
6692
  const violation = contractMappingViolation(
6630
- propertyName6,
6693
+ propertyName7,
6631
6694
  sourcePropertyName,
6632
6695
  sourceResolution,
6633
6696
  targetResolution
@@ -7230,7 +7293,7 @@ function isZodCall(node, method) {
7230
7293
  const { callee } = node;
7231
7294
  return callee?.type === "MemberExpression" && !callee.computed && callee.object.type === "Identifier" && callee.object.name === "z" && callee.property.type === "Identifier" && callee.property.name === method;
7232
7295
  }
7233
- function propertyName5(property) {
7296
+ function propertyName6(property) {
7234
7297
  if (property.computed) return void 0;
7235
7298
  if (property.key.type === "Identifier") return property.key.name;
7236
7299
  if (property.key.type === "Literal" && typeof property.key.value === "string") return property.key.value;
@@ -7241,7 +7304,7 @@ function rawZodDiscriminantLiteral(schemaCall, discriminator) {
7241
7304
  const shape = schemaCall.arguments[0];
7242
7305
  if (shape?.type !== "ObjectExpression") return void 0;
7243
7306
  for (const property of shape.properties) {
7244
- if (property.type !== "Property" || propertyName5(property) !== discriminator) continue;
7307
+ if (property.type !== "Property" || propertyName6(property) !== discriminator) continue;
7245
7308
  if (property.value.type !== "CallExpression" || !isZodCall(property.value, "literal")) return void 0;
7246
7309
  const literal = property.value.arguments[0];
7247
7310
  if (literal?.type === "Literal" && (typeof literal.value === "string" || typeof literal.value === "number")) {
@@ -7405,19 +7468,19 @@ function directPropertyBinding(context, declarator, isEnumValue) {
7405
7468
  if (member.computed || member.optional || member.property.type !== "Identifier") return void 0;
7406
7469
  if (!memberCanBecomeLocal(member)) return void 0;
7407
7470
  if (context.sourceCode.getCommentsInside(declarator).length > 0) return void 0;
7408
- const propertyName6 = member.property.name;
7471
+ const propertyName7 = member.property.name;
7409
7472
  const localName = declarator.id.name;
7410
- if (propertyName6 !== localName) return void 0;
7473
+ if (propertyName7 !== localName) return void 0;
7411
7474
  const source = member.object;
7412
7475
  const sourceText = context.sourceCode.getText(source);
7413
7476
  return {
7414
7477
  declarator,
7415
7478
  member,
7416
- propertyName: propertyName6,
7479
+ propertyName: propertyName7,
7417
7480
  localName,
7418
7481
  source,
7419
7482
  sourceText,
7420
- bindingText: propertyName6
7483
+ bindingText: propertyName7
7421
7484
  };
7422
7485
  }
7423
7486
  function canGroupSource(source) {
@@ -7435,8 +7498,8 @@ function rootIdentifierName(node) {
7435
7498
  if (node.type !== "MemberExpression" || node.object.type === "Super") return void 0;
7436
7499
  return rootIdentifierName(node.object);
7437
7500
  }
7438
- function isCompliantLocalName(propertyName6) {
7439
- return !propertyName6.includes("_") || /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/u.test(propertyName6);
7501
+ function isCompliantLocalName(propertyName7) {
7502
+ return !propertyName7.includes("_") || /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/u.test(propertyName7);
7440
7503
  }
7441
7504
  function propertyNameOf(node) {
7442
7505
  if (node.type !== "Property" || node.computed) return void 0;
@@ -7558,10 +7621,10 @@ function recordMemberUsage(context, scope, ownershipResolver, member, isEnumValu
7558
7621
  if (!isGroupedUsageSource(member.object) || !memberIsRead(context, member, detachableCall)) return;
7559
7622
  const sourceText = context.sourceCode.getText(member.object);
7560
7623
  const usage = objectUsage(scope, sourceText);
7561
- const propertyName6 = member.property.name;
7562
- usage.propertyNames.add(propertyName6);
7624
+ const propertyName7 = member.property.name;
7625
+ usage.propertyNames.add(propertyName7);
7563
7626
  if (!memberIsDirectVariableInitializer(context, member)) {
7564
- usage.directMembers.push({ member, propertyName: propertyName6 });
7627
+ usage.directMembers.push({ member, propertyName: propertyName7 });
7565
7628
  }
7566
7629
  }
7567
7630
  function recordDestructuringUsage(context, scope, declaration, isEnumValue) {
@@ -7688,13 +7751,13 @@ function groupedDestructuringSelections(context, first, isEnumValue) {
7688
7751
  if (!previous || nextNode?.type !== "VariableDeclaration" || nextNode.kind !== first.declaration.kind) break;
7689
7752
  const next = destructuringSelection(context, nextNode, isEnumValue);
7690
7753
  if (next?.sourceText !== first.sourceText) break;
7691
- if (next.propertyNames.some((propertyName6) => seenProperties.has(propertyName6))) break;
7754
+ if (next.propertyNames.some((propertyName7) => seenProperties.has(propertyName7))) break;
7692
7755
  const [, previousEnd] = context.sourceCode.getRange(previous);
7693
7756
  const [nextStart] = context.sourceCode.getRange(nextNode);
7694
7757
  const gap = context.sourceCode.text.slice(previousEnd, nextStart);
7695
7758
  if (!whitespaceKeepsStatementsAdjacent(gap)) break;
7696
7759
  group.push(next);
7697
- for (const propertyName6 of next.propertyNames) seenProperties.add(propertyName6);
7760
+ for (const propertyName7 of next.propertyNames) seenProperties.add(propertyName7);
7698
7761
  }
7699
7762
  return group;
7700
7763
  }
@@ -7748,9 +7811,9 @@ var preferObjectDestructuringRule = {
7748
7811
  const { member: firstDirectMember } = firstDirectUsage;
7749
7812
  const propertyNames = [...usage.propertyNames];
7750
7813
  const missingPropertyNames = propertyNames.filter(
7751
- (propertyName6) => !usage.destructuring?.propertyNames.has(propertyName6)
7814
+ (propertyName7) => !usage.destructuring?.propertyNames.has(propertyName7)
7752
7815
  );
7753
- if (missingPropertyNames.some((propertyName6) => hasBinding(context, firstDirectMember, propertyName6))) {
7816
+ if (missingPropertyNames.some((propertyName7) => hasBinding(context, firstDirectMember, propertyName7))) {
7754
7817
  continue;
7755
7818
  }
7756
7819
  context.report({
@@ -7764,7 +7827,7 @@ var preferObjectDestructuringRule = {
7764
7827
  return null;
7765
7828
  }
7766
7829
  const memberFixes = usage.directMembers.map(
7767
- ({ member, propertyName: propertyName6 }) => fixer.replaceText(member, propertyName6)
7830
+ ({ member, propertyName: propertyName7 }) => fixer.replaceText(member, propertyName7)
7768
7831
  );
7769
7832
  if (usage.destructuring) {
7770
7833
  if (missingPropertyNames.length === 0) return memberFixes;
@@ -7803,7 +7866,7 @@ ${indentation}`;
7803
7866
  continue;
7804
7867
  }
7805
7868
  if (fromSameSource.length > 1) {
7806
- const names = new Set(fromSameSource.map(({ propertyName: propertyName6 }) => propertyName6));
7869
+ const names = new Set(fromSameSource.map(({ propertyName: propertyName7 }) => propertyName7));
7807
7870
  if (names.size > 1) {
7808
7871
  context.report({ node: binding.node, message: scopeUsageMessage(binding.sourceText, names) });
7809
7872
  continue;
@@ -7843,12 +7906,12 @@ ${indentation}`;
7843
7906
  if (group.length <= 1) {
7844
7907
  if (node.kind === "const" && selection.propertyNames.length === 1 && supportsSinglePropertySource(selection.source)) {
7845
7908
  const declarator = node.declarations[0];
7846
- const propertyName6 = selection.propertyNames[0];
7847
- if (declarator && propertyName6) {
7909
+ const propertyName7 = selection.propertyNames[0];
7910
+ if (declarator && propertyName7) {
7848
7911
  currentUsageScope()?.singleProperties.push({
7849
7912
  node: declarator.id,
7850
7913
  sourceText: selection.sourceText,
7851
- propertyName: propertyName6
7914
+ propertyName: propertyName7
7852
7915
  });
7853
7916
  }
7854
7917
  }
@@ -7878,7 +7941,7 @@ ${indentation}`;
7878
7941
  if (bindings.length === 0) return;
7879
7942
  const firstBinding = bindings[0];
7880
7943
  if (!firstBinding) return;
7881
- const sameSourceBindings = bindings.length > 1 && bindings.length === node.declarations.length && bindings.every(({ sourceText }) => sourceText === firstBinding.sourceText) && new Set(bindings.map(({ propertyName: propertyName6 }) => propertyName6)).size === bindings.length;
7944
+ const sameSourceBindings = bindings.length > 1 && bindings.length === node.declarations.length && bindings.every(({ sourceText }) => sourceText === firstBinding.sourceText) && new Set(bindings.map(({ propertyName: propertyName7 }) => propertyName7)).size === bindings.length;
7882
7945
  if (sameSourceBindings) {
7883
7946
  context.report({
7884
7947
  node,
@@ -9080,7 +9143,7 @@ function isHookUsage(node, hook) {
9080
9143
  }
9081
9144
  if (ts15.isIdentifier(node) && node.text === hook.value) {
9082
9145
  const parent = node.parent;
9083
- if (ts15.isBindingElement(parent) || ts15.isPropertyAccessExpression(parent) || ts15.isShorthandPropertyAssignment(parent)) {
9146
+ if (ts15.isBindingElement(parent) && parent.name === node || ts15.isVariableDeclaration(parent) && parent.name === node || ts15.isParameter(parent) && parent.name === node || ts15.isPropertyAccessExpression(parent) && parent.name === node || ts15.isPropertyAssignment(parent) && parent.name === node) {
9084
9147
  return void 0;
9085
9148
  }
9086
9149
  return "value";
@@ -9105,19 +9168,77 @@ function topLevelJsxChildren(initial) {
9105
9168
  }
9106
9169
  return void 0;
9107
9170
  }
9108
- function collectUsesIn(child, hook) {
9109
- const positions = [];
9171
+ function isSimpleDerivedExpression(node) {
9172
+ if (ts15.isNewExpression(node) || ts15.isAwaitExpression(node) || ts15.isYieldExpression(node) || ts15.isDeleteExpression(node) || ts15.isTaggedTemplateExpression(node) || ts15.isBlock(node)) {
9173
+ return false;
9174
+ }
9175
+ if (ts15.isCallExpression(node)) {
9176
+ const callee = node.expression;
9177
+ if (!ts15.isPropertyAccessExpression(callee) || !(/* @__PURE__ */ new Set(["filter", "map", "find", "findIndex", "some", "every", "slice", "includes"])).has(callee.name.text)) {
9178
+ return false;
9179
+ }
9180
+ }
9181
+ if (ts15.isArrowFunction(node) && ts15.isBlock(node.body)) return false;
9182
+ if (ts15.isBinaryExpression(node)) {
9183
+ const operator = node.operatorToken.kind;
9184
+ if (operator >= ts15.SyntaxKind.FirstAssignment && operator <= ts15.SyntaxKind.LastAssignment) return false;
9185
+ }
9186
+ if ((ts15.isPrefixUnaryExpression(node) || ts15.isPostfixUnaryExpression(node)) && (node.operator === ts15.SyntaxKind.PlusPlusToken || node.operator === ts15.SyntaxKind.MinusMinusToken)) {
9187
+ return false;
9188
+ }
9189
+ let safe = true;
9190
+ ts15.forEachChild(node, (child) => {
9191
+ if (!isSimpleDerivedExpression(child)) safe = false;
9192
+ });
9193
+ return safe;
9194
+ }
9195
+ function isIdentifierRead(node, names) {
9196
+ if (!ts15.isIdentifier(node) || !names.has(node.text)) return false;
9197
+ const parent = node.parent;
9198
+ return !(ts15.isBindingElement(parent) && parent.name === node || ts15.isVariableDeclaration(parent) && parent.name === node || ts15.isParameter(parent) && parent.name === node || ts15.isPropertyAccessExpression(parent) && parent.name === node || ts15.isPropertyAssignment(parent) && parent.name === node);
9199
+ }
9200
+ function containsNamedRead(node, names) {
9201
+ if (isIdentifierRead(node, names)) return true;
9202
+ return ts15.forEachChild(node, (child) => containsNamedRead(child, names)) ?? false;
9203
+ }
9204
+ function findDerivedState(body, hook) {
9205
+ const names = /* @__PURE__ */ new Set([hook.value]);
9206
+ const allowedInitializers = /* @__PURE__ */ new Set();
9207
+ for (const statement of body.statements) {
9208
+ if (!ts15.isVariableStatement(statement) || statement.declarationList.flags !== ts15.NodeFlags.Const) continue;
9209
+ for (const declaration of statement.declarationList.declarations) {
9210
+ if (!ts15.isIdentifier(declaration.name) || !declaration.initializer) continue;
9211
+ if (!containsNamedRead(declaration.initializer, names)) continue;
9212
+ if (!isSimpleDerivedExpression(declaration.initializer)) continue;
9213
+ names.add(declaration.name.text);
9214
+ allowedInitializers.add(declaration.initializer);
9215
+ }
9216
+ }
9217
+ return { names, allowedInitializers };
9218
+ }
9219
+ function isTrackedUse(node, hook, names) {
9220
+ return isHookUsage(node, hook) !== void 0 || isIdentifierRead(node, names);
9221
+ }
9222
+ function countUsesIn(child, hook, names) {
9110
9223
  let count = 0;
9111
9224
  const visit = (node) => {
9112
- if (isHookUsage(node, hook)) {
9113
- positions.push(node);
9114
- count += 1;
9115
- }
9225
+ if (isTrackedUse(node, hook, names)) count += 1;
9116
9226
  if (ts15.isFunctionDeclaration(node) || ts15.isClassDeclaration(node)) return;
9117
9227
  ts15.forEachChild(node, visit);
9118
9228
  };
9119
9229
  visit(child);
9120
- return { positions, count };
9230
+ return count;
9231
+ }
9232
+ function jsxChildren(node) {
9233
+ if (ts15.isJsxElement(node) || ts15.isJsxFragment(node)) {
9234
+ return [...node.children].filter((child) => !ts15.isJsxText(child));
9235
+ }
9236
+ return void 0;
9237
+ }
9238
+ function isDecorativeSeparator(node) {
9239
+ if (!ts15.isJsxSelfClosingElement(node) && !ts15.isJsxElement(node)) return false;
9240
+ const tagName2 = ts15.isJsxElement(node) ? node.openingElement.tagName : node.tagName;
9241
+ return /(?:Divider|Separator)$/.test(tagName2.getText());
9121
9242
  }
9122
9243
  var soleStateOwnerRule = {
9123
9244
  meta: {
@@ -9163,42 +9284,54 @@ function analyzeSoleOwner(declaration, hook) {
9163
9284
  };
9164
9285
  visit(body);
9165
9286
  if (returns.length !== 1) return void 0;
9166
- const single = returns[0];
9167
- if (!single?.expression || !ts15.isExpression(single.expression)) return void 0;
9168
- const returnExpression = single.expression;
9169
- const root = topLevelJsxChildren(returnExpression);
9170
- if (!root || root.children.length === 0) return void 0;
9171
- const totalTopLevel = root.children.length;
9172
- const usagePerChild = root.children.map((child) => collectUsesIn(child, hook));
9173
- const outsideJsx = usesOutsideJsx(declaration, hook, root.children);
9174
- if (outsideJsx) return void 0;
9175
- const usedLabels = usagePerChild.map((u) => u.count > 0);
9176
- const firstUsed = usedLabels.findIndex((v) => v);
9177
- const lastUsed = usedLabels.lastIndexOf(true);
9178
- if (firstUsed === -1 || lastUsed === -1) return void 0;
9179
- const windowHasUnused = usedLabels.slice(firstUsed, lastUsed + 1).some((v) => !v);
9180
- if (windowHasUnused) return void 0;
9181
- const run = lastUsed - firstUsed + 1;
9182
- const hasOutside = firstUsed > 0 || lastUsed < totalTopLevel - 1;
9183
- if (!hasOutside) return void 0;
9184
- return { run, totalTopLevel };
9185
- }
9186
- function usesOutsideJsx(declaration, hook, children) {
9287
+ const expression = returns[0]?.expression;
9288
+ if (!expression || !ts15.isExpression(expression)) return void 0;
9289
+ const root = topLevelJsxChildren(expression);
9290
+ if (!root) return void 0;
9291
+ const derived = findDerivedState(body, hook);
9292
+ if (usesOutsideJsx(declaration, hook, derived, root.children)) return void 0;
9293
+ const totalUses = countUsesIn(root.root, hook, derived.names);
9294
+ if (totalUses === 0) return void 0;
9295
+ const analyzeSection = (node) => {
9296
+ const children = jsxChildren(node);
9297
+ if (!children || children.length === 0) return void 0;
9298
+ for (const child of children) {
9299
+ if (ts15.isJsxElement(child) || ts15.isJsxFragment(child)) {
9300
+ const inner = analyzeSection(child);
9301
+ if (inner) return inner;
9302
+ }
9303
+ }
9304
+ const counts = children.map((child) => countUsesIn(child, hook, derived.names));
9305
+ if (counts.reduce((sum, count) => sum + count, 0) !== totalUses) return void 0;
9306
+ const firstUsed = counts.findIndex((count) => count > 0);
9307
+ const lastUsed = counts.map((count) => count > 0).lastIndexOf(true);
9308
+ if (firstUsed === -1 || lastUsed === -1) return void 0;
9309
+ for (let index = firstUsed; index <= lastUsed; index += 1) {
9310
+ const child = children[index];
9311
+ if ((counts[index] ?? 0) === 0 && (child === void 0 || !isDecorativeSeparator(child))) return void 0;
9312
+ }
9313
+ const hasOutside = firstUsed > 0 || lastUsed < children.length - 1;
9314
+ if (!hasOutside) return void 0;
9315
+ return { run: lastUsed - firstUsed + 1, totalTopLevel: children.length };
9316
+ };
9317
+ return analyzeSection(root.root);
9318
+ }
9319
+ function usesOutsideJsx(declaration, hook, derived, children) {
9187
9320
  let outside = false;
9188
9321
  const visit = (node) => {
9189
9322
  if (outside) return;
9190
9323
  if (node !== declaration && (ts15.isFunctionDeclaration(node) || ts15.isClassDeclaration(node))) return;
9191
- if (isHookUsage(node, hook)) {
9324
+ if (isTrackedUse(node, hook, derived.names)) {
9192
9325
  let current = node;
9193
- let isInJsxChild = false;
9326
+ let allowed = false;
9194
9327
  while (!ts15.isSourceFile(current)) {
9195
- if (children.includes(current)) {
9196
- isInJsxChild = true;
9328
+ if (children.includes(current) || derived.allowedInitializers.has(current)) {
9329
+ allowed = true;
9197
9330
  break;
9198
9331
  }
9199
9332
  current = current.parent;
9200
9333
  }
9201
- if (!isInJsxChild) outside = true;
9334
+ if (!allowed) outside = true;
9202
9335
  }
9203
9336
  ts15.forEachChild(node, visit);
9204
9337
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.106",
3
+ "version": "0.10.108",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",