@eslint-react/core 3.0.0-next.66 → 3.0.0-next.67

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
@@ -644,6 +644,10 @@ declare function getJsxAttributeName(context: RuleContext, node: TSESTree$1.JSXA
644
644
  * Represents possible JSX attribute value types that can be resolved
645
645
  */
646
646
  type JsxAttributeValue = {
647
+ kind: "missing";
648
+ node: TSESTree.JSXEmptyExpression;
649
+ toStatic(): "{}";
650
+ } | {
647
651
  kind: "boolean";
648
652
  toStatic(): true;
649
653
  } | {
@@ -661,11 +665,13 @@ type JsxAttributeValue = {
661
665
  } | {
662
666
  kind: "spreadProps";
663
667
  node: TSESTree.JSXSpreadAttribute["argument"];
664
- toStatic(name?: string): unknown;
668
+ toStatic(): unknown;
669
+ getProperty(name: string): unknown;
665
670
  } | {
666
671
  kind: "spreadChild";
667
672
  node: TSESTree.JSXSpreadChild["expression"];
668
673
  toStatic(): unknown;
674
+ getChildren(at: number): unknown;
669
675
  };
670
676
  /**
671
677
  * Resolve the static value of a JSX attribute or spread attribute
@@ -678,26 +684,37 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: ast.T
678
684
  readonly kind: "boolean";
679
685
  readonly toStatic: () => true;
680
686
  readonly node?: never;
687
+ readonly getChildren?: never;
681
688
  } | {
682
689
  readonly kind: "literal";
683
690
  readonly node: TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral;
684
691
  readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
692
+ readonly getChildren?: never;
693
+ } | {
694
+ readonly kind: "missing";
695
+ readonly node: TSESTree.JSXEmptyExpression;
696
+ readonly toStatic: () => "{}";
697
+ readonly getChildren?: never;
685
698
  } | {
686
699
  readonly kind: "expression";
687
- readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
700
+ readonly node: TSESTree.Expression;
688
701
  readonly toStatic: () => unknown;
702
+ readonly getChildren?: never;
689
703
  } | {
690
704
  readonly kind: "element";
691
705
  readonly node: TSESTree.JSXElement;
692
706
  readonly toStatic: () => null;
707
+ readonly getChildren?: never;
693
708
  } | {
694
709
  readonly kind: "spreadChild";
695
710
  readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
696
- readonly toStatic: () => null;
711
+ readonly toStatic: () => unknown;
712
+ readonly getChildren: (at: number) => null;
697
713
  } | {
698
714
  readonly kind: "spreadProps";
699
715
  readonly node: TSESTree.Expression;
700
- readonly toStatic: (name?: string) => unknown;
716
+ readonly toStatic: () => unknown;
717
+ readonly getProperty: (name: string) => unknown;
701
718
  };
702
719
  //#endregion
703
720
  //#region src/jsx/jsx-config.d.ts
package/dist/index.js CHANGED
@@ -458,6 +458,13 @@ function resolveJsxAttributeValue(context, attribute) {
458
458
  }
459
459
  case AST_NODE_TYPES.JSXExpressionContainer: {
460
460
  const expr = node.value.expression;
461
+ if (expr.type === AST_NODE_TYPES.JSXEmptyExpression) return {
462
+ kind: "missing",
463
+ node: expr,
464
+ toStatic() {
465
+ return "{}";
466
+ }
467
+ };
461
468
  return {
462
469
  kind: "expression",
463
470
  node: expr,
@@ -473,13 +480,19 @@ function resolveJsxAttributeValue(context, attribute) {
473
480
  return null;
474
481
  }
475
482
  };
476
- case AST_NODE_TYPES.JSXSpreadChild: return {
477
- kind: "spreadChild",
478
- node: node.value.expression,
479
- toStatic() {
480
- return null;
481
- }
482
- };
483
+ case AST_NODE_TYPES.JSXSpreadChild: {
484
+ const expr = node.value.expression;
485
+ return {
486
+ kind: "spreadChild",
487
+ node: node.value.expression,
488
+ toStatic() {
489
+ return getStaticValue(expr, initialScope)?.value;
490
+ },
491
+ getChildren(at) {
492
+ return null;
493
+ }
494
+ };
495
+ }
483
496
  }
484
497
  }
485
498
  /**
@@ -490,8 +503,10 @@ function resolveJsxAttributeValue(context, attribute) {
490
503
  return {
491
504
  kind: "spreadProps",
492
505
  node: node.argument,
493
- toStatic(name) {
494
- if (name == null) return null;
506
+ toStatic() {
507
+ return getStaticValue(node.argument, initialScope)?.value;
508
+ },
509
+ getProperty(name) {
495
510
  return match(getStaticValue(node.argument, initialScope)?.value).with({ [name]: P.select(P.any) }, identity).otherwise(() => null);
496
511
  }
497
512
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "3.0.0-next.66",
3
+ "version": "3.0.0-next.67",
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": {
@@ -34,10 +34,10 @@
34
34
  "@typescript-eslint/types": "canary",
35
35
  "@typescript-eslint/utils": "canary",
36
36
  "ts-pattern": "^5.9.0",
37
- "@eslint-react/ast": "3.0.0-next.66",
38
- "@eslint-react/eff": "3.0.0-next.66",
39
- "@eslint-react/shared": "3.0.0-next.66",
40
- "@eslint-react/var": "3.0.0-next.66"
37
+ "@eslint-react/ast": "3.0.0-next.67",
38
+ "@eslint-react/shared": "3.0.0-next.67",
39
+ "@eslint-react/var": "3.0.0-next.67",
40
+ "@eslint-react/eff": "3.0.0-next.67"
41
41
  },
42
42
  "devDependencies": {
43
43
  "tsdown": "^0.21.0-beta.2",