pasika 0.9.0 → 0.9.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/eslint/pasika/index.js +30 -5
- package/package.json +1 -1
|
@@ -2903,6 +2903,23 @@ var crossFeatureImportRule = {
|
|
|
2903
2903
|
|
|
2904
2904
|
// eslint/rules/pure-function-extract.ts
|
|
2905
2905
|
import path24 from "path";
|
|
2906
|
+
var ROUTE_HANDLER_EXPORT_NAMES = /* @__PURE__ */ new Set([
|
|
2907
|
+
"GET",
|
|
2908
|
+
"POST",
|
|
2909
|
+
"PUT",
|
|
2910
|
+
"PATCH",
|
|
2911
|
+
"DELETE",
|
|
2912
|
+
"HEAD",
|
|
2913
|
+
"OPTIONS",
|
|
2914
|
+
"dynamic",
|
|
2915
|
+
"dynamicParams",
|
|
2916
|
+
"revalidate",
|
|
2917
|
+
"fetchCache",
|
|
2918
|
+
"runtime",
|
|
2919
|
+
"preferredRegion",
|
|
2920
|
+
"maxDuration",
|
|
2921
|
+
"generateStaticParams"
|
|
2922
|
+
]);
|
|
2906
2923
|
function isComponentLikeName(name) {
|
|
2907
2924
|
return /^[A-Z]/.test(name);
|
|
2908
2925
|
}
|
|
@@ -2929,13 +2946,14 @@ var pureFunctionExtractRule = {
|
|
|
2929
2946
|
},
|
|
2930
2947
|
create(context) {
|
|
2931
2948
|
const filename = context.filename;
|
|
2932
|
-
|
|
2949
|
+
const isRouteFile = path24.basename(filename) === "route.ts";
|
|
2950
|
+
if (!filename.endsWith(".tsx") && !filename.endsWith(".jsx") && !isRouteFile) return {};
|
|
2933
2951
|
const sourceRoot = sourceRootOf(context);
|
|
2934
2952
|
const relative = path24.relative(sourceRoot, filename);
|
|
2935
2953
|
if (relative.startsWith("..")) return {};
|
|
2936
2954
|
const segments = relative.split(path24.sep);
|
|
2937
2955
|
if (segments[0] === "utils") return {};
|
|
2938
|
-
if (segments[0] === "app") return {};
|
|
2956
|
+
if (segments[0] === "app" && !isRouteFile) return {};
|
|
2939
2957
|
const supportFolders = /* @__PURE__ */ new Set(["hooks", "types", "schemas", "constants", "utils"]);
|
|
2940
2958
|
if (segments.length >= 2 && supportFolders.has(segments[segments.length - 1] ?? "")) return {};
|
|
2941
2959
|
function report3(node, name) {
|
|
@@ -2947,9 +2965,12 @@ var pureFunctionExtractRule = {
|
|
|
2947
2965
|
return {
|
|
2948
2966
|
FunctionDeclaration(node) {
|
|
2949
2967
|
const exported = node.parent?.type === "ExportNamedDeclaration";
|
|
2950
|
-
|
|
2968
|
+
const moduleLevel = exported || node.parent?.type === "Program";
|
|
2969
|
+
if (!moduleLevel) return;
|
|
2970
|
+
if (!isRouteFile && !exported) return;
|
|
2951
2971
|
const name = node.id?.name;
|
|
2952
2972
|
if (!name) return;
|
|
2973
|
+
if (isRouteFile && ROUTE_HANDLER_EXPORT_NAMES.has(name)) return;
|
|
2953
2974
|
if (isComponentLikeName(name) || isHookName2(name)) return;
|
|
2954
2975
|
if (!node.body || hasHookUsage(node.body)) return;
|
|
2955
2976
|
report3(node, name);
|
|
@@ -2958,8 +2979,12 @@ var pureFunctionExtractRule = {
|
|
|
2958
2979
|
if (node.id.type !== "Identifier") return;
|
|
2959
2980
|
const name = node.id.name;
|
|
2960
2981
|
if (!name) return;
|
|
2961
|
-
const
|
|
2962
|
-
|
|
2982
|
+
const container = node.parent.parent;
|
|
2983
|
+
const exported = container?.type === "ExportNamedDeclaration";
|
|
2984
|
+
const moduleLevel = exported || container?.type === "Program";
|
|
2985
|
+
if (!moduleLevel) return;
|
|
2986
|
+
if (!isRouteFile && !exported) return;
|
|
2987
|
+
if (isRouteFile && ROUTE_HANDLER_EXPORT_NAMES.has(name)) return;
|
|
2963
2988
|
if (isComponentLikeName(name) || isHookName2(name)) return;
|
|
2964
2989
|
const init = node.init;
|
|
2965
2990
|
if (!init || init.type !== "ArrowFunctionExpression" && init.type !== "FunctionExpression") {
|