@eslint-react/jsx 1.5.21-beta.3 → 1.5.21-beta.5

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
@@ -11,21 +11,7 @@ import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
11
11
  */
12
12
  declare function elementType(node: TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment): string;
13
13
 
14
- declare function isKeyedElement(node: TSESTree.Node, context: RuleContext): boolean;
15
- /**
16
- * Check if a node is a `JSXElement` of `User-Defined Component` type
17
- * @param node The AST node to check
18
- * @returns `true` if the node is a `JSXElement` of `User-Defined Component` type
19
- */
20
- declare function isUserDefinedElement(node: TSESTree.Node): boolean;
21
- /**
22
- * Check if a node is a `JSXFragment` of `Built-in Component` type
23
- * @param node The AST node to check
24
- * @returns `true` if the node is a `JSXFragment` of `Built-in Component` type
25
- */
26
- declare function isBuiltInElement(node: TSESTree.Node): boolean;
27
-
28
- declare function getJSXPragmaFromContext(context: RuleContext): Option.Option<string>;
14
+ declare function getJSXPragma(context: RuleContext): Option.Option<string>;
29
15
 
30
16
  /**
31
17
  * Get the name of a JSX attribute with namespace
@@ -89,20 +75,42 @@ declare function hasAnyProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpr
89
75
  */
90
76
  declare function hasEveryProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], propNames: string[], context: RuleContext, initialScope: Scope): boolean;
91
77
 
78
+ declare function isKeyedElement(node: TSESTree.Node, context: RuleContext): boolean;
92
79
  /**
93
- * Checks if the node is inside a prop's value
80
+ * Check if a node is a `JSXElement` of `User-Defined Component` type
94
81
  * @param node The AST node to check
95
- * @returns `true` if the node is inside a prop's value
82
+ * @returns `true` if the node is a `JSXElement` of `User-Defined Component` type
96
83
  */
97
- declare function isInsidePropValue(node: TSESTree.Node): boolean;
84
+ declare function isUserDefinedElement(node: TSESTree.Node): boolean;
85
+ /**
86
+ * Check if a node is a `JSXFragment` of `Built-in Component` type
87
+ * @param node The AST node to check
88
+ * @returns `true` if the node is a `JSXFragment` of `Built-in Component` type
89
+ */
90
+ declare function isBuiltInElement(node: TSESTree.Node): boolean;
98
91
 
92
+ declare const JSXValueHint: {
93
+ readonly None: 0n;
94
+ readonly SkipNullLiteral: bigint;
95
+ readonly SkipUndefinedLiteral: bigint;
96
+ readonly SkipBooleanLiteral: bigint;
97
+ readonly SkipStringLiteral: bigint;
98
+ readonly SkipNumberLiteral: bigint;
99
+ readonly SkipCreateElement: bigint;
100
+ readonly SkipEmptyArray: bigint;
101
+ readonly StrictArray: bigint;
102
+ readonly StrictLogical: bigint;
103
+ readonly StrictConditional: bigint;
104
+ };
105
+ declare const DEFAULT_JSX_VALUE_HINT: bigint;
99
106
  /**
100
- * Traverses up prop node
101
- * @param node The AST node to start traversing from
102
- * @param predicate The predicate to check each node
103
- * @returns prop node if found
107
+ * Check if a node is a JSX value
108
+ * @param node The AST node to check
109
+ * @param context The rule context
110
+ * @param hint The `JSXValueHint` to use
111
+ * @returns boolean
104
112
  */
105
- declare function traverseUpProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): Option.Option<TSESTree.JSXAttribute>;
113
+ declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
106
114
 
107
115
  /**
108
116
  * Check if a node is a Literal or JSXText
@@ -129,27 +137,12 @@ declare function isLineBreak(node: TSESTree.Node): boolean;
129
137
  */
130
138
  declare function isPaddingSpaces(node: TSESTree.Node): boolean;
131
139
 
132
- declare const JSXValueHint: {
133
- readonly None: 0n;
134
- readonly SkipNullLiteral: bigint;
135
- readonly SkipUndefinedLiteral: bigint;
136
- readonly SkipBooleanLiteral: bigint;
137
- readonly SkipStringLiteral: bigint;
138
- readonly SkipNumberLiteral: bigint;
139
- readonly SkipCreateElement: bigint;
140
- readonly SkipEmptyArray: bigint;
141
- readonly StrictArray: bigint;
142
- readonly StrictLogical: bigint;
143
- readonly StrictConditional: bigint;
144
- };
145
- declare const DEFAULT_JSX_VALUE_HINT: bigint;
146
140
  /**
147
- * Check if a node is a JSX value
148
- * @param node The AST node to check
149
- * @param context The rule context
150
- * @param hint The `JSXValueHint` to use
151
- * @returns boolean
141
+ * Traverses up prop node
142
+ * @param node The AST node to start traversing from
143
+ * @param predicate The predicate to check each node
144
+ * @returns prop node if found
152
145
  */
