@eslint-react/jsx 1.23.3-next.8 → 1.24.0-next.0

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
@@ -1,10 +1,10 @@
1
- import { O } from '@eslint-react/eff';
1
+ import { _ } from '@eslint-react/eff';
2
2
  import { TSESTree } from '@typescript-eslint/types';
3
+ import * as VAR from '@eslint-react/var';
3
4
  import { Scope } from '@typescript-eslint/scope-manager';
4
5
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
5
- import * as _eslint_react_types from '@eslint-react/types';
6
6
 
7
- declare function findParentProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): O.Option<TSESTree.JSXAttribute>;
7
+ declare function findParentProp(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | _;
8
8
 
9
9
  /**
10
10
  * Returns the tag name associated with a JSXOpeningElement.
@@ -19,36 +19,18 @@ declare function getElementName(node: TSESTree.JSXOpeningElement | TSESTree.JSXO
19
19
  * @returns string
20
20
  */
21
21
  declare function getPropName(node: TSESTree$1.JSXAttribute): string;
22
- declare function getProp(props: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], propName: string, initialScope: Scope): O.Option<TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute>;
22
+ declare function getProp(name: string, initialScope: Scope, props: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[]): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | _;
23
23
  /**
24
24
  * Gets and resolves the static value of a JSX attribute
25
25
  * @param attribute The JSX attribute to get the value of
26
26
  * @param initialScope The initial scope to start from
27
27
  * @returns The static value of the given JSX attribute
28
28
  */
29
- declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): O.None<unknown> | O.Some<unknown>;
30
- /**
31
- * @param properties The properties to search in
32
- * @param initialScope The initial scope to start from
33
- * @param seenProps The properties that have already been seen
34
- * @returns A function that searches for a property in the given properties
35
- */
36
- declare function findPropInProperties(properties: (TSESTree$1.Property | TSESTree$1.RestElement | TSESTree$1.SpreadElement)[], initialScope: Scope, seenProps?: string[]): (propName: string) => O.Option<(typeof properties)[number]>;
37
- /**
38
- * @param attributes The attributes to search in
39
- * @param initialScope The initial scope to start from
40
- * @returns A function that searches for a property in the given attributes
41
- */
42
- declare function findPropInAttributes(attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope: Scope): (propName: string) => O.Option<NonNullable<TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | undefined>>;
29
+ declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): VAR.StaticValue;
30
+ declare function findPropInProperties(name: string, properties: (TSESTree$1.Property | TSESTree$1.RestElement | TSESTree$1.SpreadElement)[], initialScope: Scope, seenProps?: string[]): (typeof properties)[number] | _;
31
+ declare function findPropInAttributes(name: string, initialScope: Scope, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[]): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | _;
43
32
 
44
- /**
45
- * Check if the given prop name is present in the given attributes
46
- * @param attributes The attributes to search in
47
- * @param propName The prop name to search for
48
- * @param initialScope The initial scope to start from
49
- * @returns `true` if the given prop name is present in the given properties
50
- */
51
- declare function hasProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], propName: string, initialScope: Scope): boolean;
33
+ declare function hasProp(propName: string, initialScope: Scope, attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[]): boolean;
52
34
  /**
53
35
  * Check if any of the given prop names are present in the given attributes
54
36
  * @param attributes The attributes to search in
@@ -103,7 +85,7 @@ declare const DEFAULT_JSX_VALUE_HINT: bigint;
103
85
  * @param hint The `JSXValueHint` to use
104
86
  * @returns boolean
105
87
  */
