@eslint-react/core 2.0.0-next.175 → 2.0.0-next.176
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 -30
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -470,7 +470,7 @@ declare function resolveAttributeValue(context: RuleContext, attribute: AST.TSES
|
|
|
470
470
|
readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
|
|
471
471
|
} | {
|
|
472
472
|
readonly kind: "expression";
|
|
473
|
-
readonly node: TSESTree.
|
|
473
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
474
474
|
readonly toStatic: () => unknown;
|
|
475
475
|
} | {
|
|
476
476
|
readonly kind: "element";
|
|
@@ -478,7 +478,7 @@ declare function resolveAttributeValue(context: RuleContext, attribute: AST.TSES
|
|
|
478
478
|
readonly toStatic: () => undefined;
|
|
479
479
|
} | {
|
|
480
480
|
readonly kind: "spreadChild";
|
|
481
|
-
readonly node: TSESTree.
|
|
481
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
482
482
|
readonly toStatic: () => undefined;
|
|
483
483
|
} | {
|
|
484
484
|
readonly kind: "spreadProps";
|
|
@@ -740,7 +740,7 @@ declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
|
|
|
740
740
|
* @param prev The previous AST node in the traversal (used for context)
|
|
741
741
|
* @internal
|
|
742
742
|
*/
|
|
743
|
-
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.
|
|
743
|
+
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;
|
|
744
744
|
//#endregion
|
|
745
745
|
//#region src/utils/is-from-react.d.ts
|
|
746
746
|
/**
|
package/dist/index.js
CHANGED
|
@@ -230,24 +230,22 @@ function useHookCollector() {
|
|
|
230
230
|
const onFunctionExit = () => {
|
|
231
231
|
functionEntries.pop();
|
|
232
232
|
};
|
|
233
|
-
const ctx = { getAllHooks(node) {
|
|
234
|
-
return hooks;
|
|
235
|
-
} };
|
|
236
|
-
const listeners = {
|
|
237
|
-
":function[type]": onFunctionEnter,
|
|
238
|
-
":function[type]:exit": onFunctionExit,
|
|
239
|
-
"CallExpression[type]"(node) {
|
|
240
|
-
if (!isReactHookCall(node)) return;
|
|
241
|
-
const fEntry = functionEntries.at(-1);
|
|
242
|
-
if (fEntry?.key == null) return;
|
|
243
|
-
const hook = hooks.get(fEntry.key);
|
|
244
|
-
if (hook == null) return;
|
|
245
|
-
hook.hookCalls.push(node);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
233
|
return {
|
|
249
|
-
ctx
|
|
250
|
-
|
|
234
|
+
ctx: { getAllHooks(node) {
|
|
235
|
+
return hooks;
|
|
236
|
+
} },
|
|
237
|
+
listeners: {
|
|
238
|
+
":function[type]": onFunctionEnter,
|
|
239
|
+
":function[type]:exit": onFunctionExit,
|
|
240
|
+
"CallExpression[type]"(node) {
|
|
241
|
+
if (!isReactHookCall(node)) return;
|
|
242
|
+
const fEntry = functionEntries.at(-1);
|
|
243
|
+
if (fEntry?.key == null) return;
|
|
244
|
+
const hook = hooks.get(fEntry.key);
|
|
245
|
+
if (hook == null) return;
|
|
246
|
+
hook.hookCalls.push(node);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
251
249
|
};
|
|
252
250
|
}
|
|
253
251
|
|
|
@@ -777,8 +775,7 @@ function isInitializedFromReact(name, importSource, initialScope) {
|
|
|
777
775
|
const { init } = node;
|
|
778
776
|
if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return isInitializedFromReact(init.object.name, importSource, initialScope);
|
|
779
777
|
if (init.type === AST_NODE_TYPES.Identifier) return isInitializedFromReact(init.name, importSource, initialScope);
|
|
780
|
-
const
|
|
781
|
-
const arg0 = args?.[0];
|
|
778
|
+
const arg0 = getRequireExpressionArguments(init)?.[0];
|
|
782
779
|
if (arg0 == null || !AST.isLiteral(arg0, "string")) return false;
|
|
783
780
|
return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
|
|
784
781
|
}
|
|
@@ -895,8 +892,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
895
892
|
for (let i = rets.length - 1; i >= 0; i--) {
|
|
896
893
|
const ret = rets[i];
|
|
897
894
|
if (ret == null) continue;
|
|
898
|
-
|
|
899
|
-
if (shouldDrop) {
|
|
895
|
+
if (context.sourceCode.getScope(ret).block === entry.node && ret.argument != null && !isJsxLike(context.sourceCode, ret.argument, hint)) {
|
|
900
896
|
components.delete(entry.key);
|
|
901
897
|
break;
|
|
902
898
|
}
|
|
@@ -919,8 +915,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
919
915
|
const entry = getCurrentEntry();
|
|
920
916
|
if (entry == null) return;
|
|
921
917
|
const { body } = entry.node;
|
|
922
|
-
|
|
923
|
-
if (!isComponent) return;
|
|
918
|
+
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isComponentDefinition(context, entry.node, hint))) return;
|
|
924
919
|
const initPath = AST.getFunctionInitPath(entry.node);
|
|
925
920
|
const id = getFunctionComponentId(context, entry.node);
|
|
926
921
|
const name = getComponentNameFromId(id);
|
|
@@ -955,8 +950,7 @@ function useComponentCollector(context, options = {}) {
|
|
|
955
950
|
"ReturnStatement[type]"(node) {
|
|
956
951
|
const entry = getCurrentEntry();
|
|
957
952
|
if (entry == null) return;
|
|
958
|
-
|
|
959
|
-
if (!isComponent) return;
|
|
953
|
+
if (!(hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isComponentDefinition(context, entry.node, hint))) return;
|
|
960
954
|
entry.isComponent = true;
|
|
961
955
|
const initPath = AST.getFunctionInitPath(entry.node);
|
|
962
956
|
const id = getFunctionComponentId(context, entry.node);
|
|
@@ -1009,13 +1003,12 @@ function useComponentCollectorLegacy() {
|
|
|
1009
1003
|
methods: []
|
|
1010
1004
|
});
|
|
1011
1005
|
};
|
|
1012
|
-
const listeners = {
|
|
1013
|
-
"ClassDeclaration[type]": collect,
|
|
1014
|
-
"ClassExpression[type]": collect
|
|
1015
|
-
};
|
|
1016
1006
|
return {
|
|
1017
1007
|
ctx,
|
|
1018
|
-
listeners
|
|
1008
|
+
listeners: {
|
|
1009
|
+
"ClassDeclaration[type]": collect,
|
|
1010
|
+
"ClassExpression[type]": collect
|
|
1011
|
+
}
|
|
1019
1012
|
};
|
|
1020
1013
|
}
|
|
1021
1014
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.176",
|
|
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": {
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"./package.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
31
|
-
"@typescript-eslint/type-utils": "^8.
|
|
32
|
-
"@typescript-eslint/types": "^8.
|
|
33
|
-
"@typescript-eslint/utils": "^8.
|
|
30
|
+
"@typescript-eslint/scope-manager": "^8.43.0",
|
|
31
|
+
"@typescript-eslint/type-utils": "^8.43.0",
|
|
32
|
+
"@typescript-eslint/types": "^8.43.0",
|
|
33
|
+
"@typescript-eslint/utils": "^8.43.0",
|
|
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.0-next.
|
|
38
|
-
"@eslint-react/
|
|
39
|
-
"@eslint-react/
|
|
40
|
-
"@eslint-react/shared": "2.0.0-next.
|
|
41
|
-
"@eslint-react/var": "2.0.0-next.
|
|
37
|
+
"@eslint-react/ast": "2.0.0-next.176",
|
|
38
|
+
"@eslint-react/kit": "2.0.0-next.176",
|
|
39
|
+
"@eslint-react/eff": "2.0.0-next.176",
|
|
40
|
+
"@eslint-react/shared": "2.0.0-next.176",
|
|
41
|
+
"@eslint-react/var": "2.0.0-next.176"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsdown": "^0.14.2",
|