pasika 0.10.40 → 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.
|
@@ -5171,21 +5171,22 @@ var pureFunctionExtractRule = {
|
|
|
5171
5171
|
schema: [],
|
|
5172
5172
|
type: "problem",
|
|
5173
5173
|
docs: {
|
|
5174
|
-
description: "Require pure functions
|
|
5174
|
+
description: "Require module-scope pure functions to be extracted to utils/."
|
|
5175
5175
|
}
|
|
5176
5176
|
},
|
|
5177
5177
|
create(context) {
|
|
5178
5178
|
const filename = context.filename;
|
|
5179
5179
|
const isRouteFile = path40.basename(filename) === "route.ts";
|
|
5180
|
-
|
|
5180
|
+
const isComponentFile = filename.endsWith(".tsx") || filename.endsWith(".jsx");
|
|
5181
5181
|
const sourceRoot = sourceRootOf(context);
|
|
5182
5182
|
const relative = path40.relative(sourceRoot, filename);
|
|
5183
5183
|
if (relative.startsWith("..")) return {};
|
|
5184
5184
|
const segments = relative.split(path40.sep);
|
|
5185
|
-
|
|
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 {};
|
|
5186
5189
|
if (segments[0] === "app" && !isRouteFile) return {};
|
|
5187
|
-
const supportFolders = /* @__PURE__ */ new Set(["hooks", "types", "schemas", "constants", "utils"]);
|
|
5188
|
-
if (segments.length >= 2 && supportFolders.has(segments[segments.length - 1] ?? "")) return {};
|
|
5189
5190
|
function report3(node, name) {
|
|
5190
5191
|
context.report({
|
|
5191
5192
|
node,
|
|
@@ -5201,6 +5202,7 @@ var pureFunctionExtractRule = {
|
|
|
5201
5202
|
if (!name) return;
|
|
5202
5203
|
if (isRouteFile && ROUTE_HANDLER_EXPORT_NAMES.has(name)) return;
|
|
5203
5204
|
if (isComponentLikeName(name) || isHookName3(name)) return;
|
|
5205
|
+
if (isHookSupportFile && node.async) return;
|
|
5204
5206
|
if (!node.body || hasHookUsage(node.body)) return;
|
|
5205
5207
|
report3(node, name);
|
|
5206
5208
|
},
|
|
@@ -5218,6 +5220,7 @@ var pureFunctionExtractRule = {
|
|
|
5218
5220
|
if (!init || init.type !== "ArrowFunctionExpression" && init.type !== "FunctionExpression") {
|
|
5219
5221
|
return;
|
|
5220
5222
|
}
|
|
5223
|
+
if (isHookSupportFile && init.async) return;
|
|
5221
5224
|
if (init.body.type === "BlockStatement" && hasHookUsage(init.body)) return;
|
|
5222
5225
|
report3(node, name);
|
|
5223
5226
|
}
|