@eslint-react/core 3.0.0-next.60 → 3.0.0-next.62

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -3
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as ast from "@eslint-react/ast";
2
2
  import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
3
- import { findVariable, getVariableInitializer } from "@eslint-react/var";
3
+ import { findVariable } from "@eslint-react/var";
4
4
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
5
5
  import { P, match } from "ts-pattern";
6
6
  import { IdGenerator, RE_ANNOTATION_JSX, RE_ANNOTATION_JSX_FRAG, RE_ANNOTATION_JSX_IMPORT_SOURCE, RE_ANNOTATION_JSX_RUNTIME, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE } from "@eslint-react/shared";
@@ -412,7 +412,15 @@ function getJsxAttribute(context, node, initialScope) {
412
412
  if (attr.type === AST_NODE_TYPES.JSXAttribute) return getJsxAttributeName(context, attr) === name;
413
413
  switch (attr.argument.type) {
414
414
  case AST_NODE_TYPES.Identifier: {
415
- const initNode = getVariableInitializer(findVariable(attr.argument.name, scope), 0);
415
+ const variable = findVariable(attr.argument.name, scope);
416
+ function resolve(v) {
417
+ if (v == null) return unit;
418
+ const def = v.defs.at(0);
419
+ if (def == null) return unit;
420
+ if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
421
+ return unit;
422
+ }
423
+ const initNode = resolve(variable);
416
424
  if (initNode?.type === AST_NODE_TYPES.ObjectExpression) return ast.findProperty(initNode.properties, name) != null;
417
425
  return false;
418
426
  }
@@ -640,7 +648,14 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
640
648
  const { name } = node;
641
649
  if (name === "undefined") return !(hint & JsxDetectionHint.DoNotIncludeJsxWithUndefinedValue);
642
650
  if (ast.isJSXTagNameExpression(node)) return true;
643
- return isJsxLike(code, getVariableInitializer(findVariable(name, code.getScope(node)), 0), hint);
651
+ function resolve(v) {
652
+ if (v == null) return unit;
653
+ const def = v.defs.at(0);
654
+ if (def == null) return unit;
655
+ if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
656
+ return unit;
657
+ }
658
+ return isJsxLike(code, resolve(findVariable(name, code.getScope(node))), hint);
644
659
  }
645
660
  }
646
661
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "3.0.0-next.60",
3
+ "version": "3.0.0-next.62",
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.60",
38
- "@eslint-react/eff": "3.0.0-next.60",
39
- "@eslint-react/shared": "3.0.0-next.60",
40
- "@eslint-react/var": "3.0.0-next.60"
37
+ "@eslint-react/ast": "3.0.0-next.62",
38
+ "@eslint-react/var": "3.0.0-next.62",
39
+ "@eslint-react/eff": "3.0.0-next.62",
40
+ "@eslint-react/shared": "3.0.0-next.62"
41
41
  },
42
42
  "devDependencies": {
43
43
  "tsdown": "^0.21.0-beta.2",