@eslint-react/jsx 1.40.4-next.2 → 1.40.4-next.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.mts CHANGED
@@ -69,15 +69,15 @@ declare const DEFAULT_JSX_DETECTION_HINT: bigint;
69
69
 
70
70
  /**
71
71
  * Heuristic decision to determine if a node is a JSX-like node.
72
+ * @param code The sourceCode object
73
+ * @param code.getScope The function to get the scope of a node
72
74
  * @param node The AST node to check
73
- * @param jsxCtx The requirements for the check
74
- * @param jsxCtx.getScope The function to get the scope of a node
75
75
  * @param hint The `JSXDetectionHint` to use
76
76
  * @returns boolean
77
77
  */
78
- declare function isJSXLike(node: TSESTree$1.Node | _ | null, jsxCtx: {
78
+ declare function isJsxLike(code: {
79
79
  getScope: (node: TSESTree$1.Node) => Scope;
80
- }, hint?: JSXDetectionHint): boolean;
80
+ }, node: TSESTree$1.Node | _ | null, hint?: JSXDetectionHint): boolean;
81
81
 
82
82
  declare function isJsxFragmentElement(node: TSESTree.Node): boolean;
83
83
  declare function isJsxKeyedElement(node: TSESTree.Node, initialScope?: Scope): boolean;
@@ -105,4 +105,4 @@ declare function isJsxText(node: TSESTree.Node | null | _): node is TSESTree.JSX
105
105
  */
106
106
  declare function toString(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXClosingElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXText): string;
107
107
 
108
- export { DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getElementType, hasAnyAttribute, hasAttribute, hasEveryAttribute, isJSXLike, isJsxBuiltInElement, isJsxFragment, isJsxFragmentElement, isJsxKeyedElement, isJsxText, isJsxUserDefinedElement, toString };
108
+ export { DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getElementType, hasAnyAttribute, hasAttribute, hasEveryAttribute, isJsxBuiltInElement, isJsxFragment, isJsxFragmentElement, isJsxKeyedElement, isJsxLike, isJsxText, isJsxUserDefinedElement, toString };
package/dist/index.d.ts CHANGED
@@ -69,15 +69,15 @@ declare const DEFAULT_JSX_DETECTION_HINT: bigint;
69
69
 
70
70
  /**
71
71
  * Heuristic decision to determine if a node is a JSX-like node.
72
+ * @param code The sourceCode object
73
+ * @param code.getScope The function to get the scope of a node
72
74
  * @param node The AST node to check
73
- * @param jsxCtx The requirements for the check
74
- * @param jsxCtx.getScope The function to get the scope of a node
75
75
  * @param hint The `JSXDetectionHint` to use
76
76
  * @returns boolean
77
77
  */
78
- declare function isJSXLike(node: TSESTree$1.Node | _ | null, jsxCtx: {
78
+ declare function isJsxLike(code: {
79
79
  getScope: (node: TSESTree$1.Node) => Scope;
80
- }, hint?: JSXDetectionHint): boolean;
80
+ }, node: TSESTree$1.Node | _ | null, hint?: JSXDetectionHint): boolean;
81
81
 
82
82
  declare function isJsxFragmentElement(node: TSESTree.Node): boolean;
83
83
  declare function isJsxKeyedElement(node: TSESTree.Node, initialScope?: Scope): boolean;
@@ -105,4 +105,4 @@ declare function isJsxText(node: TSESTree.Node | null | _): node is TSESTree.JSX
105
105
  */
106
106
  declare function toString(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXClosingElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXText): string;
107
107
 
