pasika 0.10.77 → 0.10.79

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.
@@ -6153,11 +6153,8 @@ function directPropertyBinding(context, declarator) {
6153
6153
  function canGroupSource(source) {
6154
6154
  return source.type === "Identifier" || source.type === "ThisExpression";
6155
6155
  }
6156
- function isStableObjectSource(source) {
6157
- if (source.type === "Identifier" || source.type === "ThisExpression") return true;
6158
- if (source.type !== "MemberExpression") return false;
6159
- if (source.computed || source.optional || source.property.type !== "Identifier") return false;
6160
- return isStableObjectSource(source.object);
6156
+ function isGroupedUsageSource(source) {
6157
+ return source.type === "Identifier" || source.type === "ThisExpression";
6161
6158
  }
6162
6159
  function rootIdentifierName(node) {
6163
6160
  if (node.type === "Identifier") return node.name;
@@ -6231,7 +6228,7 @@ function memberIsDirectVariableInitializer(context, member) {
6231
6228
  function recordMemberUsage(context, scope, ownershipResolver, member) {
6232
6229
  if (!scope || member.computed || member.optional || member.property.type !== "Identifier") return;
6233
6230
  if (!memberCanBeDestructured(context, ownershipResolver, member)) return;
6234
- if (!isStableObjectSource(member.object) || !memberIsRead(context, member)) return;
6231
+ if (!isGroupedUsageSource(member.object) || !memberIsRead(context, member)) return;
6235
6232
  const sourceText = context.sourceCode.getText(member.object);
6236
6233
  const usage = objectUsage(scope, sourceText);
6237
6234
  const propertyName5 = member.property.name;
@@ -6243,10 +6240,11 @@ function recordMemberUsage(context, scope, ownershipResolver, member) {
6243
6240
  function recordDestructuringUsage(context, scope, declaration) {
6244
6241
  if (!scope) return;
6245
6242
  for (const declarator of declaration.declarations) {
6246
- if (declarator.id.type !== "ObjectPattern" || !declarator.init || !isStableObjectSource(declarator.init)) continue;
6243
+ if (declarator.id.type !== "ObjectPattern" || !declarator.init || !isGroupedUsageSource(declarator.init)) continue;
6247
6244
  if (rootIdentifierName(declarator.init) === "locales") continue;
6248
6245
  const sourceText = context.sourceCode.getText(declarator.init);
6249
6246
  const usage = objectUsage(scope, sourceText);
6247
+ if (usage.directMembers.length > 0) continue;
6250
6248
  const propertyNames = /* @__PURE__ */ new Set();
6251
6249
  for (const property of declarator.id.properties) {
6252
6250
  if (property.type !== "Property" || property.computed || property.key.type !== "Identifier") continue;
@@ -6264,6 +6262,10 @@ function scopeUsageMessage(sourceText, propertyNames) {
6264
6262
  function hasBinding(context, node, name) {
6265
6263
  const initialScope = context.sourceCode.getScope(node);
6266
6264
  if (initialScope.variables.some((variable) => variable.name === name)) return true;
6265
+ const descendantHasBinding = (scope) => scope.childScopes.some(
6266
+ (childScope) => childScope.variables.some((variable) => variable.name === name) || descendantHasBinding(childScope)
6267
+ );
6268
+ if (descendantHasBinding(initialScope)) return true;
6267
6269
  for (let scope = initialScope.upper; scope !== null; scope = scope.upper) {
6268
6270
  if (scope.variables.some((variable) => variable.name === name)) return true;
6269
6271
  }
@@ -6404,6 +6406,9 @@ var preferObjectDestructuringRule = {
6404
6406
  const enterUsageScope = (node) => {
6405
6407
  usageScopes.push({ node, objects: /* @__PURE__ */ new Map() });
6406
6408
  };
6409
+ const enterUsageBarrier = () => {
6410
+ usageScopes.push(void 0);
6411
+ };
6407
6412
  const exitUsageScope = () => {
6408
6413
  const scope = usageScopes.pop();
6409
6414
  if (!scope) return;
@@ -6412,17 +6417,17 @@ var preferObjectDestructuringRule = {
6412
6417
  const firstDirectUsage = usage.directMembers[0];
6413
6418
  if (!firstDirectUsage) continue;
6414
6419
  const { member: firstDirectMember } = firstDirectUsage;
6420
+ const propertyNames = [...usage.propertyNames];
6421
+ const missingPropertyNames = propertyNames.filter(
6422
+ (propertyName5) => !usage.destructuring?.propertyNames.has(propertyName5)
6423
+ );
6424
+ if (missingPropertyNames.some((propertyName5) => hasBinding(context, firstDirectMember, propertyName5))) {
6425
+ continue;
6426
+ }
6415
6427
  context.report({
6416
6428
  node: firstDirectMember,
6417
6429
  message: scopeUsageMessage(sourceText, usage.propertyNames),
6418
6430
  fix(fixer) {
6419
- const propertyNames = [...usage.propertyNames];
6420
- const missingPropertyNames = propertyNames.filter(
6421
- (propertyName5) => !usage.destructuring?.propertyNames.has(propertyName5)
6422
- );
6423
- if (missingPropertyNames.some((propertyName5) => hasBinding(context, firstDirectMember, propertyName5))) {
6424
- return null;
6425
- }
6426
6431
  const memberFixes = usage.directMembers.map(
6427
6432
  ({ member, propertyName: propertyName5 }) => fixer.replaceText(member, propertyName5)
6428
6433
  );
@@ -6452,11 +6457,11 @@ ${indentation}`;
6452
6457
  "Program:exit": exitUsageScope,
6453
6458
  BlockStatement: enterUsageScope,
6454
6459
  "BlockStatement:exit": exitUsageScope,
6455
- FunctionDeclaration: enterUsageScope,
6460
+ FunctionDeclaration: enterUsageBarrier,
6456
6461
  "FunctionDeclaration:exit": exitUsageScope,
6457
- FunctionExpression: enterUsageScope,
6462
+ FunctionExpression: enterUsageBarrier,
6458
6463
  "FunctionExpression:exit": exitUsageScope,
6459
- ArrowFunctionExpression: enterUsageScope,
6464
+ ArrowFunctionExpression: enterUsageBarrier,
6460
6465
  "ArrowFunctionExpression:exit": exitUsageScope,
6461
6466
  MemberExpression(node) {
6462
6467
  recordMemberUsage(context, currentUsageScope(), ownershipResolver, node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.77",
3
+ "version": "0.10.79",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",