@lark-apaas/fullstack-presets 1.1.3-beta.5 → 1.1.3-beta.6

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.
@@ -48,78 +48,43 @@ const rule = {
48
48
  if (!hasJsxAttribute) {
49
49
  return;
50
50
  }
51
- // Check if this is a "jsx global" style tag - these are allowed to coexist with regular jsx styles
52
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
- const hasGlobalAttribute = openingElement.attributes.some((attr) => attr.type === 'JSXAttribute' &&
54
- attr.name?.type === 'JSXIdentifier' &&
55
- attr.name?.name === 'global');
56
- // Skip checking for "jsx global" tags - they don't conflict with regular jsx styles
57
- if (hasGlobalAttribute) {
58
- return;
59
- }
60
- // Count JSXElement ancestors and find the outer styled-jsx tag
51
+ // Count JSXElement and JSXFragment ancestors and find the outer styled-jsx tag
61
52
  // styled-jsx uses ignoreClosing counter that increments on JSXOpeningElement enter
62
53
  // and checks if ignoreClosing > 1 on style tag exit
63
54
  // @see https://github.com/vercel/styled-jsx/blob/d7a59379134d73afaeb98177387cd62d54d746be/src/babel.js#L222
55
+ // Note: JSXFragment (<>...</>) should also be counted as a container
64
56
  let jsxElementCount = 0;
65
57
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
58
  let outerStyledJsxNode = null;
67
59
  let current = node.parent;
68
- // Helper function to recursively find styled-jsx tags in a node tree (excluding "jsx global")
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
- const findStyledJsxInTree = (astNode, excludeNode) => {
71
- if (!astNode)
72
- return null;
73
- // Check if this node itself is a styled-jsx tag
74
- if (astNode.type === 'JSXElement' && astNode !== excludeNode) {
75
- const openingEl = astNode.openingElement;
76
- if (openingEl) {
77
- const elName = openingEl.name;
78
- if (elName?.type === 'JSXIdentifier' && elName?.name === 'style') {
79
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- const hasJsxAttr = openingEl.attributes?.some((attr) => attr.type === 'JSXAttribute' &&
81
- attr.name?.type === 'JSXIdentifier' &&
82
- attr.name?.name === 'jsx');
83
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
- const hasGlobalAttr = openingEl.attributes?.some((attr) => attr.type === 'JSXAttribute' &&
85
- attr.name?.type === 'JSXIdentifier' &&
86
- attr.name?.name === 'global');
87
- // Only return if it's a regular jsx style (not global)
88
- if (hasJsxAttr && !hasGlobalAttr) {
89
- return astNode;
90
- }
91
- }
92
- }
93
- }
94
- // Check children
95
- const children = astNode.children;
96
- if (children && Array.isArray(children)) {
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- for (const child of children) {
99
- const result = findStyledJsxInTree(child, excludeNode);
100
- if (result)
101
- return result;
102
- }
103
- }
104
- return null;
105
- };
106
60
  while (current) {
107
- if (current.type === 'JSXElement') {
61
+ // Count both JSXElement and JSXFragment as containers
62
+ if (current.type === 'JSXElement' || current.type === 'JSXFragment') {
108
63
  jsxElementCount++;
109
- // Try to find any styled-jsx tag in the ancestor tree
64
+ // Check if any sibling or ancestor siblings contain a styled-jsx tag
110
65
  if (!outerStyledJsxNode && current.parent) {
111
66
  const parentNode = current.parent;
112
- // Search in parent's children (siblings of current)
113
- const children = parentNode.children || (parentNode.type === 'JSXElement' ? parentNode.children : null);
67
+ // Check if parent has children that we can iterate
68
+ const children = parentNode.children ||
69
+ (parentNode.type === 'JSXElement' || parentNode.type === 'JSXFragment' ? parentNode.children : null);
114
70
  if (children && Array.isArray(children)) {
115
71
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
116
72
  for (const child of children) {
117
- // Don't search in the current branch that contains our node
118
- if (child !== current) {
119
- const result = findStyledJsxInTree(child, node);
120
- if (result) {
121
- outerStyledJsxNode = result;
122
- break;
73
+ if (child.type === 'JSXElement' && child !== node) {
74
+ const childOpeningElement = child.openingElement;
75
+ if (childOpeningElement) {
76
+ const childElementName = childOpeningElement.name;
77
+ if (childElementName?.type === 'JSXIdentifier' &&
78
+ childElementName?.name === 'style') {
79
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
+ const hasChildJsxAttr = childOpeningElement.attributes?.some((attr) => attr.type === 'JSXAttribute' &&
81
+ attr.name?.type === 'JSXIdentifier' &&
82
+ attr.name?.name === 'jsx');
83
+ if (hasChildJsxAttr) {
84
+ outerStyledJsxNode = child;
85
+ break;
86
+ }
87
+ }
123
88
  }
124
89
  }
125
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-presets",
3
- "version": "1.1.3-beta.5",
3
+ "version": "1.1.3-beta.6",
4
4
  "files": [
5
5
  "lib"
6
6
  ],