106
- declare function isJSXValue(node: null | TSESTree$1.Node | undefined, jsxCtx: {
88
+ declare function isJSXValue(node: TSESTree$1.Node | _ | null, jsxCtx: {
107
89
  getScope: (node: TSESTree$1.Node) => Scope;
108
90
  }, hint?: bigint): boolean;
109
91
 
@@ -139,260 +121,6 @@ declare function isPaddingSpaces(node: TSESTree.Node): boolean;
139
121
  */
140
122
  declare function unescapeStringLiteralText(text: string): string;
141
123
 
142
- declare const xhtmlEntities: _eslint_react_types.BiRecord<{
143
- readonly Aacute: "Á";
144
- readonly aacute: "á";
145
- readonly Acirc: "Â";
146
- readonly acirc: "â";
147
- readonly acute: "´";
148
- readonly AElig: "Æ";
149
- readonly aelig: "æ";
150
- readonly Agrave: "À";
151
- readonly agrave: "à";
152
- readonly alefsym: "ℵ";
153
- readonly Alpha: "Α";
154
- readonly alpha: "α";
155
- readonly amp: "&";
156
- readonly and: "∧";
157
- readonly ang: "∠";
158
- readonly apos: "'";
159
- readonly Aring: "Å";
160
- readonly aring: "å";
161
- readonly asymp: "≈";
162
- readonly Atilde: "Ã";
163
- readonly atilde: "ã";
164
- readonly Auml: "Ä";
165
- readonly auml: "ä";
166
- readonly bdquo: "„";
167
- readonly Beta: "Β";
168
- readonly beta: "β";
169
- readonly brvbar: "¦";
170
- readonly bull: "•";
171
- readonly cap: "∩";
172
- readonly Ccedil: "Ç";
173
- readonly ccedil: "ç";
174
- readonly cedil: "¸";
175
- readonly cent: "¢";
176
- readonly Chi: "Χ";
177
- readonly chi: "χ";
178
- readonly circ: "ˆ";
179
- readonly clubs: "♣";
180
- readonly cong: "≅";
181
- readonly copy: "©";
182
- readonly crarr: "↵";
183
- readonly cup: "∪";
184
- readonly curren: "¤";
185
- readonly dagger: "†";
186
- readonly Dagger: "‡";
187
- readonly darr: "↓";
188
- readonly dArr: "⇓";
189
- readonly deg: "°";
190
- readonly Delta: "Δ";
191
- readonly delta: "δ";
192
- readonly diams: "♦";
193
- readonly divide: "÷";
194
- readonly Eacute: "É";
195
- readonly eacute: "é";
196
- readonly Ecirc: "Ê";
197
- readonly ecirc: "ê";
198
- readonly Egrave: "È";
199
- readonly egrave: "è";
200
- readonly empty: "∅";
201
- readonly emsp: " ";
202
- readonly ensp: " ";
203
- readonly Epsilon: "Ε";
204
- readonly epsilon: "ε";
205
- readonly equiv: "≡";
206
- readonly Eta: "Η";
207
- readonly eta: "η";
208
- readonly ETH: "Ð";
209
- readonly eth: "ð";
210
- readonly Euml: "Ë";
211
- readonly euml: "ë";
212
- readonly euro: "€";
213
- readonly exist: "∃";
214
- readonly fnof: "ƒ";
215
- readonly forall: "∀";
216
- readonly frac12: "½";
217
- readonly frac14: "¼";
218
- readonly frac34: "¾";
219
- readonly frasl: "⁄";
220
- readonly Gamma: "Γ";
221
- readonly gamma: "γ";
222
- readonly ge: "≥";
223
- readonly gt: ">";
224
- readonly harr: "↔";
225
- readonly hArr: "⇔";
226
- readonly hearts: "♥";
227
- readonly hellip: "…";
228
- readonly Iacute: "Í";
229
- readonly iacute: "í";
230
- readonly Icirc: "Î";
231
- readonly icirc: "î";
232
- readonly iexcl: "¡";
233
- readonly Igrave: "Ì";
234
- readonly igrave: "ì";
235
- readonly image: "ℑ";
236
- readonly infin: "∞";
237
- readonly int: "∫";
238
- readonly Iota: "Ι";
239
- readonly iota: "ι";
240
- readonly iquest: "¿";
241
- readonly isin: "∈";
242
- readonly Iuml: "Ï";
243
- readonly iuml: "ï";
244
- readonly Kappa: "Κ";
245
- readonly kappa: "κ";
246
- readonly Lambda: "Λ";
247
- readonly lambda: "λ";
248
- readonly lang: "〈";
249
- readonly laquo: "«";
250
- readonly larr: "←";
251
- readonly lArr: "⇐";
252
- readonly lceil: "⌈";
253
- readonly ldquo: "“";
254
- readonly le: "≤";
255
- readonly lfloor: "⌊";
256
- readonly lowast: "∗";
257
- readonly loz: "◊";
258
- readonly lrm: "‎";
259
- readonly lsaquo: "‹";
260
- readonly lsquo: "‘";
261
- readonly lt: "<";
262
- readonly macr: "¯";
263
- readonly mdash: "—";
264
- readonly micro: "µ";
265
- readonly middot: "·";
266
- readonly minus: "−";
267
- readonly Mu: "Μ";
268
- readonly mu: "μ";
269
- readonly nabla: "∇";
270
- readonly nbsp: " ";
271
- readonly ndash: "–";
272
- readonly ne: "≠";
273
- readonly ni: "∋";
274
- readonly not: "¬";
275
- readonly notin: "∉";
276
- readonly nsub: "⊄";
277
- readonly Ntilde: "Ñ";
278
- readonly ntilde: "ñ";
279
- readonly Nu: "Ν";
280
- readonly nu: "ν";
281
- readonly Oacute: "Ó";
282
- readonly oacute: "ó";
283
- readonly Ocirc: "Ô";
284
- readonly ocirc: "ô";
285
- readonly OElig: "Œ";
286
- readonly oelig: "œ";
287
- readonly Ograve: "Ò";
288
- readonly ograve: "ò";
289
- readonly oline: "‾";
290
- readonly Omega: "Ω";
291
- readonly omega: "ω";
292
- readonly Omicron: "Ο";
293
- readonly omicron: "ο";
294
- readonly oplus: "⊕";
295
- readonly or: "∨";
296
- readonly ordf: "ª";
297
- readonly ordm: "º";
298
- readonly Oslash: "Ø";
299
- readonly oslash: "ø";
300
- readonly Otilde: "Õ";
301
- readonly otilde: "õ";
302
- readonly otimes: "⊗";
303
- readonly Ouml: "Ö";
304
- readonly ouml: "ö";
305
- readonly para: "¶";
306
- readonly part: "∂";
307
- readonly permil: "‰";
308
- readonly perp: "⊥";
309
- readonly Phi: "Φ";
310
- readonly phi: "φ";
311
- readonly Pi: "Π";
312
- readonly pi: "π";
313
- readonly piv: "ϖ";
314
- readonly plusmn: "±";
315
- readonly pound: "£";
316
- readonly prime: "′";
317
- readonly Prime: "″";
318
- readonly prod: "∏";
319
- readonly prop: "∝";
320
- readonly Psi: "Ψ";
321
- readonly psi: "ψ";
322
- readonly quot: "\"";
323
- readonly radic: "√";
324
- readonly rang: "〉";
325
- readonly raquo: "»";
326
- readonly rarr: "→";
327
- readonly rArr: "⇒";
328
- readonly rceil: "⌉";
329
- readonly rdquo: "”";
330
- readonly real: "ℜ";
331
- readonly reg: "®";
332
- readonly rfloor: "⌋";
333
- readonly Rho: "Ρ";
334
- readonly rho: "ρ";
335
- readonly rlm: "‏";
336
- readonly rsaquo: "›";
337
- readonly rsquo: "’";
338
- readonly sbquo: "‚";
339
- readonly Scaron: "Š";
340
- readonly scaron: "š";
341
- readonly sdot: "⋅";
342
- readonly sect: "§";
343
- readonly shy: "­";
344
- readonly Sigma: "Σ";
345
- readonly sigma: "σ";
346
- readonly sigmaf: "ς";
347
- readonly sim: "∼";
348
- readonly spades: "♠";
349
- readonly sub: "⊂";
350
- readonly sube: "⊆";
351
- readonly sum: "∑";
352
- readonly sup: "⊃";
353
- readonly sup1: "¹";
354
- readonly sup2: "²";
355
- readonly sup3: "³";
356
- readonly supe: "⊇";
357
- readonly szlig: "ß";
358
- readonly Tau: "Τ";
359
- readonly tau: "τ";
360
- readonly there4: "∴";
361
- readonly Theta: "Θ";
362
- readonly theta: "θ";
363
- readonly thetasym: "ϑ";
364
- readonly thinsp: " ";
365
- readonly THORN: "Þ";
366
- readonly thorn: "þ";
367
- readonly tilde: "˜";
368
- readonly times: "×";
369
- readonly trade: "™";
370
- readonly Uacute: "Ú";
371
- readonly uacute: "ú";
372
- readonly uarr: "↑";
373
- readonly uArr: "⇑";
374
- readonly Ucirc: "Û";
375
- readonly ucirc: "û";
376
- readonly Ugrave: "Ù";
377
- readonly ugrave: "ù";
378
- readonly uml: "¨";
379
- readonly upsih: "ϒ";
380
- readonly Upsilon: "Υ";
381
- readonly upsilon: "υ";
382
- readonly Uuml: "Ü";
383
- readonly uuml: "ü";
384
- readonly weierp: "℘";
385
- readonly Xi: "Ξ";
386
- readonly xi: "ξ";
387
- readonly Yacute: "Ý";
388
- readonly yacute: "ý";
389
- readonly yen: "¥";
390
- readonly yuml: "ÿ";
391
- readonly Yuml: "Ÿ";
392
- readonly Zeta: "Ζ";
393
- readonly zeta: "ζ";
394
- readonly zwj: "‍";
395
- readonly zwnj: "‌";
396
- }>;
124
+ declare const xhtmlEntities: Record<string, string>;
397
125
 
398
126
  export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findParentProp, findPropInAttributes, findPropInProperties, getElementName, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, unescapeStringLiteralText, xhtmlEntities };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { O } from '@eslint-react/eff';
1
+ import { _ } from '@eslint-react/eff';
2
2
  import { TSESTree } from '@typescript-eslint/types';
3
+ import * as VAR from '@eslint-react/var';
3
4
  import { Scope } from '@typescript-eslint/scope-manager';
4
5
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
5
- import * as _eslint_react_types from '@eslint-react/types';
6
6
 
7
- declare function findParentProp(node: TSESTree.Node, predicate?: (node: TSESTree.JSXAttribute) => boolean): O.Option<TSESTree.JSXAttribute>;
7
+ declare function findParentProp(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | _;
8
8
 
9
9
  /**
10
10
  * Returns the tag name associated with a JSXOpeningElement.
@@ -19,36 +19,18 @@ declare function getElementName(node: TSESTree.JSXOpeningElement | TSESTree.JSXO
19
19
  * @returns string
20
20
  */
21
21
  declare function getPropName(node: TSESTree$1.JSXAttribute): string;
22
- declare function getProp(props: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], propName: string, initialScope: Scope): O.Option<TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute>;
22
+ declare function getProp(name: string, initialScope: Scope, props: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[]): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | _;
23
23
  /**
24
24
  * Gets and resolves the static value of a JSX attribute
25
25
  * @param attribute The JSX attribute to get the value of
26
26
  * @param initialScope The initial scope to start from
27
27
  * @returns The static value of the given JSX attribute
28
28
  */
29
- declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): O.None<unknown> | O.Some<unknown>;
30
- /**
31
- * @param properties The properties to search in
32
- * @param initialScope The initial scope to start from
33
- * @param seenProps The properties that have already been seen
34
- * @returns A function that searches for a property in the given properties
35
- */
36
- declare function findPropInProperties(properties: (TSESTree$1.Property | TSESTree$1.RestElement | TSESTree$1.SpreadElement)[], initialScope: Scope, seenProps?: string[]): (propName: string) => O.Option<(typeof properties)[number]>;
37
- /**
38
- * @param attributes The attributes to search in
39
- * @param initialScope The initial scope to start from
40
- * @returns A function that searches for a property in the given attributes
41
- */
42
- declare function findPropInAttributes(attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope: Scope): (propName: string) => O.Option<NonNullable<TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | undefined>>;
29
+ declare function getPropValue(attribute: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, initialScope: Scope): VAR.StaticValue;
30
+ declare function findPropInProperties(name: string, properties: (TSESTree$1.Property | TSESTree$1.RestElement | TSESTree$1.SpreadElement)[], initialScope: Scope, seenProps?: string[]): (typeof properties)[number] | _;
31
+ declare function findPropInAttributes(name: string, initialScope: Scope, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[]): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | _;
43
32
 
