pasika 0.10.50 → 0.10.52
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 +14 -6
- package/package.json +1 -1
|
@@ -6312,7 +6312,7 @@ var supportFolderShapeRule = {
|
|
|
6312
6312
|
schema: [],
|
|
6313
6313
|
type: "problem",
|
|
6314
6314
|
docs: {
|
|
6315
|
-
description: "Require a support folder to either define its exports directly in index.ts or re-export
|
|
6315
|
+
description: "Require a support folder to either define its exports directly in index.ts or re-export its local sibling modules, never proxy an external module from an otherwise empty support folder or mix both."
|
|
6316
6316
|
}
|
|
6317
6317
|
},
|
|
6318
6318
|
create(context) {
|
|
@@ -6329,19 +6329,27 @@ var supportFolderShapeRule = {
|
|
|
6329
6329
|
return {};
|
|
6330
6330
|
}
|
|
6331
6331
|
const siblingModules = entries.filter((entry) => entry !== baseName && /\.(?:[cm]?tsx?|jsx?)$/.test(entry));
|
|
6332
|
-
if (siblingModules.length === 0) return {};
|
|
6333
6332
|
return {
|
|
6334
6333
|
Program(node) {
|
|
6335
6334
|
const source = context.sourceCode.text;
|
|
6336
|
-
const hasDirectExport = /export\s+(?:const|let|var|function|class|
|
|
6335
|
+
const hasDirectExport = /export\s+(?:const|let|var|function|class|interface|enum)\b/.test(source) || /export\s+type\s+[A-Za-z_$][\w$]*(?:\s*<[^;=]*>)?\s*=/.test(source);
|
|
6337
6336
|
const exportedFiles = /* @__PURE__ */ new Set();
|
|
6338
|
-
|
|
6337
|
+
let hasAnyReExport = false;
|
|
6338
|
+
const exportPattern = /export\s+(?:type\s+)?(?:\{[^}]*\}|\*)\s+from\s+["'](?<specifier>[^"']+)["']/g;
|
|
6339
6339
|
for (const match of source.matchAll(exportPattern)) {
|
|
6340
|
+
hasAnyReExport = true;
|
|
6340
6341
|
const specifier = match.groups?.specifier;
|
|
6341
|
-
if (specifier) exportedFiles.add(path49.basename(specifier));
|
|
6342
|
+
if (specifier?.startsWith(".")) exportedFiles.add(path49.basename(specifier));
|
|
6342
6343
|
}
|
|
6343
|
-
const hasAnyReExport = exportedFiles.size > 0;
|
|
6344
6344
|
const guide = `docs/next-codebase-guide/rules/${folder === "constants" ? "constants" : "types-and-schemas"}-rule.md`;
|
|
6345
|
+
if (siblingModules.length === 0) {
|
|
6346
|
+
if (hasDirectExport || !hasAnyReExport) return;
|
|
6347
|
+
context.report({
|
|
6348
|
+
node,
|
|
6349
|
+
message: `${folder}/index.ts re-exports from an external module without local support files; define the exports directly in index.ts. See ${guide}`
|
|
6350
|
+
});
|
|
6351
|
+
return;
|
|
6352
|
+
}
|
|
6345
6353
|
if (hasDirectExport && hasAnyReExport) {
|
|
6346
6354
|
context.report({
|
|
6347
6355
|
node,
|