pasika 0.10.65 → 0.10.66

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.
@@ -210,6 +210,7 @@ declare const pasikaPlugin: {
210
210
  "value-extraction": eslint.Rule.RuleModule;
211
211
  "constant-casing": eslint.Rule.RuleModule;
212
212
  "prefer-enum": eslint.Rule.RuleModule;
213
+ "prefer-object-destructuring": eslint.Rule.RuleModule;
213
214
  "enum-placement": eslint.Rule.RuleModule;
214
215
  "type-extraction": eslint.Rule.RuleModule;
215
216
  "zod-schema-validation": eslint.Rule.RuleModule;
@@ -5719,6 +5719,140 @@ var preferEnumRule = {
5719
5719
  }
5720
5720
  };
5721
5721
 
5722
+ // eslint/rules/prefer-object-destructuring.ts
5723
+ var DOC5 = "See docs/next-codebase-guide/rules/redundant-aliases-rule.md";
5724
+ function hasTypeAnnotation(identifier) {
5725
+ return "typeAnnotation" in identifier && identifier.typeAnnotation !== void 0;
5726
+ }
5727
+ function directPropertyBinding(context, declarator) {
5728
+ if (declarator.id.type !== "Identifier" || hasTypeAnnotation(declarator.id)) return void 0;
5729
+ if (declarator.init?.type !== "MemberExpression") return void 0;
5730
+ const member = declarator.init;
5731
+ if (member.computed || member.optional || member.property.type !== "Identifier" || member.object.type === "Super") {
5732
+ return void 0;
5733
+ }
5734
+ if (context.sourceCode.getCommentsInside(declarator).length > 0) return void 0;
5735
+ const propertyName4 = member.property.name;
5736
+ const localName = declarator.id.name;
5737
+ const source = member.object;
5738
+ const sourceText = context.sourceCode.getText(source);
5739
+ return {
5740
+ declarator,
5741
+ member,
5742
+ propertyName: propertyName4,
5743
+ localName,
5744
+ source,
5745
+ sourceText,
5746
+ bindingText: propertyName4 === localName ? propertyName4 : `${propertyName4}: ${localName}`
5747
+ };
5748
+ }
5749
+ function canGroupSource(source) {
5750
+ return source.type === "Identifier" || source.type === "ThisExpression";
5751
+ }
5752
+ function whitespaceKeepsStatementsAdjacent(text) {
5753
+ if (text.trim() !== "") return false;
5754
+ return (text.match(/\n/gu) ?? []).length <= 1;
5755
+ }
5756
+ function groupedDeclarations(context, declaration, firstBinding) {
5757
+ if (declaration.declarations.length !== 1 || !canGroupSource(firstBinding.source)) {
5758
+ return [{ declaration, binding: firstBinding }];
5759
+ }
5760
+ const parent = context.sourceCode.getAncestors(declaration).at(-1);
5761
+ if (parent?.type !== "Program" && parent?.type !== "BlockStatement") {
5762
+ return [{ declaration, binding: firstBinding }];
5763
+ }
5764
+ const body = parent.body;
5765
+ const startIndex = body.indexOf(declaration);
5766
+ if (startIndex < 0) return [{ declaration, binding: firstBinding }];
5767
+ const group = [{ declaration, binding: firstBinding }];
5768
+ const seenProperties = /* @__PURE__ */ new Set([firstBinding.propertyName]);
5769
+ for (let index = startIndex + 1; index < body.length; index += 1) {
5770
+ const nextNode = body[index];
5771
+ const previous = group.at(-1)?.declaration;
5772
+ if (!previous || nextNode?.type !== "VariableDeclaration" || nextNode.kind !== declaration.kind) break;
5773
+ if (nextNode.declarations.length !== 1) break;
5774
+ const nextDeclarator = nextNode.declarations[0];
5775
+ if (!nextDeclarator) break;
5776
+ const nextBinding = directPropertyBinding(context, nextDeclarator);
5777
+ if (nextBinding?.sourceText !== firstBinding.sourceText) break;
5778
+ if (!canGroupSource(nextBinding.source) || seenProperties.has(nextBinding.propertyName)) break;
5779
+ const [, previousEnd] = context.sourceCode.getRange(previous);
5780
+ const [nextStart] = context.sourceCode.getRange(nextNode);
5781
+ const gap = context.sourceCode.text.slice(previousEnd, nextStart);
5782
+ if (!whitespaceKeepsStatementsAdjacent(gap)) break;
5783
+ group.push({ declaration: nextNode, binding: nextBinding });
5784
+ seenProperties.add(nextBinding.propertyName);
5785
+ }
5786
+ return group;
5787
+ }
5788
+ function declarationTerminator(context, declaration) {
5789
+ return context.sourceCode.getText(declaration).trimEnd().endsWith(";") ? ";" : "";
5790
+ }
5791
+ function singleMessage(binding) {
5792
+ return `"${binding.localName}" is derived directly from "${binding.sourceText}.${binding.propertyName}". Use object destructuring. ${DOC5}`;
5793
+ }
5794
+ function groupMessage(bindings) {
5795
+ const firstBinding = bindings[0];
5796
+ if (!firstBinding) return `Use object destructuring. ${DOC5}`;
5797
+ const names = bindings.map(({ localName }) => `"${localName}"`).join(", ");
5798
+ return `${names} are derived directly from properties of "${firstBinding.sourceText}". Use object destructuring. ${DOC5}`;
5799
+ }
5800
+ var preferObjectDestructuringRule = {
5801
+ meta: {
5802
+ schema: [],
5803
+ type: "problem",
5804
+ fixable: "code",
5805
+ docs: {
5806
+ description: "Require locals derived directly from object properties to use object destructuring."
5807
+ }
5808
+ },
5809
+ create(context) {
5810
+ const grouped = /* @__PURE__ */ new Set();
5811
+ return {
5812
+ VariableDeclaration(node) {
5813
+ if (grouped.has(node)) return;
5814
+ const bindings = node.declarations.map((declarator) => directPropertyBinding(context, declarator)).filter((binding) => binding !== void 0);
5815
+ if (bindings.length === 0) return;
5816
+ const firstBinding = bindings[0];
5817
+ if (!firstBinding) return;
5818
+ if (node.declarations.length === 1 && bindings.length === 1) {
5819
+ const group = groupedDeclarations(context, node, firstBinding);
5820
+ if (group.length > 1) {
5821
+ for (const item of group.slice(1)) grouped.add(item.declaration);
5822
+ const groupBindings = group.map(({ binding }) => binding);
5823
+ const lastDeclaration = group.at(-1)?.declaration;
5824
+ if (!lastDeclaration) return;
5825
+ context.report({
5826
+ node,
5827
+ message: groupMessage(groupBindings),
5828
+ fix(fixer) {
5829
+ const [start] = context.sourceCode.getRange(node);
5830
+ const [, end] = context.sourceCode.getRange(lastDeclaration);
5831
+ const terminator = declarationTerminator(context, lastDeclaration);
5832
+ const pattern = groupBindings.map(({ bindingText }) => bindingText).join(", ");
5833
+ return fixer.replaceTextRange(
5834
+ [start, end],
5835
+ `${node.kind} { ${pattern} } = ${firstBinding.sourceText}${terminator}`
5836
+ );
5837
+ }
5838
+ });
5839
+ return;
5840
+ }
5841
+ }
5842
+ for (const binding of bindings) {
5843
+ context.report({
5844
+ node: binding.declarator,
5845
+ message: singleMessage(binding),
5846
+ fix(fixer) {
5847
+ return fixer.replaceText(binding.declarator, `{ ${binding.bindingText} } = ${binding.sourceText}`);
5848
+ }
5849
+ });
5850
+ }
5851
+ }
5852
+ };
5853
+ }
5854
+ };
5855
+
5722
5856
  // eslint/rules/pure-function-extract.ts
