@eslint-react/core 4.2.4-beta.0 → 4.2.5-beta.0
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 +3 -3
- package/dist/index.js +23 -10
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as ast from "@eslint-react/ast";
|
|
2
2
|
import { TSESTree } from "@typescript-eslint/types";
|
|
3
3
|
import { RegExpLike, RuleContext } from "@eslint-react/shared";
|
|
4
|
-
import { Scope } from "@typescript-eslint/scope-manager";
|
|
5
4
|
import { ESLintUtils, TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
|
|
5
|
+
import { Scope } from "@typescript-eslint/scope-manager";
|
|
6
6
|
|
|
7
7
|
//#region src/api/find-import-source.d.ts
|
|
8
8
|
/**
|
|
@@ -520,10 +520,10 @@ interface HookSemanticNode extends SemanticNode {
|
|
|
520
520
|
id: ast.FunctionID;
|
|
521
521
|
/** The AST node of the hook */
|
|
522
522
|
node: ast.TSESTreeFunction;
|
|
523
|
-
/** The name of the hook */
|
|
524
|
-
name: string;
|
|
525
523
|
/** The kind of hook */
|
|
526
524
|
kind: "hook";
|
|
525
|
+
/** List of expressions returned by the hook */
|
|
526
|
+
rets: TSESTree.ReturnStatement["argument"][];
|
|
527
527
|
/** The other hooks called by the hook */
|
|
528
528
|
hookCalls: TSESTree.CallExpression[];
|
|
529
529
|
/** The directives used in the function (ex: "use strict", "use client", etc.) */
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { findVariable } from "@typescript-eslint/utils/ast-utils";
|
|
|
4
4
|
import { P, match } from "ts-pattern";
|
|
5
5
|
import { JsxDetectionHint, isJsxLike } from "@eslint-react/jsx";
|
|
6
6
|
import { IdGenerator, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE } from "@eslint-react/shared";
|
|
7
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/utils";
|
|
7
8
|
|
|
8
9
|
//#region ../../.pkgs/eff/dist/index.js
|
|
9
10
|
/**
|
|
@@ -473,22 +474,22 @@ function getHookCollector(context) {
|
|
|
473
474
|
const onFunctionEnter = (node) => {
|
|
474
475
|
const id = ast.getFunctionId(node);
|
|
475
476
|
const key = idGen$2.next();
|
|
476
|
-
|
|
477
|
-
key,
|
|
478
|
-
node
|
|
479
|
-
});
|
|
480
|
-
if (id == null || !isHookId(id)) return;
|
|
481
|
-
hooks.set(key, {
|
|
477
|
+
const entry = {
|
|
482
478
|
id,
|
|
483
479
|
key,
|
|
484
480
|
kind: "hook",
|
|
485
|
-
name: ast.getFullyQualifiedName(id, getText),
|
|
481
|
+
name: id == null ? null : ast.getFullyQualifiedName(id, getText),
|
|
486
482
|
directives: [],
|
|
487
483
|
flag: 0n,
|
|
488
484
|
hint: 0n,
|
|
489
485
|
hookCalls: [],
|
|
490
|
-
|
|
491
|
-
|
|
486
|
+
isHookDefinition: id != null && isHookId(id),
|
|
487
|
+
node,
|
|
488
|
+
rets: []
|
|
489
|
+
};
|
|
490
|
+
functionEntries.push(entry);
|
|
491
|
+
if (!entry.isHookDefinition) return;
|
|
492
|
+
hooks.set(key, entry);
|
|
492
493
|
};
|
|
493
494
|
const onFunctionExit = () => {
|
|
494
495
|
functionEntries.pop();
|
|
@@ -500,11 +501,23 @@ function getHookCollector(context) {
|
|
|
500
501
|
visitor: {
|
|
501
502
|
":function": onFunctionEnter,
|
|
502
503
|
":function:exit": onFunctionExit,
|
|
504
|
+
"ArrowFunctionExpression[body.type!='BlockStatement']"() {
|
|
505
|
+
const entry = getCurrentEntry();
|
|
506
|
+
if (entry == null) return;
|
|
507
|
+
const { body } = entry.node;
|
|
508
|
+
if (body.type === AST_NODE_TYPES$1.BlockStatement) return;
|
|
509
|
+
entry.rets.push(body);
|
|
510
|
+
},
|
|
503
511
|
CallExpression(node) {
|
|
504
512
|
if (!isHookCall(node)) return;
|
|
505
513
|
const entry = getCurrentEntry();
|
|
506
514
|
if (entry == null) return;
|
|
507
|
-
|
|
515
|
+
entry.hookCalls.push(node);
|
|
516
|
+
},
|
|
517
|
+
ReturnStatement(node) {
|
|
518
|
+
const entry = getCurrentEntry();
|
|
519
|
+
if (entry == null) return;
|
|
520
|
+
entry.rets.push(node.argument);
|
|
508
521
|
}
|
|
509
522
|
}
|
|
510
523
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.5-beta.0",
|
|
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": "^8.58.0",
|
|
35
35
|
"@typescript-eslint/utils": "^8.58.0",
|
|
36
36
|
"ts-pattern": "^5.9.0",
|
|
37
|
-
"@eslint-react/ast": "4.2.
|
|
38
|
-
"@eslint-react/jsx": "4.2.
|
|
39
|
-
"@eslint-react/shared": "4.2.
|
|
40
|
-
"@eslint-react/var": "4.2.
|
|
37
|
+
"@eslint-react/ast": "4.2.5-beta.0",
|
|
38
|
+
"@eslint-react/jsx": "4.2.5-beta.0",
|
|
39
|
+
"@eslint-react/shared": "4.2.5-beta.0",
|
|
40
|
+
"@eslint-react/var": "4.2.5-beta.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@typescript-eslint/typescript-estree": "^8.58.0",
|