153
- declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
146
+ declare function traverseUpProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): Option.Option<TSESTree.JSXAttribute>;
154
147
 
155
- export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, elementType, findPropInAttributes, findPropInProperties, getJSXPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isInsidePropValue, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp };
148
+ export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, elementType, findPropInAttributes, findPropInProperties, getJSXPragma, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp };
package/dist/index.d.ts CHANGED
@@ -11,21 +11,7 @@ import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
11
11
  */
12
12
  declare function elementType(node: TSESTree.JSXOpeningElement | TSESTree.JSXOpeningFragment): string;
13
13
 
14
- declare function isKeyedElement(node: TSESTree.Node, context: RuleContext): boolean;
15
- /**
16
- * Check if a node is a `JSXElement` of `User-Defined Component` type
17
- * @param node The AST node to check
18
- * @returns `true` if the node is a `JSXElement` of `User-Defined Component` type
19
- */
20
- declare function isUserDefinedElement(node: TSESTree.Node): boolean;
21
- /**
22
- * Check if a node is a `JSXFragment` of `Built-in Component` type
23
- * @param node The AST node to check
24
- * @returns `true` if the node is a `JSXFragment` of `Built-in Component` type
25
- */
26
- declare function isBuiltInElement(node: TSESTree.Node): boolean;
27
-
28
- declare function getJSXPragmaFromContext(context: RuleContext): Option.Option<string>;
14
+ declare function getJSXPragma(context: RuleContext): Option.Option<string>;
29
15
 
30
16
  /**
31
17
  * Get the name of a JSX attribute with namespace
@@ -89,20 +75,42 @@ declare function hasAnyProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpr
89
75
  */
90
76
  declare function hasEveryProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], propNames: string[], context: RuleContext, initialScope: Scope): boolean;
91
77
 
78
+ declare function isKeyedElement(node: TSESTree.Node, context: RuleContext): boolean;
92
79
  /**
93
- * Checks if the node is inside a prop's value
80
+ * Check if a node is a `JSXElement` of `User-Defined Component` type
94
81
  * @param node The AST node to check
95
- * @returns `true` if the node is inside a prop's value
82
+ * @returns `true` if the node is a `JSXElement` of `User-Defined Component` type
96
83
  */
97
- declare function isInsidePropValue(node: TSESTree.Node): boolean;
84
+ declare function isUserDefinedElement(node: TSESTree.Node): boolean;
85
+ /**
86
+ * Check if a node is a `JSXFragment` of `Built-in Component` type
87
+ * @param node The AST node to check
88
+ * @returns `true` if the node is a `JSXFragment` of `Built-in Component` type
89
+ */
90
+ declare function isBuiltInElement(node: TSESTree.Node): boolean;
98
91
 
92
+ declare const JSXValueHint: {
93
+ readonly None: 0n;
94
+ readonly SkipNullLiteral: bigint;
95
+ readonly SkipUndefinedLiteral: bigint;
96
+ readonly SkipBooleanLiteral: bigint;
97
+ readonly SkipStringLiteral: bigint;
98
+ readonly SkipNumberLiteral: bigint;
99
+ readonly SkipCreateElement: bigint;
100
+ readonly SkipEmptyArray: bigint;
101
+ readonly StrictArray: bigint;
102
+ readonly StrictLogical: bigint;
103
+ readonly StrictConditional: bigint;
104
+ };
105
+ declare const DEFAULT_JSX_VALUE_HINT: bigint;
99
106
  /**
100
- * Traverses up prop node
101
- * @param node The AST node to start traversing from
102
- * @param predicate The predicate to check each node
103
- * @returns prop node if found
107
+ * Check if a node is a JSX value
108
+ * @param node The AST node to check
109
+ * @param context The rule context
110
+ * @param hint The `JSXValueHint` to use
111
+ * @returns boolean
104
112
  */
105
- declare function traverseUpProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): Option.Option<TSESTree.JSXAttribute>;
113
+ declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
106
114
 
