pasika 0.10.41 → 0.10.42
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.
|
@@ -5177,13 +5177,15 @@ var pureFunctionExtractRule = {
|
|
|
5177
5177
|
create(context) {
|
|
5178
5178
|
const filename = context.filename;
|
|
5179
5179
|
const isRouteFile = path40.basename(filename) === "route.ts";
|
|
5180
|
-
const
|
|
5181
|
-
if (!isSourceFile && !isRouteFile) return {};
|
|
5180
|
+
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
5182
5181
|
const sourceRoot = sourceRootOf(context);
|
|
5183
5182
|
const relative = path40.relative(sourceRoot, filename);
|
|
5184
5183
|
if (relative.startsWith("..")) return {};
|
|
5185
5184
|
const segments = relative.split(path40.sep);
|
|
5186
|
-
|
|
5185
|
+
const folders = segments.slice(0, -1);
|
|
5186
|
+
const isHookSupportFile = folders.includes("hooks") && /\.(?:[cm]?[jt]s)$/.test(filename);
|
|
5187
|
+
if (!isComponentFile && !isRouteFile && !isHookSupportFile) return {};
|
|
5188
|
+
if (folders.includes("utils")) return {};
|
|
5187
5189
|
if (segments[0] === "app" && !isRouteFile) return {};
|
|
5188
5190
|
function report3(node, name) {
|
|
5189
5191
|
context.report({
|
|
@@ -5200,6 +5202,7 @@ var pureFunctionExtractRule = {
|
|
|
5200
5202
|
if (!name) return;
|
|
5201
5203
|
if (isRouteFile && ROUTE_HANDLER_EXPORT_NAMES.has(name)) return;
|
|
5202
5204
|
if (isComponentLikeName(name) || isHookName3(name)) return;
|
|
5205
|
+
if (isHookSupportFile && node.async) return;
|
|
5203
5206
|
if (!node.body || hasHookUsage(node.body)) return;
|
|
5204
5207
|
report3(node, name);
|
|
5205
5208
|
},
|
|
@@ -5217,6 +5220,7 @@ var pureFunctionExtractRule = {
|
|
|
5217
5220
|
if (!init || init.type !== "ArrowFunctionExpression" && init.type !== "FunctionExpression") {
|
|
5218
5221
|
return;
|
|
5219
5222
|
}
|
|
5223
|
+
if (isHookSupportFile && init.async) return;
|
|
5220
5224
|
if (init.body.type === "BlockStatement" && hasHookUsage(init.body)) return;
|
|
5221
5225
|
report3(node, name);
|
|
5222
5226
|
}
|