pasika 0.10.91 → 0.10.92

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.
@@ -6418,13 +6418,17 @@ function canGroupSource(source) {
6418
6418
  function isGroupedUsageSource(source) {
6419
6419
  return source.type === "Identifier" || source.type === "ThisExpression";
6420
6420
  }
6421
+ function supportsSinglePropertySource(source) {
6422
+ if (isGroupedUsageSource(source) || source.type === "CallExpression") return true;
6423
+ return source.type === "MemberExpression" && !source.computed && !source.optional && source.property.type === "Identifier" && supportsSinglePropertySource(source.object);
6424
+ }
6421
6425
  function rootIdentifierName(node) {
6422
6426
  if (node.type === "Identifier") return node.name;
6423
6427
  if (node.type !== "MemberExpression" || node.object.type === "Super") return void 0;
6424
6428
  return rootIdentifierName(node.object);
6425
6429
  }
6426
6430
  function isCompliantLocalName(propertyName5) {
6427
- return !propertyName5.includes("_");
6431
+ return !propertyName5.includes("_") || /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/u.test(propertyName5);
6428
6432
  }
6429
6433
  function propertyNameOf(node) {
6430
6434
  if (node.type !== "Property" || node.computed) return void 0;
@@ -6667,8 +6671,8 @@ function groupedDestructuringSelections(context, first, isEnumValue) {
6667
6671
  function declarationTerminator(context, declaration) {
6668
6672
  return context.sourceCode.getText(declaration).trimEnd().endsWith(";") ? ";" : "";
6669
6673
  }
6670
- function singleMessage(binding) {
6671
- return `"${binding.localName}" is derived directly from "${binding.sourceText}.${binding.propertyName}". Use object destructuring. ${DOC5}`;
6674
+ function singlePropertyMessage(binding) {
6675
+ return `"${binding.propertyName}" is the only property bound from "${binding.sourceText}". Read "${binding.sourceText}.${binding.propertyName}" directly instead of creating a local binding. ${DOC5}`;
6672
6676
  }
6673
6677
  function groupMessage(bindings) {
6674
6678
  const firstBinding = bindings[0];
@@ -6688,7 +6692,7 @@ var preferObjectDestructuringRule = {
6688
6692
  type: "problem",
6689
6693
  fixable: "code",
6690
6694
  docs: {
6691
- description: "Require related object-property reads to use one object destructuring declaration."
6695
+ description: "Prefer direct access for one property and shared destructuring for related property reads."
6692
6696
  }
6693
6697
  },
6694
6698
  create(context) {
@@ -6698,7 +6702,7 @@ var preferObjectDestructuringRule = {
6698
6702
  const usageScopes = [];
6699
6703
  const currentUsageScope = () => usageScopes.at(-1);
6700
6704
  const enterUsageScope = (node) => {
6701
- usageScopes.push({ node, objects: /* @__PURE__ */ new Map() });
6705
+ usageScopes.push({ node, objects: /* @__PURE__ */ new Map(), singleProperties: [] });
6702
6706
  };
6703
6707
  const enterUsageBarrier = () => {
6704
6708
  usageScopes.push(void 0);
@@ -6745,6 +6749,31 @@ ${indentation}`;
6745
6749
  }
6746
6750
  });
6747
6751
  }
6752
+ for (const binding of scope.singleProperties) {
6753
+ const fromSameSource = scope.singleProperties.filter(({ sourceText }) => sourceText === binding.sourceText);
6754
+ if (fromSameSource[0] !== binding) continue;
6755
+ const usage = scope.objects.get(binding.sourceText);
6756
+ const usedProperties = usage?.propertyNames;
6757
+ if (usedProperties && usedProperties.size > 1 && usage.directMembers.length > 0) {
6758
+ if (scope.singleProperties.some(
6759
+ (item) => item.node.type === "ObjectPattern" && item.sourceText === binding.sourceText
6760
+ )) {
6761
+ continue;
6762
+ }
6763
+ }
6764
+ if (usedProperties && usedProperties.size > 1) {
6765
+ context.report({ node: binding.node, message: scopeUsageMessage(binding.sourceText, usedProperties) });
6766
+ continue;
6767
+ }
6768
+ if (fromSameSource.length > 1) {
6769
+ const names = new Set(fromSameSource.map(({ propertyName: propertyName5 }) => propertyName5));
6770
+ if (names.size > 1) {
6771
+ context.report({ node: binding.node, message: scopeUsageMessage(binding.sourceText, names) });
6772
+ continue;
6773
+ }
6774
+ }
6775
+ context.report({ node: binding.node, message: singlePropertyMessage(binding) });
6776
+ }
6748
6777
  };
6749
6778
  return {
6750
6779
  Program: enterUsageScope,
@@ -6774,7 +6803,20 @@ ${indentation}`;
6774
6803
  const selection = destructuringSelection(context, node, isEnumValue);
6775
6804
  if (selection) {
6776
6805
  const group = groupedDestructuringSelections(context, selection, isEnumValue);
6777
- if (group.length <= 1) return;
6806
+ if (group.length <= 1) {
6807
+ if (node.kind === "const" && selection.propertyNames.length === 1 && supportsSinglePropertySource(selection.source)) {
6808
+ const declarator = node.declarations[0];
6809
+ const propertyName5 = selection.propertyNames[0];
6810
+ if (declarator && propertyName5) {
6811
+ currentUsageScope()?.singleProperties.push({
6812
+ node: declarator.id,
6813
+ sourceText: selection.sourceText,
6814
+ propertyName: propertyName5
6815
+ });
6816
+ }
6817
+ }
6818
+ return;
6819
+ }
6778
6820
  for (const item of group.slice(1)) grouped.add(item.declaration);
6779
6821
  const lastDeclaration = group.at(-1)?.declaration;
6780
6822
  if (!lastDeclaration) return;
@@ -6841,13 +6883,11 @@ ${indentation}`;
6841
6883
  }
6842
6884
  }
6843
6885
  for (const binding of bindings) {
6844
- if (!canGroupSource(binding.source)) continue;
6845
- context.report({
6886
+ if (node.kind !== "const" || !supportsSinglePropertySource(binding.source)) continue;
6887
+ currentUsageScope()?.singleProperties.push({
6846
6888
  node: binding.declarator,
6847
- message: singleMessage(binding),
6848
- fix(fixer) {
6849
- return fixer.replaceText(binding.declarator, `{ ${binding.bindingText} } = ${binding.sourceText}`);
6850
- }
6889
+ sourceText: binding.sourceText,
6890
+ propertyName: binding.propertyName
6851
6891
  });
6852
6892
  }
6853
6893
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.91",
3
+ "version": "0.10.92",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",