107
115
  /**
108
116
  * Check if a node is a Literal or JSXText
@@ -129,27 +137,12 @@ declare function isLineBreak(node: TSESTree.Node): boolean;
129
137
  */
130
138
  declare function isPaddingSpaces(node: TSESTree.Node): boolean;
131
139
 
132
- declare const JSXValueHint: {
133
- readonly None: 0n;
134
- readonly SkipNullLiteral: bigint;
135
- readonly SkipUndefinedLiteral: bigint;
136
- readonly SkipBooleanLiteral: bigint;
137
- readonly SkipStringLiteral: bigint;
138
- readonly SkipNumberLiteral: bigint;
139
- readonly SkipCreateElement: bigint;
140
- readonly SkipEmptyArray: bigint;
141
- readonly StrictArray: bigint;
142
- readonly StrictLogical: bigint;
143
- readonly StrictConditional: bigint;
144
- };
145
- declare const DEFAULT_JSX_VALUE_HINT: bigint;
146
140
  /**
147
- * Check if a node is a JSX value
148
- * @param node The AST node to check
149
- * @param context The rule context
150
- * @param hint The `JSXValueHint` to use
151
- * @returns boolean
141
+ * Traverses up prop node
142
+ * @param node The AST node to start traversing from
143
+ * @param predicate The predicate to check each node
144
+ * @returns prop node if found
152
145
  */
153
- declare function isJSXValue(node: TSESTree$1.Node | null | undefined, context: RuleContext, hint?: bigint): boolean;
146
+ declare function traverseUpProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): Option.Option<TSESTree.JSXAttribute>;
154
147
 
155
- export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, elementType, findPropInAttributes, findPropInProperties, getJSXPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isInsidePropValue, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp };
148
+ export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, elementType, findPropInAttributes, findPropInProperties, getJSXPragma, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp };
package/dist/index.js CHANGED
@@ -1872,6 +1872,19 @@ var bind3 = /* @__PURE__ */ bind(map2, flatMap2);
1872
1872
  var bindTo3 = /* @__PURE__ */ bindTo(map2);
1873
1873
  var let_3 = /* @__PURE__ */ let_(map2);
1874
1874
 
1875
+ // src/get-jsx-pragma.ts
1876
+ var RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
1877
+ var RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
1878
+ function getJSXPragma(context) {
1879
+ const { sourceCode } = context;
1880
+ return Function_exports.pipe(
1881
+ Array_exports.findFirst(sourceCode.getAllComments(), (node) => RE_JSX_ANNOTATION_REGEX.test(node.value)),
1882
+ Option_exports.map(({ value }) => RE_JSX_ANNOTATION_REGEX.exec(value)),
1883
+ Option_exports.flatMapNullable((matches) => matches?.[1]),
1884
+ Option_exports.filter((pragma) => RE_JS_IDENTIFIER_REGEX.test(pragma))
1885
+ );
1886
+ }
1887
+
1875
1888
  // ../../../node_modules/.pnpm/ts-pattern@5.2.0/node_modules/ts-pattern/dist/index.js
1876
1889
  var t = Symbol.for("@ts-pattern/matcher");
1877
1890
  var e = Symbol.for("@ts-pattern/isVariadic");
@@ -2126,7 +2139,7 @@ var z = class _z {
2126
2139
  }
2127
2140
  };
2128
2141
 
2129
- // src/prop/get-prop.ts
2142
+ // src/get-prop.ts
2130
2143
  var { getStaticValue } = ast.ESLintCommunityESLintUtils;
2131
2144
  function getPropName(node) {
2132
2145
  return $(node.name).when(ast.is(ast.NodeType.JSXIdentifier), (n2) => n2.name).when(ast.is(ast.NodeType.JSXNamespacedName), (n2) => `${n2.namespace.name}:${n2.name.name}`).exhaustive();
@@ -2206,7 +2219,7 @@ function findPropInAttributes(attributes, context, initialScope) {
2206
2219
  };
2207
2220
  }
2208
2221
 
2209
- // src/prop/has-prop.ts
2222
+ // src/has-prop.ts
2210
2223
  function hasProp(attributes, propName, context, initialScope) {
2211
2224
  return Option_exports.isSome(findPropInAttributes(attributes, context, initialScope)(propName));
2212
2225
  }
