@eslint-react/core 2.0.1-beta.1 → 2.0.1-beta.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
@@ -480,7 +480,7 @@ declare function resolveAttributeValue(context: RuleContext, attribute: AST.TSES
480
480
  readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
481
481
  } | {
482
482
  readonly kind: "expression";
483
- readonly node: TSESTree.Expression | TSESTree.JSXEmptyExpression;
483
+ readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
484
484
  readonly toStatic: () => unknown;
485
485
  } | {
486
486
  readonly kind: "element";
@@ -488,7 +488,7 @@ declare function resolveAttributeValue(context: RuleContext, attribute: AST.TSES
488
488
  readonly toStatic: () => undefined;
489
489
  } | {
490
490
  readonly kind: "spreadChild";
491
- readonly node: TSESTree.Expression | TSESTree.JSXEmptyExpression;
491
+ readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
492
492
  readonly toStatic: () => undefined;
493
493
  } | {
494
494
  readonly kind: "spreadProps";
@@ -671,7 +671,7 @@ declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXNam
671
671
  * @param prev The previous AST node in the traversal (used for context)
672
672
  * @internal
673
673
  */
674
- declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.BinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.TemplateLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpression | TSESTree.UpdateExpression | TSESTree.YieldExpression | TSESTree.PrivateIdentifier | undefined;
674
+ declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.BinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpression | TSESTree.UpdateExpression | TSESTree.YieldExpression | undefined;
675
675
  //#endregion
676
676
  //#region src/utils/is-from-react.d.ts
677
677
  /**
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import * as AST from "@eslint-react/ast";
3
3
  import { constFalse, constTrue, dual, flip, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
4
4
  import { 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/kit";
5
5
  import { getId } from "@eslint-react/shared";
6
- import * as VAR from "@eslint-react/var";
6
+ import { findProperty, findVariable, getVariableDefinitionNode, isNodeValueEqual } from "@eslint-react/var";
7
7
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
8
8
  import { P, isMatching, match } from "ts-pattern";
9
9
  import birecord from "birecord";
@@ -314,12 +314,12 @@ function getAttribute(context, attributes, initialScope) {
314
314
  if (initialScope == null) return false;
315
315
  switch (attr.argument.type) {
316
316
  case AST_NODE_TYPES.Identifier: {
317
- const variable = VAR.findVariable(attr.argument.name, initialScope);
318
- const variableNode = VAR.getVariableDefinitionNode(variable, 0);
319
- if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return VAR.findProperty(name, variableNode.properties, initialScope) != null;
317
+ const variable = findVariable(attr.argument.name, initialScope);
318
+ const variableNode = getVariableDefinitionNode(variable, 0);
319
+ if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) return findProperty(name, variableNode.properties, initialScope) != null;
320
320
  return false;
321
321
  }
322
- case AST_NODE_TYPES.ObjectExpression: return VAR.findProperty(name, attr.argument.properties, initialScope) != null;
322
+ case AST_NODE_TYPES.ObjectExpression: return findProperty(name, attr.argument.properties, initialScope) != null;
323
323
  }
324
324
  return false;
325
325
  });
@@ -536,8 +536,8 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
536
536
  const { name } = node;
537
537
  if (name === "undefined") return !(hint & JSXDetectionHint.SkipUndefined);
538
538
  if (AST.isJSXTagNameExpression(node)) return true;
539
- const variable = VAR.findVariable(name, code.getScope(node));
540
- const variableNode = variable && VAR.getVariableDefinitionNode(variable, 0);
539
+ const variable = findVariable(name, code.getScope(node));
540
+ const variableNode = variable && getVariableDefinitionNode(variable, 0);
541
541
  return !!variableNode && isJsxLike(code, variableNode, hint);
542
542
  }
543
543
  }
@@ -831,7 +831,7 @@ function getRequireExpressionArguments(node) {
831
831
  */
832
832
  function isInitializedFromReact(name, importSource, initialScope) {
833
833
  if (name.toLowerCase() === "react") return true;
834
- const latestDef = VAR.findVariable(name, initialScope)?.defs.at(-1);
834
+ const latestDef = findVariable(name, initialScope)?.defs.at(-1);
835
835
  if (latestDef == null) return false;
836
836
  const { node, parent } = latestDef;
837
837
  if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
@@ -849,7 +849,7 @@ function isInitializedFromReact(name, importSource, initialScope) {
849
849
  //#region src/utils/is-instance-id-equal.ts
850
850
  /** @internal */
851
851
  function isInstanceIdEqual(context, a, b) {
852
- return AST.isNodeEqual(a, b) || VAR.isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
852
+ return AST.isNodeEqual(a, b) || isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
853
853
  }
854
854
 
855
855
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "2.0.1-beta.1",
3
+ "version": "2.0.1-beta.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": {
@@ -34,11 +34,11 @@
34
34
  "birecord": "^0.1.1",
35
35
  "ts-api-utils": "^2.1.0",
36
36
  "ts-pattern": "^5.8.0",
37
- "@eslint-react/ast": "2.0.1-beta.1",
38
- "@eslint-react/kit": "2.0.1-beta.1",
39
- "@eslint-react/eff": "2.0.1-beta.1",
40
- "@eslint-react/shared": "2.0.1-beta.1",
41
- "@eslint-react/var": "2.0.1-beta.1"
37
+ "@eslint-react/ast": "2.0.1-beta.4",
38
+ "@eslint-react/kit": "2.0.1-beta.4",
39
+ "@eslint-react/shared": "2.0.1-beta.4",
40
+ "@eslint-react/var": "2.0.1-beta.4",
41
+ "@eslint-react/eff": "2.0.1-beta.4"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsdown": "^0.15.4",