@eslint-react/core 1.53.1-next.0 → 1.53.1-next.1
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.js +39 -38
- package/dist/index.mjs +23 -30
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -21,14 +21,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
let __eslint_react_ast = require("@eslint-react/ast");
|
|
25
|
+
__eslint_react_ast = __toESM(__eslint_react_ast);
|
|
26
|
+
let __eslint_react_eff = require("@eslint-react/eff");
|
|
27
|
+
__eslint_react_eff = __toESM(__eslint_react_eff);
|
|
28
|
+
let __eslint_react_kit = require("@eslint-react/kit");
|
|
29
|
+
__eslint_react_kit = __toESM(__eslint_react_kit);
|
|
30
|
+
let __eslint_react_shared = require("@eslint-react/shared");
|
|
31
|
+
__eslint_react_shared = __toESM(__eslint_react_shared);
|
|
32
|
+
let __typescript_eslint_types = require("@typescript-eslint/types");
|
|
33
|
+
__typescript_eslint_types = __toESM(__typescript_eslint_types);
|
|
34
|
+
let __eslint_react_var = require("@eslint-react/var");
|
|
35
|
+
__eslint_react_var = __toESM(__eslint_react_var);
|
|
36
|
+
let ts_pattern = require("ts-pattern");
|
|
37
|
+
ts_pattern = __toESM(ts_pattern);
|
|
38
|
+
let birecord = require("birecord");
|
|
39
|
+
birecord = __toESM(birecord);
|
|
32
40
|
|
|
33
41
|
//#region src/utils/get-instance-id.ts
|
|
34
42
|
/** @internal */
|
|
@@ -79,8 +87,7 @@ function isInitializedFromReact(name, importSource, initialScope) {
|
|
|
79
87
|
const { init } = node;
|
|
80
88
|
if (init.type === __typescript_eslint_types.AST_NODE_TYPES.MemberExpression && init.object.type === __typescript_eslint_types.AST_NODE_TYPES.Identifier) return isInitializedFromReact(init.object.name, importSource, initialScope);
|
|
81
89
|
if (init.type === __typescript_eslint_types.AST_NODE_TYPES.Identifier) return isInitializedFromReact(init.name, importSource, initialScope);
|
|
82
|
-
const
|
|
83
|
-
const arg0 = args?.[0];
|
|
90
|
+
const arg0 = getRequireExpressionArguments(init)?.[0];
|
|
84
91
|
if (arg0 == null || !__eslint_react_ast.isLiteral(arg0, "string")) return false;
|
|
85
92
|
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
86
93
|
}
|
|
@@ -271,24 +278,22 @@ function useHookCollector() {
|
|
|
271
278
|
const onFunctionExit = () => {
|
|
272
279
|
functionEntries.pop();
|
|
273
280
|
};
|
|
274
|
-
const ctx = { getAllHooks(node) {
|
|
275
|
-
return hooks;
|
|
276
|
-
} };
|
|
277
|
-
const listeners = {
|
|
278
|
-
":function[type]": onFunctionEnter,
|
|
279
|
-
":function[type]:exit": onFunctionExit,
|
|
280
|
-
"CallExpression[type]"(node) {
|
|
281
|
-
if (!isReactHookCall(node)) return;
|
|
282
|
-
const fEntry = functionEntries.at(-1);
|
|
283
|
-
if (fEntry?.key == null) return;
|
|
284
|
-
const hook = hooks.get(fEntry.key);
|
|
285
|
-
if (hook == null) return;
|
|
286
|
-
hook.hookCalls.push(node);
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
281
|
return {
|
|
290
|
-
ctx
|
|
291
|
-
|
|
282
|
+
ctx: { getAllHooks(node) {
|
|
283
|
+
return hooks;
|
|
284
|
+
} },
|
|
285
|
+
listeners: {
|
|
286
|
+
":function[type]": onFunctionEnter,
|
|
287
|
+
":function[type]:exit": onFunctionExit,
|
|
288
|
+
"CallExpression[type]"(node) {
|
|
289
|
+
if (!isReactHookCall(node)) return;
|
|
290
|
+
const fEntry = functionEntries.at(-1);
|
|
291
|
+
if (fEntry?.key == null) return;
|
|
292
|
+
const hook = hooks.get(fEntry.key);
|
|
293
|
+
if (hook == null) return;
|
|
294
|
+
hook.hookCalls.push(node);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
292
297
|
};
|
|
293
298
|
}
|
|
294
299
|
|
|
@@ -920,8 +925,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
920
925
|
for (let i = rets.length - 1; i >= 0; i--) {
|
|
921
926
|
const ret = rets[i];
|
|
922
927
|
if (ret == null) continue;
|
|
923
|
-
|
|
924
|
-
if (shouldDrop) {
|
|
928
|
+
if (context.sourceCode.getScope(ret).block === entry.node && ret.argument != null && !isJsxLike(context.sourceCode, ret.argument, hint)) {
|
|
925
929
|
components.delete(entry.key);
|
|
926
930
|
break;
|
|
927
931
|
}
|
|
@@ -944,8 +948,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
944
948
|
const entry = getCurrentEntry();
|
|
945
949
|
if (entry == null) return;
|
|
946
950
|
const { body } = entry.node;
|
|
947
|
-
|
|
948
|
-
if (!isComponent) return;
|
|
951
|
+
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint))) return;
|
|
949
952
|
const initPath = __eslint_react_ast.getFunctionInitPath(entry.node);
|
|
950
953
|
const id = getFunctionComponentId(context, entry.node);
|
|
951
954
|
const name = getComponentNameFromId(id);
|
|
@@ -980,8 +983,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
980
983
|
"ReturnStatement[type]"(node) {
|
|
981
984
|
const entry = getCurrentEntry();
|
|
982
985
|
if (entry == null) return;
|
|
983
|
-
|
|
984
|
-
if (!isComponent) return;
|
|
986
|
+
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint))) return;
|
|
985
987
|
entry.isComponent = true;
|
|
986
988
|
const initPath = __eslint_react_ast.getFunctionInitPath(entry.node);
|
|
987
989
|
const id = getFunctionComponentId(context, entry.node);
|
|
@@ -1034,13 +1036,12 @@ function useComponentCollectorLegacy() {
|
|
|
1034
1036
|
methods: []
|
|
1035
1037
|
});
|
|
1036
1038
|
};
|
|
1037
|
-
const listeners = {
|
|
1038
|
-
"ClassDeclaration[type]": collect,
|
|
1039
|
-
"ClassExpression[type]": collect
|
|
1040
|
-
};
|
|
1041
1039
|
return {
|
|
1042
1040
|
ctx,
|
|
1043
|
-
listeners
|
|
1041
|
+
listeners: {
|
|
1042
|
+
"ClassDeclaration[type]": collect,
|
|
1043
|
+
"ClassExpression[type]": collect
|
|
1044
|
+
}
|
|
1044
1045
|
};
|
|
1045
1046
|
}
|
|
1046
1047
|
|
package/dist/index.mjs
CHANGED
|
@@ -56,8 +56,7 @@ function isInitializedFromReact(name, importSource, initialScope) {
|
|
|
56
56
|
const { init } = node;
|
|
57
57
|
if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return isInitializedFromReact(init.object.name, importSource, initialScope);
|
|
58
58
|
if (init.type === AST_NODE_TYPES.Identifier) return isInitializedFromReact(init.name, importSource, initialScope);
|
|
59
|
-
const
|
|
60
|
-
const arg0 = args?.[0];
|
|
59
|
+
const arg0 = getRequireExpressionArguments(init)?.[0];
|
|
61
60
|
if (arg0 == null || !AST.isLiteral(arg0, "string")) return false;
|
|
62
61
|
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
63
62
|
}
|
|
@@ -248,24 +247,22 @@ function useHookCollector() {
|
|
|
248
247
|
const onFunctionExit = () => {
|
|
249
248
|
functionEntries.pop();
|
|
250
249
|
};
|
|
251
|
-
const ctx = { getAllHooks(node) {
|
|
252
|
-
return hooks;
|
|
253
|
-
} };
|
|
254
|
-
const listeners = {
|
|
255
|
-
":function[type]": onFunctionEnter,
|
|
256
|
-
":function[type]:exit": onFunctionExit,
|
|
257
|
-
"CallExpression[type]"(node) {
|
|
258
|
-
if (!isReactHookCall(node)) return;
|
|
259
|
-
const fEntry = functionEntries.at(-1);
|
|
260
|
-
if (fEntry?.key == null) return;
|
|
261
|
-
const hook = hooks.get(fEntry.key);
|
|
262
|
-
if (hook == null) return;
|
|
263
|
-
hook.hookCalls.push(node);
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
250
|
return {
|
|
267
|
-
ctx
|
|
268
|
-
|
|
251
|
+
ctx: { getAllHooks(node) {
|
|
252
|
+
return hooks;
|
|
253
|
+
} },
|
|
254
|
+
listeners: {
|
|
255
|
+
":function[type]": onFunctionEnter,
|
|
256
|
+
":function[type]:exit": onFunctionExit,
|
|
257
|
+
"CallExpression[type]"(node) {
|
|
258
|
+
if (!isReactHookCall(node)) return;
|
|
259
|
+
const fEntry = functionEntries.at(-1);
|
|
260
|
+
if (fEntry?.key == null) return;
|
|
261
|
+
const hook = hooks.get(fEntry.key);
|
|
262
|
+
if (hook == null) return;
|
|
263
|
+
hook.hookCalls.push(node);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
269
266
|
};
|
|
270
267
|
}
|
|
271
268
|
|
|
@@ -897,8 +894,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
897
894
|
for (let i = rets.length - 1; i >= 0; i--) {
|
|
898
895
|
const ret = rets[i];
|
|
899
896
|
if (ret == null) continue;
|
|
900
|
-
|
|
901
|
-
if (shouldDrop) {
|
|
897
|
+
if (context.sourceCode.getScope(ret).block === entry.node && ret.argument != null && !isJsxLike(context.sourceCode, ret.argument, hint)) {
|
|
902
898
|
components.delete(entry.key);
|
|
903
899
|
break;
|
|
904
900
|
}
|
|
@@ -921,8 +917,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
921
917
|
const entry = getCurrentEntry();
|
|
922
918
|
if (entry == null) return;
|
|
923
919
|
const { body } = entry.node;
|
|
924
|
-
|
|
925
|
-
if (!isComponent) return;
|
|
920
|
+
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint))) return;
|
|
926
921
|
const initPath = AST.getFunctionInitPath(entry.node);
|
|
927
922
|
const id = getFunctionComponentId(context, entry.node);
|
|
928
923
|
const name = getComponentNameFromId(id);
|
|
@@ -957,8 +952,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
957
952
|
"ReturnStatement[type]"(node) {
|
|
958
953
|
const entry = getCurrentEntry();
|
|
959
954
|
if (entry == null) return;
|
|
960
|
-
|
|
961
|
-
if (!isComponent) return;
|
|
955
|
+
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint))) return;
|
|
962
956
|
entry.isComponent = true;
|
|
963
957
|
const initPath = AST.getFunctionInitPath(entry.node);
|
|
964
958
|
const id = getFunctionComponentId(context, entry.node);
|
|
@@ -1011,13 +1005,12 @@ function useComponentCollectorLegacy() {
|
|
|
1011
1005
|
methods: []
|
|
1012
1006
|
});
|
|
1013
1007
|
};
|
|
1014
|
-
const listeners = {
|
|
1015
|
-
"ClassDeclaration[type]": collect,
|
|
1016
|
-
"ClassExpression[type]": collect
|
|
1017
|
-
};
|
|
1018
1008
|
return {
|
|
1019
1009
|
ctx,
|
|
1020
|
-
listeners
|
|
1010
|
+
listeners: {
|
|
1011
|
+
"ClassDeclaration[type]": collect,
|
|
1012
|
+
"ClassExpression[type]": collect
|
|
1013
|
+
}
|
|
1021
1014
|
};
|
|
1022
1015
|
}
|
|
1023
1016
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.53.1-next.
|
|
3
|
+
"version": "1.53.1-next.1",
|
|
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,20 +35,20 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
39
|
-
"@typescript-eslint/type-utils": "^8.
|
|
40
|
-
"@typescript-eslint/types": "^8.
|
|
41
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/scope-manager": "^8.43.0",
|
|
39
|
+
"@typescript-eslint/type-utils": "^8.43.0",
|
|
40
|
+
"@typescript-eslint/types": "^8.43.0",
|
|
41
|
+
"@typescript-eslint/utils": "^8.43.0",
|
|
42
42
|
"birecord": "^0.1.1",
|
|
43
43
|
"ts-pattern": "^5.8.0",
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/eff": "1.53.1-next.
|
|
47
|
-
"@eslint-react/var": "1.53.1-next.
|
|
48
|
-
"@eslint-react/
|
|
44
|
+
"@eslint-react/kit": "1.53.1-next.1",
|
|
45
|
+
"@eslint-react/ast": "1.53.1-next.1",
|
|
46
|
+
"@eslint-react/eff": "1.53.1-next.1",
|
|
47
|
+
"@eslint-react/var": "1.53.1-next.1",
|
|
48
|
+
"@eslint-react/shared": "1.53.1-next.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"tsdown": "^0.
|
|
51
|
+
"tsdown": "^0.15.0",
|
|
52
52
|
"@local/configs": "0.0.0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|