@@ -2216,20 +2229,6 @@ function hasAnyProp(attributes, propNames, context, initialScope) {
2216
2229
  function hasEveryProp(attributes, propNames, context, initialScope) {
2217
2230
  return propNames.every((propName) => hasProp(attributes, propName, context, initialScope));
2218
2231
  }
2219
- function traverseUpProp(node, predicate = Function_exports.constTrue) {
2220
- const guard = (node2) => {
2221
- return node2.type === ast.NodeType.JSXAttribute && predicate(node2);
2222
- };
2223
- return ast.traverseUpGuard(node, guard);
2224
- }
2225
-
2226
- // src/prop/misc.ts
2227
- function isInsidePropValue(node) {
2228
- if (ast.isStringLiteral(node)) return node.parent.type === ast.NodeType.JSXAttribute;
2229
- return Option_exports.isSome(traverseUpProp(node, (n2) => n2.value?.type === ast.NodeType.JSXExpressionContainer));
2230
- }
2231
-
2232
- // src/element/is.ts
2233
2232
  function isKeyedElement(node, context) {
2234
2233
  if (node.type !== ast.NodeType.JSXElement) return false;
2235
2234
  return hasProp(node.openingElement.attributes, "key", context, context.sourceCode.getScope(node));
@@ -2242,29 +2241,6 @@ function isBuiltInElement(node) {
2242
2241
  if (node.type !== ast.NodeType.JSXElement) return false;
2243
2242
  return node.openingElement.name.type === ast.NodeType.JSXIdentifier && node.openingElement.name.name.toLowerCase() === node.openingElement.name.name && /^[a-z]/u.test(node.openingElement.name.name);
2244
2243
  }
2245
-
2246
- // src/pragma.ts
2247
- var RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
2248
- var RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
2249
- function getJSXPragmaFromContext(context) {
2250
- const { sourceCode } = context;
2251
- return Function_exports.pipe(
2252
- Array_exports.findFirst(sourceCode.getAllComments(), (node) => RE_JSX_ANNOTATION_REGEX.test(node.value)),
2253
- Option_exports.map(({ value }) => RE_JSX_ANNOTATION_REGEX.exec(value)),
2254
- Option_exports.flatMapNullable((matches) => matches?.[1]),
2255
- Option_exports.filter((pragma) => RE_JS_IDENTIFIER_REGEX.test(pragma))
2256
- );
2257
- }
2258
- var isLiteral = ast.isOneOf([ast.NodeType.Literal, ast.NodeType.JSXText]);
2259
- function isWhiteSpace(node) {
2260
- return Predicate_exports.isString(node.value) && node.value.trim() === "";
2261
- }
2262
- function isLineBreak(node) {
2263
- return isLiteral(node) && isWhiteSpace(node) && ast.isMultiLine(node);
2264
- }
2265
- function isPaddingSpaces(node) {
2266
- return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
2267
- }
2268
2244
  var JSXValueHint = {
2269
2245
  None: 0n,
2270
2246
  SkipNullLiteral: 1n << 0n,
@@ -2328,13 +2304,29 @@ function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HINT) {
2328
2304
  );
2329
2305
  }).otherwise(Function_exports.constFalse);
2330
2306
  }
2307
+ var isLiteral = ast.isOneOf([ast.NodeType.Literal, ast.NodeType.JSXText]);
2308
+ function isWhiteSpace(node) {
2309
+ return Predicate_exports.isString(node.value) && node.value.trim() === "";
2310
+ }
2311
+ function isLineBreak(node) {
2312
+ return isLiteral(node) && isWhiteSpace(node) && ast.isMultiLine(node);
2313
+ }
2314
+ function isPaddingSpaces(node) {
2315
+ return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
2316
+ }
2317
+ function traverseUpProp(node, predicate = Function_exports.constTrue) {
2318
+ const guard = (node2) => {
2319
+ return node2.type === ast.NodeType.JSXAttribute && predicate(node2);
2320
+ };
2321
+ return ast.traverseUpGuard(node, guard);
2322
+ }
2331
2323
 
2332
2324
  exports.DEFAULT_JSX_VALUE_HINT = DEFAULT_JSX_VALUE_HINT;
2333
2325
  exports.JSXValueHint = JSXValueHint;
2334
2326
  exports.elementType = elementType;
2335
2327
  exports.findPropInAttributes = findPropInAttributes;
2336
2328
  exports.findPropInProperties = findPropInProperties;
2337
- exports.getJSXPragmaFromContext = getJSXPragmaFromContext;
2329
+ exports.getJSXPragma = getJSXPragma;
2338
2330
  exports.getProp = getProp;
2339
2331
  exports.getPropName = getPropName;