5723
5857
  import path43 from "path";
5724
5858
  var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
@@ -8529,9 +8663,9 @@ var vulykRules = {
8529
8663
  // eslint/rules/with-response-helper.ts
8530
8664
  var HELPER3 = "withResponse";
8531
8665
  var ENTRY3 = "pasika/with-response";
8532
- var DOC5 = "docs/pasika-adoption-guide/rules/with-response-helper-rule.md";
8533
- var DECLARED3 = `A repository must not declare its own ${HELPER3}; import it from ${ENTRY3}. See ${DOC5}`;
8534
- var IMPORTED3 = `${HELPER3} must be imported from ${ENTRY3}. See ${DOC5}`;
8666
+ var DOC6 = "docs/pasika-adoption-guide/rules/with-response-helper-rule.md";
8667
+ var DECLARED3 = `A repository must not declare its own ${HELPER3}; import it from ${ENTRY3}. See ${DOC6}`;
8668
+ var IMPORTED3 = `${HELPER3} must be imported from ${ENTRY3}. See ${DOC6}`;
8535
8669
  function isNamed3(node, name) {
8536
8670
  return node?.type === "Identifier" && node.name === name;
8537
8671
  }
@@ -8652,10 +8786,10 @@ function referencesZirka(sourceCode) {
8652
8786
  // eslint/rules/zod-fetch-helper.ts
8653
8787
  var HELPER4 = "zodFetch";
8654
8788
  var ENTRY4 = "pasika/zod-fetch";
8655
- var DOC6 = "docs/pasika-adoption-guide/rules/zod-fetch-helper-rule.md";
8656
- var FETCHED = `fetch must not be called; make the request through ${HELPER4} from ${ENTRY4}. See ${DOC6}`;
8657
- var DECLARED4 = `A file must not declare its own ${HELPER4}; import it from ${ENTRY4}. See ${DOC6}`;
8658
- var IMPORTED4 = `${HELPER4} must be imported from ${ENTRY4}. See ${DOC6}`;
8789
+ var DOC7 = "docs/pasika-adoption-guide/rules/zod-fetch-helper-rule.md";
8790
+ var FETCHED = `fetch must not be called; make the request through ${HELPER4} from ${ENTRY4}. See ${DOC7}`;
8791
+ var DECLARED4 = `A file must not declare its own ${HELPER4}; import it from ${ENTRY4}. See ${DOC7}`;
8792
+ var IMPORTED4 = `${HELPER4} must be imported from ${ENTRY4}. See ${DOC7}`;
8659
8793
  var GLOBAL_OBJECTS = /* @__PURE__ */ new Set(["globalThis", "window", "self", "global"]);
8660
8794
  var TEST_FILE2 = /(?:^|[\\/])(?:__tests__|tests)[\\/]|[.](?:test|spec)[.][cm]?[jt]sx?$/;
8661
8795
  function isNamed4(node, name) {
@@ -8842,6 +8976,7 @@ var pasikaNextjsAppRules = {
8842
8976
  "value-extraction": valueExtractionRule,
8843
8977
  "constant-casing": constantCasingRule,
8844
8978
  "prefer-enum": preferEnumRule,
8979
+ "prefer-object-destructuring": preferObjectDestructuringRule,
8845
8980
  "enum-placement": enumPlacementRule,
8846
8981
  "type-extraction": typeExtractionRule,
8847
8982
  "zod-schema-validation": zodSchemaValidationRule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.10.65",
3
+ "version": "0.10.66",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",