@eslint-react/jsx 5.27.2 → 5.27.3

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.
package/dist/index.d.ts CHANGED
@@ -194,7 +194,8 @@ export declare function getAttributeStaticValue(context: RuleContext, element: T
194
194
  export declare function getChildren(element: TSESTreeJSXElementLike): TSESTree.JSXChild[];
195
195
  /**
196
196
  * Check if the element has at least one meaningful child, that is, a child that
197
- * is not purely whitespace text or an empty string expression (`{""}`).
197
+ * is not purely whitespace text, an empty expression container (`{}`), or an
198
+ * empty string expression (`{""}`).
198
199
  *
199
200
  * Unlike {@link getChildren} (which only filters whitespace containing a newline),
200
201
  * this check treats any whitespace-only text as non-meaningful, so `hasChildren(node)`
package/dist/index.js CHANGED
@@ -266,6 +266,10 @@ function isWhitespaceText(node) {
266
266
  if (node.type !== AST_NODE_TYPES.JSXText) return false;
267
267
  return node.raw.trim() === "";
268
268
  }
269
+ function isEmptyExpressionContainer(node) {
270
+ if (node.type !== AST_NODE_TYPES.JSXExpressionContainer) return false;
271
+ return node.expression.type === AST_NODE_TYPES.JSXEmptyExpression;
272
+ }
269
273
  function isEmptyStringExpression(node) {
270
274
  if (node.type !== AST_NODE_TYPES.JSXExpressionContainer) return false;
271
275
  const expr = node.expression;
@@ -278,17 +282,15 @@ function getChildren(element) {
278
282
  const children = [];
279
283
  for (const child of element.children) {
280
284
  if (isPaddingWhitespace(child)) continue;
281
- if (child.type === AST_NODE_TYPES.JSXExpressionContainer) {
282
- if (child.expression.type === AST_NODE_TYPES.JSXEmptyExpression) continue;
283
- if (isEmptyStringExpression(child)) continue;
284
- }
285
+ if (isEmptyExpressionContainer(child)) continue;
286
+ if (isEmptyStringExpression(child)) continue;
285
287
  children.push(child);
286
288
  }
287
289
  return children;
288
290
  }
289
291
  function hasChildren(element) {
290
292
  if (element.children.length === 0) return false;
291
- return !element.children.every(or(isWhitespaceText, isEmptyStringExpression));
293
+ return !element.children.every(or(or(isWhitespaceText, isEmptyExpressionContainer), isEmptyStringExpression));
292
294
  }
293
295
  //#endregion
294
296
  //#region src/element-type.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/jsx",
3
- "version": "5.27.2",
3
+ "version": "5.27.3",
4
4
  "description": "ESLint React's TSESTree JSX utility module for static analysis of JSX patterns.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -29,9 +29,9 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.27.2",
33
- "@eslint-react/eslint": "5.27.2",
34
- "@eslint-react/var": "5.27.2",
32
+ "@eslint-react/ast": "5.27.3",
33
+ "@eslint-react/eslint": "5.27.3",
34
+ "@eslint-react/var": "5.27.3",
35
35
  "@typescript-eslint/types": "^8.71.2",
36
36
  "@typescript-eslint/utils": "^8.71.2",
37
37
  "ts-pattern": "^5.9.2"