@eslint-react/core 3.0.0-next.61 → 3.0.0-next.63

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 +5 -6
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,10 +1,9 @@
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 } from "@eslint-react/var";
4
3
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
4
+ import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
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";
7
- import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
8
7
  import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/utils";
9
8
 
10
9
  //#region src/api/find-import-source.ts
@@ -34,7 +33,7 @@ function getRequireExpressionArguments(node) {
34
33
  * @returns The import source or undefined if not found
35
34
  */
36
35
  function findImportSource(name, initialScope) {
37
- const latestDef = findVariable(name, initialScope)?.defs.at(-1);
36
+ const latestDef = findVariable(initialScope, name)?.defs.at(-1);
38
37
  if (latestDef == null) return unit;
39
38
  const { node, parent } = latestDef;
40
39
  if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
@@ -412,7 +411,7 @@ function getJsxAttribute(context, node, initialScope) {
412
411
  if (attr.type === AST_NODE_TYPES.JSXAttribute) return getJsxAttributeName(context, attr) === name;
413
412
  switch (attr.argument.type) {
414
413
  case AST_NODE_TYPES.Identifier: {
415
- const variable = findVariable(attr.argument.name, scope);
414
+ const variable = findVariable(scope, attr.argument.name);
416
415
  function resolve(v) {
417
416
  if (v == null) return unit;
418
417
  const def = v.defs.at(0);
@@ -655,7 +654,7 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
655
654
  if ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)) return def.node.init;
656
655
  return unit;
657
656
  }
658
- return isJsxLike(code, resolve(findVariable(name, code.getScope(node))), hint);
657
+ return isJsxLike(code, resolve(findVariable(code.getScope(node), name)), hint);
659
658
  }
660
659
  }
661
660
  return false;
@@ -1212,7 +1211,7 @@ function isInitializedFromRef(name, initialScope) {
1212
1211
  * @returns The init expression node if the variable is derived from a ref, or undefined otherwise
1213
1212
  */
1214
1213
  function getRefInit(name, initialScope) {
1215
- for (const { node } of findVariable(initialScope)(name)?.defs ?? []) {
1214
+ for (const { node } of findVariable(initialScope, name)?.defs ?? []) {
1216
1215
  if (node.type !== AST_NODE_TYPES$1.VariableDeclarator) continue;
1217
1216
  const init = node.init;
1218
1217
  if (init == null) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "3.0.0-next.61",
3
+ "version": "3.0.0-next.63",
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.61",
38
- "@eslint-react/eff": "3.0.0-next.61",
39
- "@eslint-react/shared": "3.0.0-next.61",
40
- "@eslint-react/var": "3.0.0-next.61"
37
+ "@eslint-react/shared": "3.0.0-next.63",
38
+ "@eslint-react/ast": "3.0.0-next.63",
39
+ "@eslint-react/var": "3.0.0-next.63",
40
+ "@eslint-react/eff": "3.0.0-next.63"
41
41
  },
42
42
  "devDependencies": {
43
43
  "tsdown": "^0.21.0-beta.2",