108
- export { DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getElementType, hasAnyAttribute, hasAttribute, hasEveryAttribute, isJSXLike, isJsxBuiltInElement, isJsxFragment, isJsxFragmentElement, isJsxKeyedElement, isJsxText, isJsxUserDefinedElement, toString };
108
+ export { DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getElementType, hasAnyAttribute, hasAttribute, hasEveryAttribute, isJsxBuiltInElement, isJsxFragment, isJsxFragmentElement, isJsxKeyedElement, isJsxLike, isJsxText, isJsxUserDefinedElement, toString };
package/dist/index.js CHANGED
@@ -157,7 +157,7 @@ var JSXDetectionHint = {
157
157
  var DEFAULT_JSX_DETECTION_HINT = 0n | JSXDetectionHint.SkipUndefined | JSXDetectionHint.SkipBooleanLiteral;
158
158
 
159
159
  // src/is-jsx.ts
160
- function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
160
+ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
161
161
  switch (node?.type) {
162
162
  case types.AST_NODE_TYPES.JSXText:
163
163
  case types.AST_NODE_TYPES.JSXElement:
@@ -197,15 +197,15 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
197
197
  }
198
198
  case types.AST_NODE_TYPES.ArrayExpression: {
199
199
  if (hint & JSXDetectionHint.StrictArray) {
200
- return node.elements.every((n) => isJSXLike(n, jsxCtx, hint));
200
+ return node.elements.every((n) => isJsxLike(code, n, hint));
201
201
  }
202
- return node.elements.some((n) => isJSXLike(n, jsxCtx, hint));
202
+ return node.elements.some((n) => isJsxLike(code, n, hint));
203
203
  }
204
204
  case types.AST_NODE_TYPES.LogicalExpression: {
205
205
  if (hint & JSXDetectionHint.StrictLogical) {
206
- return isJSXLike(node.left, jsxCtx, hint) && isJSXLike(node.right, jsxCtx, hint);
206
+ return isJsxLike(code, node.left, hint) && isJsxLike(code, node.right, hint);
207
207
  }
208
- return isJSXLike(node.left, jsxCtx, hint) || isJSXLike(node.right, jsxCtx, hint);
208
+ return isJsxLike(code, node.left, hint) || isJsxLike(code, node.right, hint);
209
209
  }
210
210
  case types.AST_NODE_TYPES.ConditionalExpression: {
211
211
  let leftHasJSX2 = function(node2) {
@@ -214,13 +214,13 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
214
214
  return !(hint & JSXDetectionHint.SkipEmptyArray);
215
215
  }
216
216
  if (hint & JSXDetectionHint.StrictArray) {
217
- return node2.consequent.every((n) => isJSXLike(n, jsxCtx, hint));
217
+ return node2.consequent.every((n) => isJsxLike(code, n, hint));
218
218
  }
219
- return node2.consequent.some((n) => isJSXLike(n, jsxCtx, hint));
219
+ return node2.consequent.some((n) => isJsxLike(code, n, hint));
220
220
  }
221
- return isJSXLike(node2.consequent, jsxCtx, hint);
221
+ return isJsxLike(code, node2.consequent, hint);
222
222
  }, rightHasJSX2 = function(node2) {
223
- return isJSXLike(node2.alternate, jsxCtx, hint);
223
+ return isJsxLike(code, node2.alternate, hint);
224
224
  };
225
225
  if (hint & JSXDetectionHint.StrictConditional) {
226
226
  return leftHasJSX2(node) && rightHasJSX2(node);
@@ -229,7 +229,7 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
229
229
  }
230
230
  case types.AST_NODE_TYPES.SequenceExpression: {
231
231
  const exp = node.expressions.at(-1);
232
- return isJSXLike(exp, jsxCtx, hint);
232
+ return isJsxLike(code, exp, hint);
233
233
  }
234
234
  case types.AST_NODE_TYPES.CallExpression: {
235
235
  if (hint & JSXDetectionHint.SkipCreateElement) {
@@ -251,9 +251,9 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
251
251
  if (AST__namespace.isJSXTagNameExpression(node)) {
252
252
  return true;
253
253
  }
254
- const variable = VAR__namespace.findVariable(name, jsxCtx.getScope(node));
254
+ const variable = VAR__namespace.findVariable(name, code.getScope(node));
255
255
  const variableNode = variable && VAR__namespace.getVariableInitNode(variable, 0);
256
- return !!variableNode && isJSXLike(variableNode, jsxCtx, hint);
256
+ return !!variableNode && isJsxLike(code, variableNode, hint);
257
257
  }
258
258
  }
259
259
  return false;
@@ -290,11 +290,11 @@ exports.getElementType = getElementType;
290
290
  exports.hasAnyAttribute = hasAnyAttribute;
291
291
  exports.hasAttribute = hasAttribute;
292
292
  exports.hasEveryAttribute = hasEveryAttribute;
293
- exports.isJSXLike = isJSXLike;
294
293
  exports.isJsxBuiltInElement = isJsxBuiltInElement;
295
294
  exports.isJsxFragment = isJsxFragment;
296
295
  exports.isJsxFragmentElement = isJsxFragmentElement;
297
296
  exports.isJsxKeyedElement = isJsxKeyedElement;
297
+ exports.isJsxLike = isJsxLike;
298
298
  exports.isJsxText = isJsxText;
299
299
  exports.isJsxUserDefinedElement = isJsxUserDefinedElement;
300
300
  exports.toString = toString;
