@eslint-react/core 2.3.13-next.3 → 2.3.13-next.4

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
@@ -515,11 +515,11 @@ declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | unit): boole
515
515
  //#endregion
516
516
  //#region src/jsx/jsx-attribute.d.ts
517
517
  /**
518
- * Get a function to find JSX attributes by name, considering direct attributes and spread attributes.
518
+ * Creates a helper function to find a specific JSX attribute by name
519
+ * Handles direct attributes and spread attributes (variables or object literals)
519
520
  * @param context The ESLint rule context
520
521
  * @param node The JSX element node
521
- * @param initialScope Optional initial scope for variable resolution
522
- * @returns A function that takes an attribute name and returns the corresponding JSX attribute node or undefined
522
+ * @param initialScope (Optional) The initial scope to use for variable resolution
523
523
  */
524
524
  declare function getJsxAttribute(context: RuleContext, node: TSESTree.JSXElement, initialScope?: Scope): (name: string) => TSESTree.JSXAttribute | TSESTree.JSXSpreadAttribute | undefined;
525
525
  //#endregion
@@ -560,6 +560,13 @@ type JsxAttributeValue = {
560
560
  node: TSESTree.JSXSpreadChild["expression"];
561
561
  toStatic(): unknown;
562
562
  };
563
+ /**
564
+ * Resolves the static value of a JSX attribute or spread attribute
565
+ *
566
+ * @param context - The ESLint rule context
567
+ * @param attribute - The JSX attribute node to resolve
568
+ * @returns An object containing the value kind, the node (if applicable), and a `toStatic` helper
569
+ */
563
570
  declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.TSESTreeJSXAttributeLike): {
564
571
  readonly kind: "boolean";
565
572
  readonly toStatic: () => true;
@@ -602,9 +609,9 @@ interface JsxConfig {
602
609
  jsxImportSource?: string;
603
610
  }
604
611
  /**
605
- * Get JsxConfig from the rule context by reading compiler options.
606
- * @param context The RuleContext.
607
- * @returns JsxConfig derived from compiler options.
612
+ * Get JsxConfig from the rule context by reading compiler options
613
+ * @param context The RuleContext
614
+ * @returns JsxConfig derived from compiler options
608
615
  */
609
616
  declare function getJsxConfigFromContext(context: RuleContext): {
610
617
  jsx: 4 | typescript0.JsxEmit;
@@ -613,9 +620,9 @@ declare function getJsxConfigFromContext(context: RuleContext): {
613
620
  jsxImportSource: string;
614
621
  };
615
622
  /**
616
- * Get JsxConfig from pragma comments (annotations) in the source code.
617
- * @param context The RuleContext.
618
- * @returns JsxConfig derived from pragma comments.
623
+ * Get JsxConfig from pragma comments (annotations) in the source code
624
+ * @param context The RuleContext
625
+ * @returns JsxConfig derived from pragma comments
619
626
  */
620
627
  declare function getJsxConfigFromAnnotation(context: RuleContext): JsxConfig;
621
628
  //#endregion
package/dist/index.js CHANGED
@@ -253,19 +253,18 @@ function getJsxAttributeName(context, node) {
253
253
  //#endregion
254
254
  //#region src/jsx/jsx-attribute.ts
255
255
  /**
256
- * Get a function to find JSX attributes by name, considering direct attributes and spread attributes.
256
+ * Creates a helper function to find a specific JSX attribute by name
257
+ * Handles direct attributes and spread attributes (variables or object literals)
257
258
  * @param context The ESLint rule context
258
259
  * @param node The JSX element node
259
- * @param initialScope Optional initial scope for variable resolution
260
- * @returns A function that takes an attribute name and returns the corresponding JSX attribute node or undefined
260
+ * @param initialScope (Optional) The initial scope to use for variable resolution
261
261
  */
262
262
  function getJsxAttribute(context, node, initialScope) {
263
263
  const scope = initialScope ?? context.sourceCode.getScope(node);
264
264
  const attributes = node.openingElement.attributes;
265
265
  /**
266
- * Find a JSX attribute by name, considering both direct attributes and spread attributes.
267
- * @param name The name of the attribute to find
268
- * @returns The JSX attribute node if found, otherwise undefined
266
+ * Finds the last occurrence of a specific attribute
267
+ * @param name The attribute name to search for
269
268
  */
270
269
  return (name) => {
271
270
  return attributes.findLast((attr) => {
@@ -285,8 +284,19 @@ function getJsxAttribute(context, node, initialScope) {
285
284
 
286
285
  //#endregion
287
286
  //#region src/jsx/jsx-attribute-value.ts
287
+ /**
288
+ * Resolves the static value of a JSX attribute or spread attribute
289
+ *
290
+ * @param context - The ESLint rule context
291
+ * @param attribute - The JSX attribute node to resolve
292
+ * @returns An object containing the value kind, the node (if applicable), and a `toStatic` helper
293
+ */
288
294
  function resolveJsxAttributeValue(context, attribute) {
289
295
  const initialScope = context.sourceCode.getScope(attribute);
296
+ /**
297
+ * Handles standard JSX attributes (e.g., prop="value", prop={value}, prop)
298
+ * @param node The JSX attribute node
299
+ */
290
300
  function handleJsxAttribute(node) {
291
301
  if (node.value == null) return {
292
302
  kind: "boolean",
@@ -331,6 +341,10 @@ function resolveJsxAttributeValue(context, attribute) {
331
341
  };
332
342
  }
333
343
  }
344
+ /**
345
+ * Handles JSX spread attributes (e.g., {...props})
346
+ * @param node The JSX spread attribute node
347
+ */
334
348
  function handleJsxSpreadAttribute(node) {
335
349
  return {
336
350
  kind: "spreadProps",
@@ -358,9 +372,9 @@ const JsxEmit = {
358
372
  ReactJSXDev: 5
359
373
  };
360
374
  /**
361
- * Get JsxConfig from the rule context by reading compiler options.
362
- * @param context The RuleContext.
363
- * @returns JsxConfig derived from compiler options.
375
+ * Get JsxConfig from the rule context by reading compiler options
376
+ * @param context The RuleContext
377
+ * @returns JsxConfig derived from compiler options
364
378
  */
365
379
  function getJsxConfigFromContext(context) {
366
380
  const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
@@ -373,9 +387,9 @@ function getJsxConfigFromContext(context) {
373
387
  }
374
388
  const cache = /* @__PURE__ */ new WeakMap();
375
389
  /**
376
- * Get JsxConfig from pragma comments (annotations) in the source code.
377
- * @param context The RuleContext.
378
- * @returns JsxConfig derived from pragma comments.
390
+ * Get JsxConfig from pragma comments (annotations) in the source code
391
+ * @param context The RuleContext
392
+ * @returns JsxConfig derived from pragma comments
379
393
  */
380
394
  function getJsxConfigFromAnnotation(context) {
381
395
  return getOrElseUpdate(cache, context.sourceCode, () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.3.13-next.3",
3
+ "version": "2.3.13-next.4",
4
4
  "description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -35,10 +35,10 @@
35
35
  "@typescript-eslint/utils": "^8.48.1",
36
36
  "birecord": "^0.1.1",
37
37
  "ts-pattern": "^5.9.0",
38
- "@eslint-react/ast": "2.3.13-next.3",
39
- "@eslint-react/eff": "2.3.13-next.3",
40
- "@eslint-react/shared": "2.3.13-next.3",
41
- "@eslint-react/var": "2.3.13-next.3"
38
+ "@eslint-react/ast": "2.3.13-next.4",
39
+ "@eslint-react/shared": "2.3.13-next.4",
40
+ "@eslint-react/eff": "2.3.13-next.4",
41
+ "@eslint-react/var": "2.3.13-next.4"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "eslint": "^8.57.0 || ^9.0.0",