2340
2332
  exports.getPropValue = getPropValue;
@@ -2342,7 +2334,6 @@ exports.hasAnyProp = hasAnyProp;
2342
2334
  exports.hasEveryProp = hasEveryProp;
2343
2335
  exports.hasProp = hasProp;
2344
2336
  exports.isBuiltInElement = isBuiltInElement;
2345
- exports.isInsidePropValue = isInsidePropValue;
2346
2337
  exports.isJSXValue = isJSXValue;
2347
2338
  exports.isKeyedElement = isKeyedElement;
2348
2339
  exports.isLineBreak = isLineBreak;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
2
- import { isOneOf, NodeType, is, traverseUpGuard, isStringLiteral, isMultiLine, isJSXTagNameExpression, ESLintCommunityESLintUtils } from '@eslint-react/ast';
2
+ import { isOneOf, NodeType, is, isJSXTagNameExpression, isMultiLine, traverseUpGuard, ESLintCommunityESLintUtils } from '@eslint-react/ast';
3
3
  import { findVariable, getVariableInit } from '@eslint-react/var';
4
4
 
5
5
  var __defProp = Object.defineProperty;
@@ -1870,6 +1870,19 @@ var bind3 = /* @__PURE__ */ bind(map2, flatMap2);
1870
1870
  var bindTo3 = /* @__PURE__ */ bindTo(map2);
1871
1871
  var let_3 = /* @__PURE__ */ let_(map2);
1872
1872
 
1873
+ // src/get-jsx-pragma.ts
1874
+ var RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
1875
+ var RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
1876
+ function getJSXPragma(context) {
1877
+ const { sourceCode } = context;
1878
+ return Function_exports.pipe(
1879
+ Array_exports.findFirst(sourceCode.getAllComments(), (node) => RE_JSX_ANNOTATION_REGEX.test(node.value)),
1880
+ Option_exports.map(({ value }) => RE_JSX_ANNOTATION_REGEX.exec(value)),
1881
+ Option_exports.flatMapNullable((matches) => matches?.[1]),
1882
+ Option_exports.filter((pragma) => RE_JS_IDENTIFIER_REGEX.test(pragma))
1883
+ );
1884
+ }
1885
+
1873
1886
  // ../../../node_modules/.pnpm/ts-pattern@5.2.0/node_modules/ts-pattern/dist/index.js
1874
1887
  var t = Symbol.for("@ts-pattern/matcher");
1875
1888
  var e = Symbol.for("@ts-pattern/isVariadic");
@@ -2124,7 +2137,7 @@ var z = class _z {
2124
2137
  }
2125
2138
  };
2126
2139
 
2127
- // src/prop/get-prop.ts
2140
+ // src/get-prop.ts
2128
2141
  var { getStaticValue } = ESLintCommunityESLintUtils;
2129
2142
  function getPropName(node) {
2130
2143
  return $(node.name).when(is(NodeType.JSXIdentifier), (n2) => n2.name).when(is(NodeType.JSXNamespacedName), (n2) => `${n2.namespace.name}:${n2.name.name}`).exhaustive();
@@ -2204,7 +2217,7 @@ function findPropInAttributes(attributes, context, initialScope) {
2204
2217
  };
2205
2218
  }
2206
2219
 
2207
- // src/prop/has-prop.ts
2220
+ // src/has-prop.ts
2208
2221
  function hasProp(attributes, propName, context, initialScope) {
2209
2222
  return Option_exports.isSome(findPropInAttributes(attributes, context, initialScope)(propName));
2210
2223
  }
