@eslint-react/core 2.3.10 → 2.3.11-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 +7 -18
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ declare namespace useComponentCollector {
|
|
|
138
138
|
};
|
|
139
139
|
type ReturnType = {
|
|
140
140
|
ctx: {
|
|
141
|
-
getAllComponents: (node: TSESTree.Program) =>
|
|
141
|
+
getAllComponents: (node: TSESTree.Program) => FunctionComponent[];
|
|
142
142
|
getCurrentEntries: () => FunctionEntry[];
|
|
143
143
|
getCurrentEntry: () => FunctionEntry | unit;
|
|
144
144
|
};
|
|
@@ -157,7 +157,7 @@ declare function useComponentCollector(context: RuleContext, options?: useCompon
|
|
|
157
157
|
declare namespace useComponentCollectorLegacy {
|
|
158
158
|
type ReturnType = {
|
|
159
159
|
ctx: {
|
|
160
|
-
getAllComponents: (node: TSESTree$1.Program) =>
|
|
160
|
+
getAllComponents: (node: TSESTree$1.Program) => ClassComponent[];
|
|
161
161
|
};
|
|
162
162
|
listeners: ESLintUtils.RuleListener;
|
|
163
163
|
};
|
|
@@ -350,7 +350,7 @@ interface Hook extends SemanticNode {
|
|
|
350
350
|
declare namespace useHookCollector {
|
|
351
351
|
type ReturnType = {
|
|
352
352
|
ctx: {
|
|
353
|
-
getAllHooks(node: TSESTree$1.Program):
|
|
353
|
+
getAllHooks(node: TSESTree$1.Program): Hook[];
|
|
354
354
|
};
|
|
355
355
|
listeners: ESLintUtils.RuleListener;
|
|
356
356
|
};
|
package/dist/index.js
CHANGED
|
@@ -230,7 +230,7 @@ function useHookCollector() {
|
|
|
230
230
|
};
|
|
231
231
|
return {
|
|
232
232
|
ctx: { getAllHooks(node) {
|
|
233
|
-
return hooks;
|
|
233
|
+
return [...hooks.values()];
|
|
234
234
|
} },
|
|
235
235
|
listeners: {
|
|
236
236
|
":function[type]": onFunctionEnter,
|
|
@@ -901,8 +901,8 @@ const idGen$1 = new IdGenerator("function_component_");
|
|
|
901
901
|
*/
|
|
902
902
|
function useComponentCollector(context, options = {}) {
|
|
903
903
|
const { collectDisplayName = false, collectHookCalls = false, hint = DEFAULT_COMPONENT_DETECTION_HINT } = options;
|
|
904
|
-
const components = /* @__PURE__ */ new Map();
|
|
905
904
|
const functionEntries = [];
|
|
905
|
+
const components = /* @__PURE__ */ new Map();
|
|
906
906
|
const getCurrentEntry = () => functionEntries.at(-1);
|
|
907
907
|
const onFunctionEnter = (node) => {
|
|
908
908
|
const key = idGen$1.next();
|
|
@@ -914,24 +914,12 @@ function useComponentCollector(context, options = {}) {
|
|
|
914
914
|
});
|
|
915
915
|
};
|
|
916
916
|
const onFunctionExit = () => {
|
|
917
|
-
const entry = functionEntries.at(-1);
|
|
918
|
-
if (entry == null) return;
|
|
919
|
-
if (!entry.isComponent) return functionEntries.pop();
|
|
920
|
-
const rets = AST.getNestedReturnStatements(entry.node.body);
|
|
921
|
-
for (let i = rets.length - 1; i >= 0; i--) {
|
|
922
|
-
const ret = rets[i];
|
|
923
|
-
if (ret == null) continue;
|
|
924
|
-
if (context.sourceCode.getScope(ret).block === entry.node && ret.argument != null && !isJsxLike(context.sourceCode, ret.argument, hint)) {
|
|
925
|
-
components.delete(entry.key);
|
|
926
|
-
break;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
917
|
return functionEntries.pop();
|
|
930
918
|
};
|
|
931
919
|
return {
|
|
932
920
|
ctx: {
|
|
933
921
|
getAllComponents(node) {
|
|
934
|
-
return components;
|
|
922
|
+
return [...components.values()];
|
|
935
923
|
},
|
|
936
924
|
getCurrentEntries() {
|
|
937
925
|
return [...functionEntries];
|
|
@@ -984,10 +972,11 @@ function useComponentCollector(context, options = {}) {
|
|
|
984
972
|
entry.isComponent = true;
|
|
985
973
|
const initPath = AST.getFunctionInitPath(entry.node);
|
|
986
974
|
const id = getFunctionComponentId(context, entry.node);
|
|
975
|
+
const key = entry.key;
|
|
987
976
|
const name = getComponentNameFromId(id);
|
|
988
|
-
components.set(
|
|
977
|
+
components.set(key, {
|
|
989
978
|
id,
|
|
990
|
-
key
|
|
979
|
+
key,
|
|
991
980
|
kind: "function",
|
|
992
981
|
name,
|
|
993
982
|
node: entry.node,
|
|
@@ -1012,7 +1001,7 @@ const idGen = new IdGenerator("class_component_");
|
|
|
1012
1001
|
function useComponentCollectorLegacy() {
|
|
1013
1002
|
const components = /* @__PURE__ */ new Map();
|
|
1014
1003
|
const ctx = { getAllComponents(node) {
|
|
1015
|
-
return components;
|
|
1004
|
+
return [...components.values()];
|
|
1016
1005
|
} };
|
|
1017
1006
|
const collect = (node) => {
|
|
1018
1007
|
if (!isClassComponent(node)) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.11-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": {
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
"@typescript-eslint/utils": "^8.48.0",
|
|
36
36
|
"birecord": "^0.1.1",
|
|
37
37
|
"ts-pattern": "^5.9.0",
|
|
38
|
-
"@eslint-react/ast": "2.3.
|
|
39
|
-
"@eslint-react/eff": "2.3.
|
|
40
|
-
"@eslint-react/var": "2.3.
|
|
41
|
-
"@eslint-react/shared": "2.3.
|
|
38
|
+
"@eslint-react/ast": "2.3.11-beta.0",
|
|
39
|
+
"@eslint-react/eff": "2.3.11-beta.0",
|
|
40
|
+
"@eslint-react/var": "2.3.11-beta.0",
|
|
41
|
+
"@eslint-react/shared": "2.3.11-beta.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
45
45
|
"typescript": ">=4.8.4 <6.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"tsdown": "^0.17.0-beta.
|
|
48
|
+
"tsdown": "^0.17.0-beta.5",
|
|
49
49
|
"@local/configs": "0.0.0"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|