pasika 0.7.6 → 0.7.7
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 +12 -3
- package/package.json +1 -1
|
@@ -2056,7 +2056,7 @@ var supportFolderShapeRule = {
|
|
|
2056
2056
|
schema: [],
|
|
2057
2057
|
type: "problem",
|
|
2058
2058
|
docs: {
|
|
2059
|
-
description: "Require support
|
|
2059
|
+
description: "Require a support folder to either define its exports directly in index.ts or re-export every sibling from it, never both."
|
|
2060
2060
|
}
|
|
2061
2061
|
},
|
|
2062
2062
|
create(context) {
|
|
@@ -2078,13 +2078,22 @@ var supportFolderShapeRule = {
|
|
|
2078
2078
|
Program(node) {
|
|
2079
2079
|
const source = context.sourceCode.text;
|
|
2080
2080
|
const hasDirectExport = /export\s+(?:const|let|var|function|class|type|interface|enum)\b/.test(source);
|
|
2081
|
-
if (hasDirectExport) return;
|
|
2082
2081
|
const exportedFiles = /* @__PURE__ */ new Set();
|
|
2083
2082
|
const exportPattern = /export\s+(?:\{[^}]*\}|\*[^;]*)\s+from\s+["'](?<specifier>\.[^"']+)["']/g;
|
|
2084
2083
|
for (const match of source.matchAll(exportPattern)) {
|
|
2085
2084
|
const specifier = match.groups?.specifier;
|
|
2086
2085
|
if (specifier) exportedFiles.add(path16.basename(specifier));
|
|
2087
2086
|
}
|
|
2087
|
+
const hasAnyReExport = exportedFiles.size > 0;
|
|
2088
|
+
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
2089
|
+
if (hasDirectExport && hasAnyReExport) {
|
|
2090
|
+
context.report({
|
|
2091
|
+
node,
|
|
2092
|
+
message: `${folder}/index.ts mixes direct exports with re-exported support files; pick one strategy for the whole folder. See ${guide}`
|
|
2093
|
+
});
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
if (hasDirectExport) return;
|
|
2088
2097
|
const missing = siblingModules.filter((entry) => {
|
|
2089
2098
|
const stem = entry.replace(/\.(?:[cm]?tsx?|jsx?)$/, "");
|
|
2090
2099
|
return !exportedFiles.has(stem);
|
|
@@ -2092,7 +2101,7 @@ var supportFolderShapeRule = {
|
|
|
2092
2101
|
if (missing.length === 0) return;
|
|
2093
2102
|
context.report({
|
|
2094
2103
|
node,
|
|
2095
|
-
message: `${folder}/index.ts must
|
|
2104
|
+
message: `${folder}/index.ts must re-export every support file: ${missing.join(", ")}. See ${guide}`
|
|
2096
2105
|
});
|
|
2097
2106
|
}
|
|
2098
2107
|
};
|