44
- /**
45
- * Check if the given prop name is present in the given attributes
46
- * @param attributes The attributes to search in
47
- * @param propName The prop name to search for
48
- * @param initialScope The initial scope to start from
49
- * @returns `true` if the given prop name is present in the given properties
50
- */
51
- declare function hasProp(attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[], propName: string, initialScope: Scope): boolean;
33
+ declare function hasProp(propName: string, initialScope: Scope, attributes: (TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute)[]): boolean;
52
34
  /**
53
35
  * Check if any of the given prop names are present in the given attributes
54
36
  * @param attributes The attributes to search in
@@ -103,7 +85,7 @@ declare const DEFAULT_JSX_VALUE_HINT: bigint;
103
85
  * @param hint The `JSXValueHint` to use
104
86
  * @returns boolean
105
87
  */
106
- declare function isJSXValue(node: null | TSESTree$1.Node | undefined, jsxCtx: {
88
+ declare function isJSXValue(node: TSESTree$1.Node | _ | null, jsxCtx: {
107
89
  getScope: (node: TSESTree$1.Node) => Scope;
108
90
  }, hint?: bigint): boolean;
109
91
 
@@ -139,260 +121,6 @@ declare function isPaddingSpaces(node: TSESTree.Node): boolean;
139
121
  */
140
122
  declare function unescapeStringLiteralText(text: string): string;
141
123
 
142
- declare const xhtmlEntities: _eslint_react_types.BiRecord<{
143
- readonly Aacute: "Á";
144
- readonly aacute: "á";
145
- readonly Acirc: "Â";
146
- readonly acirc: "â";
147
- readonly acute: "´";
148
- readonly AElig: "Æ";
149
- readonly aelig: "æ";
150
- readonly Agrave: "À";
151
- readonly agrave: "à";
152
- readonly alefsym: "ℵ";
153
- readonly Alpha: "Α";
154
- readonly alpha: "α";
155
- readonly amp: "&";
156
- readonly and: "∧";
157
- readonly ang: "∠";
158
- readonly apos: "'";
159
- readonly Aring: "Å";
160
- readonly aring: "å";
161
- readonly asymp: "≈";
162
- readonly Atilde: "Ã";
163
- readonly atilde: "ã";
164
- readonly Auml: "Ä";
165
- readonly auml: "ä";
166
- readonly bdquo: "„";
167
- readonly Beta: "Β";
168
- readonly beta: "β";
169
- readonly brvbar: "¦";
170
- readonly bull: "•";
171
- readonly cap: "∩";
172
- readonly Ccedil: "Ç";
173
- readonly ccedil: "ç";
174
- readonly cedil: "¸";
175
- readonly cent: "¢";
176
- readonly Chi: "Χ";
177
- readonly chi: "χ";
178
- readonly circ: "ˆ";
179
- readonly clubs: "♣";
180
- readonly cong: "≅";
181
- readonly copy: "©";
182
- readonly crarr: "↵";
183
- readonly cup: "∪";
184
- readonly curren: "¤";
185
- readonly dagger: "†";
186
- readonly Dagger: "‡";
187
- readonly darr: "↓";
188
- readonly dArr: "⇓";
189
- readonly deg: "°";
190
- readonly Delta: "Δ";
191
- readonly delta: "δ";
192
- readonly diams: "♦";
193
- readonly divide: "÷";
194
- readonly Eacute: "É";
195
- readonly eacute: "é";
196
- readonly Ecirc: "Ê";
197
- readonly ecirc: "ê";
198
- readonly Egrave: "È";
199
- readonly egrave: "è";
200
- readonly empty: "∅";
201
- readonly emsp: " ";
202
- readonly ensp: " ";
203
- readonly Epsilon: "Ε";
204
- readonly epsilon: "ε";
205
- readonly equiv: "≡";
206
- readonly Eta: "Η";
207
- readonly eta: "η";
208
- readonly ETH: "Ð";
209
- readonly eth: "ð";
210
- readonly Euml: "Ë";
211
- readonly euml: "ë";
212
- readonly euro: "€";
213
- readonly exist: "∃";
214
- readonly fnof: "ƒ";
215
- readonly forall: "∀";
216
- readonly frac12: "½";
217
- readonly frac14: "¼";
218
- readonly frac34: "¾";
219
- readonly frasl: "⁄";
220
- readonly Gamma: "Γ";
221
- readonly gamma: "γ";
222
- readonly ge: "≥";
223
- readonly gt: ">";
224
- readonly harr: "↔";
225
- readonly hArr: "⇔";
226
- readonly hearts: "♥";
227
- readonly hellip: "…";
228
- readonly Iacute: "Í";
229
- readonly iacute: "í";
230
- readonly Icirc: "Î";
231
- readonly icirc: "î";
232
- readonly iexcl: "¡";
233
- readonly Igrave: "Ì";
234
- readonly igrave: "ì";
235
- readonly image: "ℑ";
236
- readonly infin: "∞";
237
- readonly int: "∫";
238
- readonly Iota: "Ι";
239
- readonly iota: "ι";
240
- readonly iquest: "¿";
241
- readonly isin: "∈";
242
- readonly Iuml: "Ï";
243
- readonly iuml: "ï";
244
- readonly Kappa: "Κ";
245
- readonly kappa: "κ";
246
- readonly Lambda: "Λ";
247
- readonly lambda: "λ";
248
- readonly lang: "〈";
249
- readonly laquo: "«";
250
- readonly larr: "←";
251
- readonly lArr: "⇐";
252
- readonly lceil: "⌈";
253
- readonly ldquo: "“";
254
- readonly le: "≤";
255
- readonly lfloor: "⌊";
256
- readonly lowast: "∗";
257
- readonly loz: "◊";
258
- readonly lrm: "‎";
259
- readonly lsaquo: "‹";
260
- readonly lsquo: "‘";
261
- readonly lt: "<";
262
- readonly macr: "¯";
263
- readonly mdash: "—";
264
- readonly micro: "µ";
265
- readonly middot: "·";
266
- readonly minus: "−";
267
- readonly Mu: "Μ";
268
- readonly mu: "μ";
269
- readonly nabla: "∇";
270
- readonly nbsp: " ";
271
- readonly ndash: "–";
272
- readonly ne: "≠";
273
- readonly ni: "∋";
274
- readonly not: "¬";
275
- readonly notin: "∉";
276
- readonly nsub: "⊄";
277
- readonly Ntilde: "Ñ";
278
- readonly ntilde: "ñ";
279
- readonly Nu: "Ν";
280
- readonly nu: "ν";
281
- readonly Oacute: "Ó";
282
- readonly oacute: "ó";
283
- readonly Ocirc: "Ô";
284
- readonly ocirc: "ô";
285
- readonly OElig: "Œ";
286
- readonly oelig: "œ";
287
- readonly Ograve: "Ò";
288
- readonly ograve: "ò";
289
- readonly oline: "‾";
290
- readonly Omega: "Ω";
291
- readonly omega: "ω";
292
- readonly Omicron: "Ο";
293
- readonly omicron: "ο";
294
- readonly oplus: "⊕";
295
- readonly or: "∨";
296
- readonly ordf: "ª";
297
- readonly ordm: "º";
298
- readonly Oslash: "Ø";
299
- readonly oslash: "ø";
300
- readonly Otilde: "Õ";
301
- readonly otilde: "õ";
302
- readonly otimes: "⊗";
303
- readonly Ouml: "Ö";
304
- readonly ouml: "ö";
305
- readonly para: "¶";
306
- readonly part: "∂";
307
- readonly permil: "‰";
308
- readonly perp: "⊥";
309
- readonly Phi: "Φ";
310
- readonly phi: "φ";
311
- readonly Pi: "Π";
312
- readonly pi: "π";
313
- readonly piv: "ϖ";
314
- readonly plusmn: "±";
315
- readonly pound: "£";
316
- readonly prime: "′";
317
- readonly Prime: "″";
318
- readonly prod: "∏";
319
- readonly prop: "∝";
320
- readonly Psi: "Ψ";
321
- readonly psi: "ψ";
322
- readonly quot: "\"";
323
- readonly radic: "√";
324
- readonly rang: "〉";
325
- readonly raquo: "»";
326
- readonly rarr: "→";
327
- readonly rArr: "⇒";
328
- readonly rceil: "⌉";
329
- readonly rdquo: "”";
330
- readonly real: "ℜ";
331
- readonly reg: "®";
332
- readonly rfloor: "⌋";
333
- readonly Rho: "Ρ";
334
- readonly rho: "ρ";
335
- readonly rlm: "‏";
336
- readonly rsaquo: "›";
337
- readonly rsquo: "’";
338
- readonly sbquo: "‚";
339
- readonly Scaron: "Š";
340
- readonly scaron: "š";
341
- readonly sdot: "⋅";
342
- readonly sect: "§";
343
- readonly shy: "­";
344
- readonly Sigma: "Σ";
345
- readonly sigma: "σ";
346
- readonly sigmaf: "ς";
347
- readonly sim: "∼";
348
- readonly spades: "♠";
349
- readonly sub: "⊂";
350
- readonly sube: "⊆";
351
- readonly sum: "∑";
352
- readonly sup: "⊃";
353
- readonly sup1: "¹";
354
- readonly sup2: "²";
355
- readonly sup3: "³";
356
- readonly supe: "⊇";
357
- readonly szlig: "ß";
358
- readonly Tau: "Τ";
359
- readonly tau: "τ";
360
- readonly there4: "∴";
361
- readonly Theta: "Θ";
362
- readonly theta: "θ";
363
- readonly thetasym: "ϑ";
364
- readonly thinsp: " ";
365
- readonly THORN: "Þ";
366
- readonly thorn: "þ";
367
- readonly tilde: "˜";
368
- readonly times: "×";
369
- readonly trade: "™";
370
- readonly Uacute: "Ú";
371
- readonly uacute: "ú";
372
- readonly uarr: "↑";
373
- readonly uArr: "⇑";
374
- readonly Ucirc: "Û";
375
- readonly ucirc: "û";
376
- readonly Ugrave: "Ù";
377
- readonly ugrave: "ù";
378
- readonly uml: "¨";
379
- readonly upsih: "ϒ";
380
- readonly Upsilon: "Υ";
381
- readonly upsilon: "υ";
382
- readonly Uuml: "Ü";
383
- readonly uuml: "ü";
384
- readonly weierp: "℘";
385
- readonly Xi: "Ξ";
386
- readonly xi: "ξ";
387
- readonly Yacute: "Ý";
388
- readonly yacute: "ý";
389
- readonly yen: "¥";
390
- readonly yuml: "ÿ";
391
- readonly Yuml: "Ÿ";
392
- readonly Zeta: "Ζ";
393
- readonly zeta: "ζ";
394
- readonly zwj: "‍";
395
- readonly zwnj: "‌";
396
- }>;
124
+ declare const xhtmlEntities: Record<string, string>;
397
125
 
398
126
  export { DEFAULT_JSX_VALUE_HINT, JSXValueHint, findParentProp, findPropInAttributes, findPropInProperties, getElementName, getProp, getPropName, getPropValue, hasAnyProp, hasEveryProp, hasProp, isBuiltInElement, isJSXValue, isKeyedElement, isLineBreak, isLiteral, isPaddingSpaces, isUserDefinedElement, isWhiteSpace, unescapeStringLiteralText, xhtmlEntities };
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var AST2 = require('@eslint-react/ast');
3
+ var AST3 = require('@eslint-react/ast');
4
4
  var eff = require('@eslint-react/eff');
5
5
  var types = require('@typescript-eslint/types');
6
6
  var VAR = require('@eslint-react/var');
7
- var types$1 = require('@eslint-react/types');
8
7
 
9
8
  function _interopNamespace(e) {
10
9
  if (e && e.__esModule) return e;
@@ -24,15 +23,15 @@ function _interopNamespace(e) {
24
23
  return Object.freeze(n);
25
24
  }
26
25
 
27
- var AST2__namespace = /*#__PURE__*/_interopNamespace(AST2);
26
+ var AST3__namespace = /*#__PURE__*/_interopNamespace(AST3);
28
27
  var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
29
28
 
30
29
  // src/find-parent-prop.ts
31
- function findParentProp(node, predicate = eff.F.constTrue) {
30
+ function findParentProp(node, test = eff.returnTrue) {
32
31
  const guard = (node2) => {
33
- return node2.type === types.AST_NODE_TYPES.JSXAttribute && predicate(node2);
32
+ return node2.type === types.AST_NODE_TYPES.JSXAttribute && test(node2);
34
33
  };
35
- return AST2__namespace.findParentNodeGuard(node, guard);
34
+ return AST3__namespace.findParentNodeGuard(node, guard);
36
35
  }
37
36
  function resolveJSXMemberExpressions(object, property) {
38
37
  if (object.type === types.AST_NODE_TYPES.JSXMemberExpression) {
@@ -65,114 +64,108 @@ function getPropName(node) {
65
64
  return `${node.name.namespace.name}:${node.name.name.name}`;
66
65
  }
67
66
  }
68
- function getProp(props, propName, initialScope) {
69
- return findPropInAttributes(props, initialScope)(propName);
67
+ function getProp(name, initialScope, props) {
68
+ return findPropInAttributes(name, initialScope, props);
70
69
  }
71
70
  function getPropValue(attribute, initialScope) {
72
- if (attribute.type === types.AST_NODE_TYPES.JSXAttribute && "value" in attribute) {
73
- const { value } = attribute;
74
- if (value == null) {
75
- return eff.O.none();
76
- }
77
- if (value.type === types.AST_NODE_TYPES.Literal) {
78
- return VAR__namespace.getStaticValue(value, initialScope);
79
- }
80
- if (value.type === types.AST_NODE_TYPES.JSXExpressionContainer) {
81
- return VAR__namespace.getStaticValue(value.expression, initialScope);
82
- }
83
- return eff.O.none();
71
+ switch (attribute.type) {
72
+ case types.AST_NODE_TYPES.JSXAttribute:
73
+ if (attribute.value?.type === types.AST_NODE_TYPES.Literal) {
74
+ return {
75
+ kind: "some",
76
+ node: attribute.value,
77
+ initialScope,
78
+ value: attribute.value.value
79
+ };
80
+ }
81
+ if (attribute.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) {
82
+ return {
83
+ kind: "lazy",
84
+ node: attribute.value.expression,
85
+ initialScope
86
+ };
87
+ }
88
+ return { kind: "none", node: attribute, initialScope };
89
+ case types.AST_NODE_TYPES.JSXSpreadAttribute:
90
+ return {
91
+ kind: "lazy",
92
+ node: attribute.argument,
93
+ initialScope
94
+ };
95
+ default:
96
+ return { kind: "none", node: attribute, initialScope };
84
97
  }
85
- const { argument } = attribute;
86
- return VAR__namespace.getStaticValue(argument, initialScope);
87
98
  }
88
- function findPropInProperties(properties, initialScope, seenProps = []) {
89
- return (propName) => {
90
- return eff.O.fromNullable(
91
- properties.findLast((prop) => {
92
- switch (true) {
93
- case (prop.type === types.AST_NODE_TYPES.Property && "name" in prop.key && prop.key.name === propName):
94
- return true;
95
- case prop.type === types.AST_NODE_TYPES.SpreadElement:
96
- switch (true) {
97
- case prop.argument.type === types.AST_NODE_TYPES.Identifier: {
98
- const { name } = prop.argument;
99
- if (seenProps.includes(name)) {
100
- return false;
101
- }
102
- return eff.F.pipe(
103
- VAR__namespace.findVariable(name, initialScope),
104
- eff.O.flatMap(VAR__namespace.getVariableNode(0)),
105
- eff.O.filter(AST2__namespace.is(types.AST_NODE_TYPES.ObjectExpression)),
106
- eff.O.flatMap(
107
- (init) => findPropInProperties(init.properties, initialScope, [...seenProps, name])(propName)
108
- ),
109
- eff.O.isSome
110
- );
111
- }
112
- case prop.argument.type === types.AST_NODE_TYPES.ObjectExpression: {
113
- return eff.O.isSome(
114
- findPropInProperties(prop.argument.properties, initialScope, seenProps)(propName)
115
- );
116
- }
117
- default: {
118
- return false;
119
- }
120
- }
121
- case prop.type === types.AST_NODE_TYPES.RestElement:
122
- return false;
123
- default:
99
+ function findPropInProperties(name, properties, initialScope, seenProps = []) {
100
+ return properties.findLast((prop) => {
101
+ if (prop.type === types.AST_NODE_TYPES.Property) {
102
+ return "name" in prop.key && prop.key.name === name;
103
+ }
104
+ if (prop.type === types.AST_NODE_TYPES.SpreadElement) {
105
+ switch (prop.argument.type) {
106
+ case types.AST_NODE_TYPES.Identifier: {
107
+ if (seenProps.includes(prop.argument.name)) {
124
108
  return false;
109
+ }
110
+ const variable = VAR__namespace.findVariable(prop.argument.name, initialScope);
111
+ const variableNode = VAR__namespace.getVariableNode(variable, 0);
112
+ if (variableNode?.type === types.AST_NODE_TYPES.ObjectExpression) {
113
+ return findPropInProperties(
114
+ name,
115
+ variableNode.properties,
116
+ initialScope,
117
+ [...seenProps, prop.argument.name]
118
+ ) !== eff._;
119
+ }
120
+ return false;
125
121
  }
126
- })
127
- );
128
- };
122
+ case types.AST_NODE_TYPES.ObjectExpression: {
123
+ return findPropInProperties(
124
+ name,
125
+ prop.argument.properties,
126
+ initialScope,
127
+ seenProps
128
+ ) !== eff._;
129
+ }
130
+ }
131
+ return false;
132
+ }
133
+ return false;
134
+ });
129
135
  }
130
- function findPropInAttributes(attributes, initialScope) {
131
- return (propName) => {
132
- return eff.O.fromNullable(
133
- attributes.findLast((attr) => {
134
- switch (attr.type) {
135
- case types.AST_NODE_TYPES.JSXAttribute:
136
- return getPropName(attr) === propName;
137
- case types.AST_NODE_TYPES.JSXSpreadAttribute:
138
- switch (attr.argument.type) {
139
- case types.AST_NODE_TYPES.CallExpression:
140
- return false;
141
- case types.AST_NODE_TYPES.Identifier: {
142
- const { name } = attr.argument;
143
- return eff.F.pipe(
144
- VAR__namespace.findVariable(name, initialScope),
145
- eff.O.flatMap(VAR__namespace.getVariableNode(0)),
146
- eff.O.filter(AST2__namespace.is(types.AST_NODE_TYPES.ObjectExpression)),
147
- eff.O.flatMap((init) => findPropInProperties(init.properties, initialScope)(propName)),
148
- eff.O.isSome
149
- );
150
- }
151
- case types.AST_NODE_TYPES.MemberExpression:
152
- return false;
153
- case types.AST_NODE_TYPES.ObjectExpression:
154
- return eff.O.isSome(findPropInProperties(attr.argument.properties, initialScope)(propName));
155
- default:
156
- return false;
157
- }
158
- default:
159
- return false;
136
+ function findPropInAttributes(name, initialScope, attributes) {
137
+ return attributes.findLast((attr) => {
138
+ if (attr.type === types.AST_NODE_TYPES.JSXAttribute) {
139
+ return getPropName(attr) === name;
140
+ }
141
+ switch (attr.argument.type) {
142
+ case types.AST_NODE_TYPES.Identifier: {
143
+ const variable = VAR__namespace.findVariable(attr.argument.name, initialScope);
144
+ const variableNode = VAR__namespace.getVariableNode(variable, 0);
145
+ if (variableNode?.type === types.AST_NODE_TYPES.ObjectExpression) {
146
+ return findPropInProperties(name, variableNode.properties, initialScope) !== eff._;
160
147
  }
161
- })
162
- );
163
- };
148
+ return false;
149
+ }
150
+ case types.AST_NODE_TYPES.ObjectExpression:
151
+ return findPropInProperties(name, attr.argument.properties, initialScope) !== eff._;
152
+ }
153
+ return false;
154
+ });
164
155
  }
165
- function hasProp(attributes, propName, initialScope) {
166
- return eff.O.isSome(findPropInAttributes(attributes, initialScope)(propName));
156
+
157
+ // src/has-prop.ts
158
+ function hasProp(propName, initialScope, attributes) {
159
+ return !!findPropInAttributes(propName, initialScope, attributes);
167
160
  }
168
161
  function hasAnyProp(attributes, propNames, initialScope) {
169
- return propNames.some((propName) => hasProp(attributes, propName, initialScope));
162
+ return propNames.some((propName) => hasProp(propName, initialScope, attributes));
170
163
  }
171
164
  function hasEveryProp(attributes, propNames, initialScope) {
172
- return propNames.every((propName) => hasProp(attributes, propName, initialScope));
165
+ return propNames.every((propName) => hasProp(propName, initialScope, attributes));
173
166
  }
174
167
  function isKeyedElement(node, initialScope) {
175
- return node.type === types.AST_NODE_TYPES.JSXElement && hasProp(node.openingElement.attributes, "key", initialScope);
168
+ return node.type === types.AST_NODE_TYPES.JSXElement && hasProp("key", initialScope, node.openingElement.attributes);
176
169
  }
177
170
  function isBuiltInElement(node) {
178
171
  return node.type === types.AST_NODE_TYPES.JSXElement && node.openingElement.name.type === types.AST_NODE_TYPES.JSXIdentifier && node.openingElement.name.name.toLowerCase() === node.openingElement.name.name && /^[a-z]/u.test(node.openingElement.name.name);
@@ -275,29 +268,29 @@ function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
275
268
  if (name === "undefined") {
276
269
  return !(hint & JSXValueHint.SkipUndefined);
277
270
  }
278
- if (AST2__namespace.isJSXTagNameExpression(node)) {
271
+ if (AST3__namespace.isJSXTagNameExpression(node)) {
279
272
  return true;
280
273
  }
281
- return eff.F.pipe(
282
- VAR__namespace.findVariable(name, jsxCtx.getScope(node)),
283
- eff.O.flatMap(VAR__namespace.getVariableNode(0)),
284
- eff.O.exists((n) => isJSXValue(n, jsxCtx, hint))
285
- );
274
+ const variable = VAR__namespace.findVariable(name, jsxCtx.getScope(node));
275
+ const variableNode = variable && VAR__namespace.getVariableNode(variable, 0);
276
+ return !!variableNode && isJSXValue(variableNode, jsxCtx, hint);
286
277
  }
287
278
  }
288
279
  return false;
289
280
  }
290
- var isLiteral = AST2__namespace.isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText]);
281
+ var isLiteral = AST3__namespace.isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText]);
291
282
  function isWhiteSpace(node) {
292
- return eff.isString(node.value) && node.value.trim() === "";
283
+ return typeof node.value === "string" && node.value.trim() === "";
293
284
  }
294
285
  function isLineBreak(node) {
295
- return isLiteral(node) && isWhiteSpace(node) && AST2__namespace.isMultiLine(node);
286
+ return isLiteral(node) && isWhiteSpace(node) && AST3__namespace.isMultiLine(node);
296
287
  }
297
288
  function isPaddingSpaces(node) {
298
289
  return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
299
290
  }
300
- var xhtmlEntities = types$1.birecord({
291
+
292
+ // src/xhtml-entities.ts
293
+ var xhtmlEntities = {
301
294
  Aacute: "\xC1",
302
295
  aacute: "\xE1",
303
296
  Acirc: "\xC2",
@@ -551,7 +544,7 @@ var xhtmlEntities = types$1.birecord({
551
544
  zeta: "\u03B6",
552
545
  zwj: "\u200D",
553
546
  zwnj: "\u200C"
554
- });
547
+ };
555
548
 
556
549
  // src/unescape-string-literal-text.ts
557
550
  function unescapeStringLiteralText(text) {
@@ -561,7 +554,7 @@ function unescapeStringLiteralText(text) {
561
554
  const codePoint = item[1] === "x" ? parseInt(item.slice(2), 16) : parseInt(item.slice(1), 10);
562
555
  return codePoint > 1114111 ? entity : String.fromCodePoint(codePoint);
563
556
  }
564
- return xhtmlEntities.has(item) ? xhtmlEntities.get(item) : entity;
557
+ return xhtmlEntities[item] ?? entity;
565
558
  });
566
559
  }
567
560
 
package/dist/index.mjs CHANGED
@@ -1,15 +1,14 @@
1
- import * as AST2 from '@eslint-react/ast';
2
- import { F, O, isString } from '@eslint-react/eff';
1
+ import * as AST3 from '@eslint-react/ast';
2
+ import { returnTrue, _ } from '@eslint-react/eff';
3
3
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
4
4
  import * as VAR from '@eslint-react/var';
5
- import { birecord } from '@eslint-react/types';
6
5
 
7
6
  // src/find-parent-prop.ts
8
- function findParentProp(node, predicate = F.constTrue) {
7
+ function findParentProp(node, test = returnTrue) {
9
8
  const guard = (node2) => {
10
- return node2.type === AST_NODE_TYPES.JSXAttribute && predicate(node2);
9
+ return node2.type === AST_NODE_TYPES.JSXAttribute && test(node2);
11
10
  };
12
- return AST2.findParentNodeGuard(node, guard);
11
+ return AST3.findParentNodeGuard(node, guard);
13
12
  }
14
13
  function resolveJSXMemberExpressions(object, property) {
15
14
  if (object.type === AST_NODE_TYPES.JSXMemberExpression) {
@@ -42,114 +41,108 @@ function getPropName(node) {
42
41
  return `${node.name.namespace.name}:${node.name.name.name}`;
43
42
  }
44
43
  }
45
- function getProp(props, propName, initialScope) {
46
- return findPropInAttributes(props, initialScope)(propName);
44
+ function getProp(name, initialScope, props) {
45
+ return findPropInAttributes(name, initialScope, props);
47
46
  }
48
47
  function getPropValue(attribute, initialScope) {
49
- if (attribute.type === AST_NODE_TYPES.JSXAttribute && "value" in attribute) {
50
- const { value } = attribute;
51
- if (value == null) {
52
- return O.none();
53
- }
54
- if (value.type === AST_NODE_TYPES.Literal) {
55
- return VAR.getStaticValue(value, initialScope);
56
- }
57
- if (value.type === AST_NODE_TYPES.JSXExpressionContainer) {
58
- return VAR.getStaticValue(value.expression, initialScope);
59
- }
60
- return O.none();
48
+ switch (attribute.type) {
49
+ case AST_NODE_TYPES.JSXAttribute:
50
+ if (attribute.value?.type === AST_NODE_TYPES.Literal) {
51
+ return {
52
+ kind: "some",
53
+ node: attribute.value,
54
+ initialScope,
55
+ value: attribute.value.value
56
+ };
57
+ }
58
+ if (attribute.value?.type === AST_NODE_TYPES.JSXExpressionContainer) {
59
+ return {
60
+ kind: "lazy",
61
+ node: attribute.value.expression,
62
+ initialScope
63
+ };
64
+ }
65
+ return { kind: "none", node: attribute, initialScope };
66
+ case AST_NODE_TYPES.JSXSpreadAttribute:
67
+ return {
68
+ kind: "lazy",
69
+ node: attribute.argument,
70
+ initialScope
71
+ };
72
+ default:
73
+ return { kind: "none", node: attribute, initialScope };
61
74
  }
62
- const { argument } = attribute;
63
- return VAR.getStaticValue(argument, initialScope);
64
75
  }
65
- function findPropInProperties(properties, initialScope, seenProps = []) {
66
- return (propName) => {
67
- return O.fromNullable(
68
- properties.findLast((prop) => {
69
- switch (true) {
70
- case (prop.type === AST_NODE_TYPES.Property && "name" in prop.key && prop.key.name === propName):
71
- return true;
72
- case prop.type === AST_NODE_TYPES.SpreadElement:
73
- switch (true) {
74
- case prop.argument.type === AST_NODE_TYPES.Identifier: {
75
- const { name } = prop.argument;
76
- if (seenProps.includes(name)) {
77
- return false;
78
- }
79
- return F.pipe(
80
- VAR.findVariable(name, initialScope),
81
- O.flatMap(VAR.getVariableNode(0)),
82
- O.filter(AST2.is(AST_NODE_TYPES.ObjectExpression)),
83
- O.flatMap(
84
- (init) => findPropInProperties(init.properties, initialScope, [...seenProps, name])(propName)
85
- ),
86
- O.isSome
87
- );
88
- }
89
- case prop.argument.type === AST_NODE_TYPES.ObjectExpression: {
90
- return O.isSome(
91
- findPropInProperties(prop.argument.properties, initialScope, seenProps)(propName)
92
- );
93
- }
94
- default: {
95
- return false;
96
- }
97
- }
98
- case prop.type === AST_NODE_TYPES.RestElement:
99
- return false;
100
- default:
76
+ function findPropInProperties(name, properties, initialScope, seenProps = []) {
77
+ return properties.findLast((prop) => {
78
+ if (prop.type === AST_NODE_TYPES.Property) {
79
+ return "name" in prop.key && prop.key.name === name;
80
+ }
81
+ if (prop.type === AST_NODE_TYPES.SpreadElement) {
82
+ switch (prop.argument.type) {
83
+ case AST_NODE_TYPES.Identifier: {
84
+ if (seenProps.includes(prop.argument.name)) {
101
85
  return false;
86
+ }
87
+ const variable = VAR.findVariable(prop.argument.name, initialScope);
88
+ const variableNode = VAR.getVariableNode(variable, 0);
89
+ if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
90
+ return findPropInProperties(
91
+ name,
92
+ variableNode.properties,
93
+ initialScope,
94
+ [...seenProps, prop.argument.name]
95
+ ) !== _;
96
+ }
97
+ return false;
102
98
  }
103
- })
104
- );
105
- };
99
+ case AST_NODE_TYPES.ObjectExpression: {
100
+ return findPropInProperties(
101
+ name,
102
+ prop.argument.properties,
103
+ initialScope,
104
+ seenProps
105
+ ) !== _;
106
+ }
107
+ }
108
+ return false;
109
+ }
110
+ return false;
111
+ });
106
112
  }
107
- function findPropInAttributes(attributes, initialScope) {
108
- return (propName) => {
109
- return O.fromNullable(
110
- attributes.findLast((attr) => {
111
- switch (attr.type) {
112
- case AST_NODE_TYPES.JSXAttribute:
113
- return getPropName(attr) === propName;
114
- case AST_NODE_TYPES.JSXSpreadAttribute:
115
- switch (attr.argument.type) {
116
- case AST_NODE_TYPES.CallExpression:
117
- return false;
118
- case AST_NODE_TYPES.Identifier: {
119
- const { name } = attr.argument;
120
- return F.pipe(
121
- VAR.findVariable(name, initialScope),
122
- O.flatMap(VAR.getVariableNode(0)),
123
- O.filter(AST2.is(AST_NODE_TYPES.ObjectExpression)),
124
- O.flatMap((init) => findPropInProperties(init.properties, initialScope)(propName)),
125
- O.isSome
126
- );
127
- }
128
- case AST_NODE_TYPES.MemberExpression:
129
- return false;
130
- case AST_NODE_TYPES.ObjectExpression:
131
- return O.isSome(findPropInProperties(attr.argument.properties, initialScope)(propName));
132
- default:
133
- return false;
134
- }
135
- default:
136
- return false;
113
+ function findPropInAttributes(name, initialScope, attributes) {
114
+ return attributes.findLast((attr) => {
115
+ if (attr.type === AST_NODE_TYPES.JSXAttribute) {
116
+ return getPropName(attr) === name;
117
+ }
118
+ switch (attr.argument.type) {
119
+ case AST_NODE_TYPES.Identifier: {
120
+ const variable = VAR.findVariable(attr.argument.name, initialScope);
121
+ const variableNode = VAR.getVariableNode(variable, 0);
122
+ if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
123
+ return findPropInProperties(name, variableNode.properties, initialScope) !== _;
137
124
  }
138
- })
139
- );
140
- };
125
+ return false;
126
+ }
127
+ case AST_NODE_TYPES.ObjectExpression:
128
+ return findPropInProperties(name, attr.argument.properties, initialScope) !== _;
129
+ }
130
+ return false;
131
+ });
141
132
  }
142
- function hasProp(attributes, propName, initialScope) {
143
- return O.isSome(findPropInAttributes(attributes, initialScope)(propName));
133
+
134
+ // src/has-prop.ts
135
+ function hasProp(propName, initialScope, attributes) {
136
+ return !!findPropInAttributes(propName, initialScope, attributes);
144
137
  }
145
138
  function hasAnyProp(attributes, propNames, initialScope) {
146
- return propNames.some((propName) => hasProp(attributes, propName, initialScope));
139
+ return propNames.some((propName) => hasProp(propName, initialScope, attributes));
147
140
  }
148
141
  function hasEveryProp(attributes, propNames, initialScope) {
149
- return propNames.every((propName) => hasProp(attributes, propName, initialScope));
142
+ return propNames.every((propName) => hasProp(propName, initialScope, attributes));
150
143
  }
151
144
  function isKeyedElement(node, initialScope) {
152
- return node.type === AST_NODE_TYPES.JSXElement && hasProp(node.openingElement.attributes, "key", initialScope);
145
+ return node.type === AST_NODE_TYPES.JSXElement && hasProp("key", initialScope, node.openingElement.attributes);
153
146
  }
154
147
  function isBuiltInElement(node) {
155
148
  return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && node.openingElement.name.name.toLowerCase() === node.openingElement.name.name && /^[a-z]/u.test(node.openingElement.name.name);
@@ -252,29 +245,29 @@ function isJSXValue(node, jsxCtx, hint = DEFAULT_JSX_VALUE_HINT) {
252
245
  if (name === "undefined") {
253
246
  return !(hint & JSXValueHint.SkipUndefined);
254
247
  }
255
- if (AST2.isJSXTagNameExpression(node)) {
248
+ if (AST3.isJSXTagNameExpression(node)) {
256
249
  return true;
257
250
  }
258
- return F.pipe(
259
- VAR.findVariable(name, jsxCtx.getScope(node)),
260
- O.flatMap(VAR.getVariableNode(0)),
261
- O.exists((n) => isJSXValue(n, jsxCtx, hint))
262
- );
251
+ const variable = VAR.findVariable(name, jsxCtx.getScope(node));
252
+ const variableNode = variable && VAR.getVariableNode(variable, 0);
253
+ return !!variableNode && isJSXValue(variableNode, jsxCtx, hint);
263
254
  }
264
255
  }
265
256
  return false;
266
257
  }
267
- var isLiteral = AST2.isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText]);
258
+ var isLiteral = AST3.isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText]);
268
259
  function isWhiteSpace(node) {
269
- return isString(node.value) && node.value.trim() === "";
260
+ return typeof node.value === "string" && node.value.trim() === "";
270
261
  }
271
262
  function isLineBreak(node) {
272
- return isLiteral(node) && isWhiteSpace(node) && AST2.isMultiLine(node);
263
+ return isLiteral(node) && isWhiteSpace(node) && AST3.isMultiLine(node);
273
264
  }
274
265
  function isPaddingSpaces(node) {
275
266
  return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
276
267
  }
277
- var xhtmlEntities = birecord({
268
+
269
+ // src/xhtml-entities.ts
270
+ var xhtmlEntities = {
278
271
  Aacute: "\xC1",
279
272
  aacute: "\xE1",
280
273
  Acirc: "\xC2",
@@ -528,7 +521,7 @@ var xhtmlEntities = birecord({
528
521
  zeta: "\u03B6",
529
522
  zwj: "\u200D",
530
523
  zwnj: "\u200C"
531
- });
524
+ };
532
525
 
533
526
  // src/unescape-string-literal-text.ts
534
527
  function unescapeStringLiteralText(text) {
@@ -538,7 +531,7 @@ function unescapeStringLiteralText(text) {
538
531
  const codePoint = item[1] === "x" ? parseInt(item.slice(2), 16) : parseInt(item.slice(1), 10);
539
532
  return codePoint > 1114111 ? entity : String.fromCodePoint(codePoint);
540
533
  }
541
- return xhtmlEntities.has(item) ? xhtmlEntities.get(item) : entity;
534
+ return xhtmlEntities[item] ?? entity;
542
535
  });
543
536
  }
544
537
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@eslint-react/jsx",
3
- "version": "1.23.3-next.8",
3
+ "version": "1.24.0-next.0",
4
4
  "description": "ESLint React's TSESTree AST utility module for static analysis of JSX.",
5
- "homepage": "https://github.com/rEl1cx/eslint-react",
5
+ "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
7
- "url": "https://github.com/rEl1cx/eslint-react/issues"
7
+ "url": "https://github.com/Rel1cx/eslint-react/issues"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/rEl1cx/eslint-react.git",
11
+ "url": "git+https://github.com/Rel1cx/eslint-react.git",
12
12
  "directory": "packages/utilities/jsx"
13
13
  },
14
14
  "license": "MIT",
@@ -37,10 +37,10 @@
37
37
  "@typescript-eslint/types": "^8.19.1",
38
38
  "@typescript-eslint/utils": "^8.19.1",
39
39
  "ts-pattern": "^5.6.0",
40
- "@eslint-react/ast": "1.23.3-next.8",
41
- "@eslint-react/eff": "1.23.3-next.8",
42
- "@eslint-react/types": "1.23.3-next.8",
43
- "@eslint-react/var": "1.23.3-next.8"
40
+ "@eslint-react/ast": "1.24.0-next.0",
41
+ "@eslint-react/eff": "1.24.0-next.0",
42
+ "@eslint-react/types": "1.24.0-next.0",
43
+ "@eslint-react/var": "1.24.0-next.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.3.5",