@eslint-react/core 5.28.7 → 5.28.8

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
@@ -1,8 +1,8 @@
1
1
  import { TSESTreeClass, TSESTreeDirective, TSESTreeFunction, TSESTreeMethodOrPropertyDefinition } from "@eslint-react/ast";
2
+ import { RuleContext } from "@eslint-react/eslint";
2
3
  import { TSESTree } from "@typescript-eslint/types";
3
4
  import { RegExpLike } from "@eslint-react/shared";
4
5
  import ts from "typescript";
5
- import { RuleContext } from "@eslint-react/eslint";
6
6
  import { ESLintUtils } from "@typescript-eslint/utils";
7
7
  //#region src/api.d.ts
8
8
  export declare namespace isAPI {
@@ -443,7 +443,7 @@ export type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSe
443
443
  * @param node The function node to analyze.
444
444
  * @returns The identifier node if found, `null` otherwise.
445
445
  */
446
- export declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | 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.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | TSESTree.PrivateIdentifier | null;
446
+ export declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | 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.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | null;
447
447
  /**
448
448
  * Get the initialization path of a function node in the AST.
449
449
  *
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Check, Extract, Traverse } from "@eslint-react/ast";
2
+ import { getText } from "@eslint-react/eslint";
2
3
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
3
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/shared";
4
5
  import { resolve } from "@eslint-react/var";
@@ -7,26 +8,25 @@ import { P, isMatching, match } from "ts-pattern";
7
8
  import ts from "typescript";
8
9
  //#region src/api.ts
9
10
  function isAPI(api) {
10
- const func = (context, node) => {
11
+ function impl(context, node) {
11
12
  if (node == null) return false;
12
13
  const expr = Extract.unwrap(node);
13
- const getText = (n) => context.sourceCode.getText(n);
14
- const name = Extract.getFullyQualifiedName(expr, getText);
14
+ const name = Extract.getFullyQualifiedName(expr, getText(context));
15
15
  return name === api || name.endsWith(`.${api}`);
16
- };
16
+ }
17
17
  function dual(context, ...rest) {
18
- return rest.length === 1 ? func(context, rest[0]) : (node) => func(context, node);
18
+ return rest.length === 1 ? impl(context, rest[0]) : (node) => impl(context, node);
19
19
  }
20
20
  return dual;
21
21
  }
22
22
  function isAPICall(api) {
23
- const func = (context, node) => {
23
+ function impl(context, node) {
24
24
  if (node == null) return false;
25
25
  if (node.type !== AST_NODE_TYPES.CallExpression) return false;
26
26
  return isAPI(api)(context, Extract.unwrap(node.callee));
27
- };
27
+ }
28
28
  function dual(context, ...rest) {
29
- return rest.length === 1 ? func(context, rest[0]) : (node) => func(context, node);
29
+ return rest.length === 1 ? impl(context, rest[0]) : (node) => impl(context, node);
30
30
  }
31
31
  return dual;
32
32
  }
@@ -273,12 +273,11 @@ function isThisSetStateCall(node) {
273
273
  //#region src/class-component-collector.ts
274
274
  function getClassComponentCollector(context) {
275
275
  const components = /* @__PURE__ */ new Map();
276
- const getText = (n) => context.sourceCode.getText(n);
277
276
  const collect = (node) => {
278
277
  if (!isClassComponent(node)) return;
279
278
  const id = getClassId(node);
280
279
  const key = node.range[0];
281
- const name = id == null ? null : Extract.getFullyQualifiedName(id, getText);
280
+ const name = id == null ? null : Extract.getFullyQualifiedName(id, getText(context));
282
281
  components.set(key, {
283
282
  id,
284
283
  key,
@@ -680,7 +679,6 @@ function getFunctionComponentCollector(context, options = {}) {
680
679
  const { collectDisplayName = false, hint = DEFAULT_COMPONENT_DETECTION_HINT } = options;
681
680
  const functionEntries = [];
682
681
  const components = /* @__PURE__ */ new Map();
683
- const getText = (n) => context.sourceCode.getText(n);
684
682
  const getCurrentEntry = () => functionEntries.at(-1) ?? null;
685
683
  const onFunctionEnter = (node) => {
686
684
  const key = node.range[0];
@@ -688,7 +686,7 @@ function getFunctionComponentCollector(context, options = {}) {
688
686
  const isExportDefault = exp != null;
689
687
  const isExportDefaultDeclaration = exp != null && Extract.unwrap(exp.declaration) === node;
690
688
  const id = getFunctionComponentId(context, node);
691
- const name = id == null ? null : Extract.getFullyQualifiedName(id, getText);
689
+ const name = id == null ? null : Extract.getFullyQualifiedName(id, getText(context));
692
690
  const initPath = getFunctionInitPath(node);
693
691
  const directives = getFunctionDirectives(node);
694
692
  const entry = {
@@ -772,7 +770,6 @@ function getFunctionComponentCollector(context, options = {}) {
772
770
  function getHookCollector(context) {
773
771
  const functionEntries = [];
774
772
  const hooks = /* @__PURE__ */ new Map();
775
- const getText = (n) => context.sourceCode.getText(n);
776
773
  const getCurrentEntry = () => functionEntries.at(-1) ?? null;
777
774
  const getCurrentHookEntry = () => functionEntries.findLast((entry) => entry.isHookDefinition) ?? null;
778
775
  const onFunctionEnter = (node) => {
@@ -781,7 +778,7 @@ function getHookCollector(context) {
781
778
  id,
782
779
  key: node.range[0],
783
780
  kind: "hook",
784
- name: id == null ? null : Extract.getFullyQualifiedName(id, getText),
781
+ name: id == null ? null : Extract.getFullyQualifiedName(id, getText(context)),
785
782
  directives: getFunctionDirectives(node),
786
783
  flag: 0n,
787
784
  hint: 0n,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "5.28.7",
3
+ "version": "5.28.8",
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": {
@@ -29,10 +29,10 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@eslint-react/ast": "5.28.7",
33
- "@eslint-react/eslint": "5.28.7",
34
- "@eslint-react/shared": "5.28.7",
35
- "@eslint-react/var": "5.28.7",
32
+ "@eslint-react/ast": "5.28.8",
33
+ "@eslint-react/eslint": "5.28.8",
34
+ "@eslint-react/shared": "5.28.8",
35
+ "@eslint-react/var": "5.28.8",
36
36
  "@typescript-eslint/types": "^8.72.0",
37
37
  "@typescript-eslint/utils": "^8.72.0",
38
38
  "ts-pattern": "^5.9.2"