pasika 0.10.59 → 0.10.61

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.
@@ -5020,12 +5020,55 @@ function aliasMessage(alias, source) {
5020
5020
  const sourceName = source ?? "the original symbol";
5021
5021
  return `"${aliasName}" only renames "${sourceName}". Use "${sourceName}" directly or rename the original symbol and its consumers. ${DOC4}`;
5022
5022
  }
5023
+ function objectPropertyMessage(propertyName4, source, identifierValue) {
5024
+ if (!identifierValue) {
5025
+ return `"${propertyName4}" maps "${source}" inline. Bind it as "${propertyName4}" before this object and use property shorthand. ${DOC4}`;
5026
+ }
5027
+ if (source === propertyName4) return `Use property shorthand for "${propertyName4}". ${DOC4}`;
5028
+ return `"${propertyName4}" maps the local "${source}" inline. Rename the producer to "${propertyName4}" and use property shorthand. ${DOC4}`;
5029
+ }
5030
+ function findVariable(context, node) {
5031
+ let scope = context.sourceCode.getScope(node);
5032
+ while (scope) {
5033
+ const variable = scope.set.get(node.name);
5034
+ if (variable) return variable;
5035
+ scope = scope.upper;
5036
+ }
5037
+ return void 0;
5038
+ }
5039
+ function isExportedVariable2(context, variable) {
5040
+ return variable.defs.some(
5041
+ (definition) => definition.type === "Variable" && context.sourceCode.getAncestors(definition.parent).at(-1)?.type === "ExportNamedDeclaration"
5042
+ );
5043
+ }
5044
+ function canRenameIdentifierProducer(context, node) {
5045
+ const variable = findVariable(context, node);
5046
+ if (!variable || isExportedVariable2(context, variable)) return false;
5047
+ const definition = variable.defs[0];
5048
+ if (!definition || variable.defs.length !== 1) return false;
5049
+ if (definition.type === "ImportBinding") return false;
5050
+ if (definition.type === "Variable" && definition.parent.kind !== "const") return false;
5051
+ if (definition.type !== "Variable" && definition.type !== "Parameter") return false;
5052
+ return variable.references.filter((reference) => reference.isRead()).length === 1;
5053
+ }
5054
+ function memberRootIdentifier(node) {
5055
+ let current = node;
5056
+ while (current.type === "MemberExpression") current = current.object;
5057
+ return current.type === "Identifier" ? current : void 0;
5058
+ }
5059
+ function canBindMemberExpression(context, node) {
5060
+ const root = memberRootIdentifier(node);
5061
+ if (!root) return true;
5062
+ if (/^[A-Z]/u.test(root.name)) return false;
5063
+ const variable = findVariable(context, root);
5064
+ return !variable?.defs.some((definition) => definition.type === "ImportBinding");
5065
+ }
5023
5066
  var noRedundantAliasRule = {
5024
5067
  meta: {
5025
5068
  schema: [],
5026
5069
  type: "problem",
5027
5070
  docs: {
5028
- description: "Disallow declarations that only give an existing symbol a second name."
5071
+ description: "Disallow redundant aliases and inline identifier/member-expression object mappings."
5029
5072
  }
5030
5073
  },
5031
5074
  create(context) {
@@ -5042,6 +5085,22 @@ var noRedundantAliasRule = {
5042
5085
  message: aliasMessage(node.id.name, node.init.name)
5043
5086
  });
5044
5087
  },
5088
+ Property(node) {
5089
+ if (node.parent.type !== "ObjectExpression" || node.computed || node.key.type !== "Identifier") return;
5090
+ if (node.value.type !== "Identifier" && node.value.type !== "MemberExpression") return;
5091
+ const propertyName4 = node.key.name;
5092
+ const source = context.sourceCode.getText(node.value);
5093
+ if (node.value.type === "Identifier") {
5094
+ if (node.shorthand) return;
5095
+ if (source !== propertyName4 && !canRenameIdentifierProducer(context, node.value)) return;
5096
+ } else if (!canBindMemberExpression(context, node.value)) {
5097
+ return;
5098
+ }
5099
+ context.report({
5100
+ node,
5101
+ message: objectPropertyMessage(propertyName4, source, node.value.type === "Identifier")
5102
+ });
5103
+ },
5045
5104
  TSTypeAliasDeclaration(node) {
5046
5105
  if (node.typeParameters) return;
5047
5106
  const annotation = node.typeAnnotation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.59",
3
+ "version": "0.10.61",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",