package/dist/index.mjs CHANGED
@@ -134,7 +134,7 @@ var JSXDetectionHint = {
134
134
  var DEFAULT_JSX_DETECTION_HINT = 0n | JSXDetectionHint.SkipUndefined | JSXDetectionHint.SkipBooleanLiteral;
135
135
 
136
136
  // src/is-jsx.ts
137
- function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
137
+ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
138
138
  switch (node?.type) {
139
139
  case AST_NODE_TYPES.JSXText:
140
140
  case AST_NODE_TYPES.JSXElement:
@@ -174,15 +174,15 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
174
174
  }
175
175
  case AST_NODE_TYPES.ArrayExpression: {
176
176
  if (hint & JSXDetectionHint.StrictArray) {
177
- return node.elements.every((n) => isJSXLike(n, jsxCtx, hint));
177
+ return node.elements.every((n) => isJsxLike(code, n, hint));
178
178
  }
179
- return node.elements.some((n) => isJSXLike(n, jsxCtx, hint));
179
+ return node.elements.some((n) => isJsxLike(code, n, hint));
180
180
  }
181
181
  case AST_NODE_TYPES.LogicalExpression: {
182
182
  if (hint & JSXDetectionHint.StrictLogical) {
183
- return isJSXLike(node.left, jsxCtx, hint) && isJSXLike(node.right, jsxCtx, hint);
183
+ return isJsxLike(code, node.left, hint) && isJsxLike(code, node.right, hint);
184
184
  }
185
- return isJSXLike(node.left, jsxCtx, hint) || isJSXLike(node.right, jsxCtx, hint);
185
+ return isJsxLike(code, node.left, hint) || isJsxLike(code, node.right, hint);
186
186
  }
187
187
  case AST_NODE_TYPES.ConditionalExpression: {
188
188
  let leftHasJSX2 = function(node2) {
@@ -191,13 +191,13 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
191
191
  return !(hint & JSXDetectionHint.SkipEmptyArray);
192
192
  }
193
193
  if (hint & JSXDetectionHint.StrictArray) {
194
- return node2.consequent.every((n) => isJSXLike(n, jsxCtx, hint));
194
+ return node2.consequent.every((n) => isJsxLike(code, n, hint));
195
195
  }
196
- return node2.consequent.some((n) => isJSXLike(n, jsxCtx, hint));
196
+ return node2.consequent.some((n) => isJsxLike(code, n, hint));
197
197
  }
198
- return isJSXLike(node2.consequent, jsxCtx, hint);
198
+ return isJsxLike(code, node2.consequent, hint);
199
199
  }, rightHasJSX2 = function(node2) {
200
- return isJSXLike(node2.alternate, jsxCtx, hint);
200
+ return isJsxLike(code, node2.alternate, hint);
201
201
  };
202
202
  if (hint & JSXDetectionHint.StrictConditional) {
203
203
  return leftHasJSX2(node) && rightHasJSX2(node);
@@ -206,7 +206,7 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
206
206
  }
207
207
  case AST_NODE_TYPES.SequenceExpression: {
208
208
  const exp = node.expressions.at(-1);
209
- return isJSXLike(exp, jsxCtx, hint);
209
+ return isJsxLike(code, exp, hint);
210
210
  }
211
211
  case AST_NODE_TYPES.CallExpression: {
212
212
  if (hint & JSXDetectionHint.SkipCreateElement) {
@@ -228,9 +228,9 @@ function isJSXLike(node, jsxCtx, hint = DEFAULT_JSX_DETECTION_HINT) {
228
228
  if (AST.isJSXTagNameExpression(node)) {
229
229
  return true;
230
230
  }
231
- const variable = VAR.findVariable(name, jsxCtx.getScope(node));
231
+ const variable = VAR.findVariable(name, code.getScope(node));
232
232
  const variableNode = variable && VAR.getVariableInitNode(variable, 0);
233
- return !!variableNode && isJSXLike(variableNode, jsxCtx, hint);
233
+ return !!variableNode && isJsxLike(code, variableNode, hint);
234
234
  }
235
235
  }
236
236
  return false;
@@ -257,4 +257,4 @@ function isJsxText(node) {
257
257
  return node.type === AST_NODE_TYPES.JSXText || node.type === AST_NODE_TYPES.Literal;
258
258
  }
259
259
 
260
- export { DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getElementType, hasAnyAttribute, hasAttribute, hasEveryAttribute, isJSXLike, isJsxBuiltInElement, isJsxFragment, isJsxFragmentElement, isJsxKeyedElement, isJsxText, isJsxUserDefinedElement, toString };
260
+ export { DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getElementType, hasAnyAttribute, hasAttribute, hasEveryAttribute, isJsxBuiltInElement, isJsxFragment, isJsxFragmentElement, isJsxKeyedElement, isJsxLike, isJsxText, isJsxUserDefinedElement, toString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/jsx",
3
- "version": "1.40.4-next.2",
3
+ "version": "1.40.4-next.3",
4
4
  "description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -39,9 +39,9 @@
39
39
  "@typescript-eslint/types": "^8.29.0",
40
40
  "@typescript-eslint/utils": "^8.29.0",
41
41
  "ts-pattern": "^5.7.0",
42
- "@eslint-react/ast": "1.40.4-next.2",
43
- "@eslint-react/eff": "1.40.4-next.2",
44
- "@eslint-react/var": "1.40.4-next.2"
42
+ "@eslint-react/ast": "1.40.4-next.3",
43
+ "@eslint-react/eff": "1.40.4-next.3",
44
+ "@eslint-react/var": "1.40.4-next.3"
45
45
  },
46
46
  "devDependencies": {
47
47
  "tsup": "^8.4.0",