@eslint-react/core 5.27.0 → 5.27.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 +13 -10
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -167,6 +167,9 @@ const absurd = (_) => {
|
|
|
167
167
|
throw new Error("Called `absurd` function which should be uncallable");
|
|
168
168
|
};
|
|
169
169
|
cast(absurd);
|
|
170
|
+
function not(predicate) {
|
|
171
|
+
return (data) => !predicate(data);
|
|
172
|
+
}
|
|
170
173
|
dual(2, (a, b) => (data) => a(data) && b(data));
|
|
171
174
|
dual(2, (a, b) => (data) => a(data) || b(data));
|
|
172
175
|
dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
@@ -656,20 +659,20 @@ function isUseEffectLikeCall(node, additionalEffectHooks = { test: constFalse })
|
|
|
656
659
|
function isUseEffectSetupCallback(node) {
|
|
657
660
|
if (node == null) return false;
|
|
658
661
|
const expr = Extract.unwrap(node);
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
return
|
|
662
|
+
const call = Traverse.findParent(expr, not(Check.isTypeOrChainExpression));
|
|
663
|
+
if (call?.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
664
|
+
const [arg0] = call.arguments;
|
|
665
|
+
if (arg0 == null) return false;
|
|
666
|
+
return Extract.unwrap(arg0) === expr && isUseEffectLikeCall(call);
|
|
664
667
|
}
|
|
665
668
|
function isUseEffectCleanupCallback(node) {
|
|
666
669
|
if (node == null) return false;
|
|
667
670
|
const expr = Extract.unwrap(node);
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
if (
|
|
672
|
-
return
|
|
671
|
+
const func = Traverse.findParent(expr, Check.isFunction);
|
|
672
|
+
if (func == null || !isUseEffectSetupCallback(func)) return false;
|
|
673
|
+
const stat = Traverse.findParent(expr, Check.isReturnStatement, Check.isFunction);
|
|
674
|
+
if (stat != null) return stat.argument != null && Extract.unwrap(stat.argument) === expr;
|
|
675
|
+
return Check.isFunction(expr) && func.type === AST_NODE_TYPES.ArrowFunctionExpression && Extract.unwrap(func.body) === expr;
|
|
673
676
|
}
|
|
674
677
|
//#endregion
|
|
675
678
|
//#region src/function-component-collector.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "5.27.
|
|
3
|
+
"version": "5.27.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": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@eslint-react/ast": "5.27.
|
|
33
|
-
"@eslint-react/eslint": "5.27.
|
|
34
|
-
"@eslint-react/shared": "5.27.
|
|
35
|
-
"@eslint-react/var": "5.27.
|
|
32
|
+
"@eslint-react/ast": "5.27.1",
|
|
33
|
+
"@eslint-react/eslint": "5.27.1",
|
|
34
|
+
"@eslint-react/shared": "5.27.1",
|
|
35
|
+
"@eslint-react/var": "5.27.1",
|
|
36
36
|
"@typescript-eslint/types": "^8.71.2",
|
|
37
37
|
"@typescript-eslint/utils": "^8.71.2",
|
|
38
38
|
"ts-pattern": "^5.9.2"
|