pasika 0.10.6 → 0.10.9
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 +42 -4
- package/package.json +1 -1
|
@@ -1627,10 +1627,8 @@ function owningFolderOf(consumer, sourceRoot) {
|
|
|
1627
1627
|
return outOfSupportFolders(folderSegmentsOf(consumer, sourceRoot));
|
|
1628
1628
|
}
|
|
1629
1629
|
var configModuleOf = (segments) => isConfigModule(segments) && segments.length >= 3 ? segments[1] : void 0;
|
|
1630
|
-
function resolveSupportPlacement(supportFile, supportFolder, index) {
|
|
1631
|
-
const consumers = [...
|
|
1632
|
-
(consumer) => isPlacingConsumer(consumer, index.sourceRoot)
|
|
1633
|
-
);
|
|
1630
|
+
function resolveSupportPlacement(supportFile, supportFolder, index, importedBy = index.consumers.get(supportFile) ?? []) {
|
|
1631
|
+
const consumers = [...importedBy].filter((consumer) => isPlacingConsumer(consumer, index.sourceRoot));
|
|
1634
1632
|
if (consumers.length === 0) return void 0;
|
|
1635
1633
|
const consumerSegments = consumers.map((consumer) => segmentsOf(consumer, index.sourceRoot));
|
|
1636
1634
|
const configModules = new Set(consumerSegments.map((segments) => configModuleOf(segments)));
|
|
@@ -1722,6 +1720,12 @@ var componentPlacementRule = {
|
|
|
1722
1720
|
// eslint/rules/support-file-placement.ts
|
|
1723
1721
|
import path12 from "path";
|
|
1724
1722
|
var CONFIG_OWNED_FOLDERS = /* @__PURE__ */ new Set(["types", "constants"]);
|
|
1723
|
+
var EXPORT_KIND_BY_SUPPORT_FOLDER = /* @__PURE__ */ new Map([
|
|
1724
|
+
["constants", "constant"],
|
|
1725
|
+
["schemas", "schema"],
|
|
1726
|
+
["types", "type"],
|
|
1727
|
+
["utils", "function"]
|
|
1728
|
+
]);
|
|
1725
1729
|
var REASON_TEXT2 = {
|
|
1726
1730
|
"config-module": "every file that imports it belongs to that configuration module",
|
|
1727
1731
|
ccf: "that is the closest folder its consumers share",
|
|
@@ -1745,6 +1749,33 @@ var supportFilePlacementRule = {
|
|
|
1745
1749
|
if (supportFolder === void 0 || !SUPPORT_FOLDERS2.has(supportFolder)) return {};
|
|
1746
1750
|
const index = getProjectIndex(sourceRoot);
|
|
1747
1751
|
if (!index) return {};
|
|
1752
|
+
const groupedExportKind = EXPORT_KIND_BY_SUPPORT_FOLDER.get(supportFolder);
|
|
1753
|
+
if (groupedExportKind !== void 0) {
|
|
1754
|
+
const utilityExports = index.modules.get(supportFile)?.exports.filter((entry) => entry.kind === groupedExportKind) ?? [];
|
|
1755
|
+
const placements = utilityExports.map((entry) => ({
|
|
1756
|
+
name: entry.name,
|
|
1757
|
+
placement: resolveSupportPlacement(
|
|
1758
|
+
supportFile,
|
|
1759
|
+
supportFolder,
|
|
1760
|
+
index,
|
|
1761
|
+
index.symbolConsumers.get(symbolKey(supportFile, entry.name))
|
|
1762
|
+
)
|
|
1763
|
+
})).filter(
|
|
1764
|
+
(entry) => entry.placement !== void 0
|
|
1765
|
+
);
|
|
1766
|
+
const folders = new Set(placements.map((entry) => formatFolder(entry.placement.expectedFolder)));
|
|
1767
|
+
if (folders.size > 1) {
|
|
1768
|
+
return {
|
|
1769
|
+
Program(node) {
|
|
1770
|
+
context.report({
|
|
1771
|
+
node,
|
|
1772
|
+
loc: { line: 1, column: 0 },
|
|
1773
|
+
message: `Split ${supportFolder} exports with different CCFs: ${placements.map((entry) => `${entry.name} \u2192 ${formatFolder(entry.placement.expectedFolder)}`).join(", ")}.`
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1748
1779
|
const placement = resolveSupportPlacement(supportFile, supportFolder, index);
|
|
1749
1780
|
if (!placement || sameFolder2(currentFolder, placement.expectedFolder)) return {};
|
|
1750
1781
|
if (isConfigModule(segmentsOf(supportFile, sourceRoot)) && CONFIG_OWNED_FOLDERS.has(supportFolder)) {
|
|
@@ -2129,6 +2160,13 @@ var supportFolderShapeRule = {
|
|
|
2129
2160
|
return;
|
|
2130
2161
|
}
|
|
2131
2162
|
if (hasDirectExport) return;
|
|
2163
|
+
if (siblingModules.length === 1 && hasAnyReExport) {
|
|
2164
|
+
context.report({
|
|
2165
|
+
node,
|
|
2166
|
+
message: `${folder}/index.ts re-exports exactly one sibling module; define that module's exports directly in index.ts instead. See ${guide}`
|
|
2167
|
+
});
|
|
2168
|
+
return;
|
|
2169
|
+
}
|
|
2132
2170
|
const missing = siblingModules.filter((entry) => {
|
|
2133
2171
|
const stem = entry.replace(/\.(?:[cm]?tsx?|jsx?)$/, "");
|
|
2134
2172
|
return !exportedFiles.has(stem);
|