@@ -2214,20 +2227,6 @@ function hasAnyProp(attributes, propNames, context, initialScope) {
2214
2227
  function hasEveryProp(attributes, propNames, context, initialScope) {
2215
2228
  return propNames.every((propName) => hasProp(attributes, propName, context, initialScope));
2216
2229
  }
2217
- function traverseUpProp(node, predicate = Function_exports.constTrue) {
2218
- const guard = (node2) => {
2219
- return node2.type === NodeType.JSXAttribute && predicate(node2);
2220
- };
2221
- return traverseUpGuard(node, guard);
2222
- }
2223
-
2224
- // src/prop/misc.ts
2225
- function isInsidePropValue(node) {
2226
- if (isStringLiteral(node)) return node.parent.type === NodeType.JSXAttribute;
2227
- return Option_exports.isSome(traverseUpProp(node, (n2) => n2.value?.type === NodeType.JSXExpressionContainer));
2228
- }
2229
-
2230
- // src/element/is.ts
2231
2230
  function isKeyedElement(node, context) {
2232
2231
  if (node.type !== NodeType.JSXElement) return false;
2233
2232
  return hasProp(node.openingElement.attributes, "key", context, context.sourceCode.getScope(node));
@@ -2240,29 +2239,6 @@ function isBuiltInElement(node) {
2240
2239
  if (node.type !== NodeType.JSXElement) return false;
2241
2240
  return node.openingElement.name.type === NodeType.JSXIdentifier && node.openingElement.name.name.toLowerCase() === node.openingElement.name.name && /^[a-z]/u.test(node.openingElement.name.name);
2242
2241
  }
2243
-
2244
- // src/pragma.ts
2245
- var RE_JSX_ANNOTATION_REGEX = /@jsx\s+(\S+)/u;
2246
- var RE_JS_IDENTIFIER_REGEX = /^[$A-Z_a-z][\w$]*$/u;
2247
- function getJSXPragmaFromContext(context) {
2248
- const { sourceCode } = context;
2249
- return Function_exports.pipe(
2250
- Array_exports.findFirst(sourceCode.getAllComments(), (node) => RE_JSX_ANNOTATION_REGEX.test(node.value)),
2251
- Option_exports.map(({ value }) => RE_JSX_ANNOTATION_REGEX.exec(value)),
2252
- Option_exports.flatMapNullable((matches) => matches?.[1]),
2253
- Option_exports.filter((pragma) => RE_JS_IDENTIFIER_REGEX.test(pragma))
2254
- );
2255
- }
2256
- var isLiteral = isOneOf([NodeType.Literal, NodeType.JSXText]);
2257
- function isWhiteSpace(node) {
2258
- return Predicate_exports.isString(node.value) && node.value.trim() === "";
2259
- }
2260
- function isLineBreak(node) {
2261
- return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
2262
- }
2263
- function isPaddingSpaces(node) {
2264
- return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
2265
- }
2266
2242
  var JSXValueHint = {
2267
2243
  None: 0n,
2268
2244
  SkipNullLiteral: 1n << 0n,
@@ -2326,5 +2302,21 @@ function isJSXValue(node, context, hint = DEFAULT_JSX_VALUE_HINT) {
2326
2302
  );
2327
2303
  }).otherwise(Function_exports.constFalse);
2328
2304
  }
2305
+ var isLiteral = isOneOf([NodeType.Literal, NodeType.JSXText]);
2306
+ function isWhiteSpace(node) {
2307
+ return Predicate_exports.isString(node.value) && node.value.trim() === "";
2308
+ }
2309
+ function isLineBreak(node) {
2310
+ return isLiteral(node) && isWhiteSpace(node) && isMultiLine(node);
2311
+ }
2312
+ function isPaddingSpaces(node) {
2313
+ return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
2314
+ }
2315
+ function traverseUpProp(node, predicate = Function_exports.constTrue) {
2316
+ const guard = (node2) => {
2317
+ return node2.type === NodeType.JSXAttribute && predicate(node2);
2318
+ };
2319
+ return traverseUpGuard(node, guard);
2320
+ }
2329
2321
 
2330
- export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, elementType, findPropInAttributes, findPropInProperties, getJSXPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isInsidePropValue, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp };
2322
+ export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, elementType, findPropInAttributes, findPropInProperties, getJSXPragma, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, traverseUpProp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/jsx",
3
- "version": "1.5.21-beta.3",
3
+ "version": "1.5.21-beta.5",
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": {
@@ -38,11 +38,10 @@
38
38
  "@typescript-eslint/scope-manager": "8.0.0-alpha.40",
39
39
  "@typescript-eslint/types": "8.0.0-alpha.40",
40
40
  "@typescript-eslint/utils": "8.0.0-alpha.40",
41
- "@eslint-react/tools": "1.5.21-beta.3",
42
- "@eslint-react/ast": "1.5.21-beta.3",
43
- "@eslint-react/types": "1.5.21-beta.3",
44
- "@eslint-react/var": "1.5.21-beta.3",
45
- "@eslint-react/shared": "1.5.21-beta.3"
41
+ "@eslint-react/ast": "1.5.21-beta.5",
42
+ "@eslint-react/tools": "1.5.21-beta.5",
43
+ "@eslint-react/types": "1.5.21-beta.5",
44
+ "@eslint-react/var": "1.5.21-beta.5"
46
45
  },
47
46
  "devDependencies": {
48
47
  "effect": "3.4.6",