pasika 0.5.10 → 0.5.11

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.
@@ -2276,6 +2276,63 @@ function isComponentReturn(node) {
2276
2276
  if (parent.type === "ReturnStatement") return true;
2277
2277
  return parent.type === "ArrowFunctionExpression" && parent.body === node;
2278
2278
  }
2279
+ function isJsxElementWithChildren(node) {
2280
+ return "children" in node && Array.isArray(node.children);
2281
+ }
2282
+ function isJsxElementChild(node) {
2283
+ return "openingElement" in node;
2284
+ }
2285
+ function decorativeTagName(node) {
2286
+ const name = node.openingElement.name;
2287
+ if (name && typeof name === "object" && "name" in name && typeof name.name === "string") return name.name;
2288
+ return void 0;
2289
+ }
2290
+ function isInteractiveChild(node) {
2291
+ const name = decorativeTagName(node);
2292
+ return name !== void 0 && INTERACTIVE_TAGS.has(name);
2293
+ }
2294
+ function isComponentChild(node) {
2295
+ const name = decorativeTagName(node);
2296
+ return name !== void 0 && /^[A-Z]/.test(name);
2297
+ }
2298
+ function isDecorative(node) {
2299
+ const name = decorativeTagName(node);
2300
+ if (name === void 0) return false;
2301
+ if (INTERACTIVE_TAGS.has(name)) return false;
2302
+ if (/^[A-Z]/.test(name)) return false;
2303
+ const children = node.children ?? [];
2304
+ const meaningfulText = children.some(
2305
+ (child) => child.type === "JSXText" && typeof child.value === "string" && child.value.trim().length > 0
2306
+ );
2307
+ return !meaningfulText && !isContentElement(name);
2308
+ }
2309
+ function isContentElement(name) {
2310
+ return /^(?:h[1-6]|p|li|dt|dd|blockquote|pre|code|figcaption|caption|th|td|form|fieldset|select|textarea)$/.test(name);
2311
+ }
2312
+ function isSoleContentOfWrapper(node) {
2313
+ const parent = node.parent;
2314
+ if (!isJsxElementChild(parent)) return false;
2315
+ let current = parent;
2316
+ while (current && isJsxElementWithChildren(current) && !isInteractiveChild(current) && !isComponentChild(current)) {
2317
+ const children = current.children ?? [];
2318
+ const siblings = children.filter(isJsxElementChild);
2319
+ const meaningful = siblings.filter((sibling) => !isDecorative(sibling));
2320
+ const textContent = children.some(
2321
+ (child) => child.type === "JSXText" && typeof child.value === "string" && child.value.trim().length > 0
2322
+ );
2323
+ const expressionContent = children.some((child) => {
2324
+ if (child.type !== "JSXExpressionContainer") return false;
2325
+ const expression = child.expression;
2326
+ return typeof expression === "object" && expression !== null && "type" in expression && expression.type !== "Literal";
2327
+ });
2328
+ if (meaningful.length <= 1 && !textContent && !expressionContent) {
2329
+ return true;
2330
+ }
2331
+ const nextParent = current.parent;
2332
+ current = nextParent !== void 0 && isJsxElementChild(nextParent) ? nextParent : void 0;
2333
+ }
2334
+ return false;
2335
+ }
2279
2336
  var interactiveComponentRule = {
2280
2337
  meta: {
2281
2338
  schema: [],
@@ -2301,6 +2358,9 @@ var interactiveComponentRule = {
2301
2358
  if (isComponentReturn(node)) {
2302
2359
  return;
2303
2360
  }
2361
+ if (isSoleContentOfWrapper(node)) {
2362
+ return;
2363
+ }
2304
2364
  const name = tagName(node);
2305
2365
  if (name === void 0) return;
2306
2366
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pasika",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "Reusable agent setup package",
5
5
  "repository": {
6
6
  "type": "git",