pasika 0.10.9 → 0.10.10
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 +32 -15
- package/package.json +1 -1
|
@@ -1524,7 +1524,8 @@ var enforceBarrelExportsRule = {
|
|
|
1524
1524
|
const filename = context.filename;
|
|
1525
1525
|
if (!filename) return {};
|
|
1526
1526
|
const baseName = path9.basename(filename);
|
|
1527
|
-
|
|
1527
|
+
const isIndexFile = baseName === "index.ts";
|
|
1528
|
+
if (!isIndexFile) return {};
|
|
1528
1529
|
const dirPath = path9.dirname(filename);
|
|
1529
1530
|
const folderName = path9.basename(dirPath);
|
|
1530
1531
|
const parentFolderName = path9.basename(path9.dirname(dirPath));
|
|
@@ -1565,10 +1566,11 @@ var enforceBarrelExportsRule = {
|
|
|
1565
1566
|
};
|
|
1566
1567
|
|
|
1567
1568
|
// eslint/rules/component-placement.ts
|
|
1568
|
-
import
|
|
1569
|
+
import fs3 from "fs";
|
|
1569
1570
|
import path11 from "path";
|
|
1570
1571
|
|
|
1571
1572
|
// eslint/project/ccf.ts
|
|
1573
|
+
import fs2 from "fs";
|
|
1572
1574
|
import path10 from "path";
|
|
1573
1575
|
var SUPPORT_FOLDERS2 = /* @__PURE__ */ new Set(["hooks", "types", "schemas", "constants", "utils"]);
|
|
1574
1576
|
function segmentsOf(file, sourceRoot) {
|
|
@@ -1623,8 +1625,20 @@ function resolveComponentPlacement(componentFile, index) {
|
|
|
1623
1625
|
return { countedConsumers: counted, expectedFolder: shared, reason: "ccf" };
|
|
1624
1626
|
}
|
|
1625
1627
|
var formatFolder = (folder) => `src/${folder.join("/")}/`;
|
|
1628
|
+
function isValidComponentFolder(folder, sourceRoot) {
|
|
1629
|
+
const name = folder[folder.length - 1];
|
|
1630
|
+
if (!name || SUPPORT_FOLDERS2.has(name)) return false;
|
|
1631
|
+
const folderPath = path10.join(sourceRoot, ...folder);
|
|
1632
|
+
return fs2.existsSync(path10.join(folderPath, `${name}.tsx`)) && fs2.existsSync(path10.join(folderPath, "index.ts"));
|
|
1633
|
+
}
|
|
1626
1634
|
function owningFolderOf(consumer, sourceRoot) {
|
|
1627
|
-
|
|
1635
|
+
const result = outOfSupportFolders(folderSegmentsOf(consumer, sourceRoot));
|
|
1636
|
+
const [topLevel] = result;
|
|
1637
|
+
let minimumDepth = result.length;
|
|
1638
|
+
if (topLevel === "features") minimumDepth = 2;
|
|
1639
|
+
if (topLevel === "compositions" || topLevel === "shared") minimumDepth = 1;
|
|
1640
|
+
while (result.length > minimumDepth && !isValidComponentFolder(result, sourceRoot)) result.pop();
|
|
1641
|
+
return result;
|
|
1628
1642
|
}
|
|
1629
1643
|
var configModuleOf = (segments) => isConfigModule(segments) && segments.length >= 3 ? segments[1] : void 0;
|
|
1630
1644
|
function resolveSupportPlacement(supportFile, supportFolder, index, importedBy = index.consumers.get(supportFile) ?? []) {
|
|
@@ -1668,7 +1682,7 @@ function isNestedInside(expectedFolder, currentFolder, componentFile) {
|
|
|
1668
1682
|
if (!sameFolder(currentFolder.slice(0, -1), expectedFolder)) return false;
|
|
1669
1683
|
const folderName = currentFolder[currentFolder.length - 1];
|
|
1670
1684
|
if (!folderName) return false;
|
|
1671
|
-
return
|
|
1685
|
+
return fs3.existsSync(path11.join(path11.dirname(componentFile), `${folderName}.tsx`));
|
|
1672
1686
|
}
|
|
1673
1687
|
var componentPlacementRule = {
|
|
1674
1688
|
meta: {
|
|
@@ -1794,7 +1808,7 @@ var supportFilePlacementRule = {
|
|
|
1794
1808
|
};
|
|
1795
1809
|
|
|
1796
1810
|
// eslint/rules/application-structure.ts
|
|
1797
|
-
import
|
|
1811
|
+
import fs4 from "fs";
|
|
1798
1812
|
import path13 from "path";
|
|
1799
1813
|
var MODULE_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"]);
|
|
1800
1814
|
var ROUTING_FILES = /* @__PURE__ */ new Set([
|
|
@@ -1861,6 +1875,9 @@ function componentFolderStart(segments) {
|
|
|
1861
1875
|
if (segments[0] === "compositions" || segments[0] === "shared") return 1;
|
|
1862
1876
|
return -1;
|
|
1863
1877
|
}
|
|
1878
|
+
function hasComponentBarrel(folderPath) {
|
|
1879
|
+
return fs4.existsSync(path13.join(folderPath, "index.ts"));
|
|
1880
|
+
}
|
|
1864
1881
|
function componentFolderViolation(segments, sourceRoot) {
|
|
1865
1882
|
const start = componentFolderStart(segments);
|
|
1866
1883
|
if (start < 0) return void 0;
|
|
@@ -1869,10 +1886,10 @@ function componentFolderViolation(segments, sourceRoot) {
|
|
|
1869
1886
|
if (!folder || SUPPORT_FOLDERS2.has(folder)) continue;
|
|
1870
1887
|
const folderPath = path13.join(sourceRoot, ...segments.slice(0, depth + 1));
|
|
1871
1888
|
const label = `src/${segments.slice(0, depth + 1).join("/")}/`;
|
|
1872
|
-
if (!
|
|
1889
|
+
if (!fs4.existsSync(path13.join(folderPath, `${folder}.tsx`))) {
|
|
1873
1890
|
return `A folder that is not a support folder must be a component folder; add "${folder}.tsx" to ${label} or move its files into a support folder.`;
|
|
1874
1891
|
}
|
|
1875
|
-
if (!
|
|
1892
|
+
if (!hasComponentBarrel(folderPath)) {
|
|
1876
1893
|
return `A component folder must have an index.ts that named-re-exports its component; add index.ts to ${label}.`;
|
|
1877
1894
|
}
|
|
1878
1895
|
}
|
|
@@ -1918,7 +1935,7 @@ var applicationStructureRule = {
|
|
|
1918
1935
|
);
|
|
1919
1936
|
}
|
|
1920
1937
|
const moduleRoot = configModuleRoot(filename, sourceRoot);
|
|
1921
|
-
if (moduleRoot && !
|
|
1938
|
+
if (moduleRoot && !fs4.existsSync(path13.join(moduleRoot, "index.ts"))) {
|
|
1922
1939
|
return report2(
|
|
1923
1940
|
context,
|
|
1924
1941
|
`Add src/config/${path13.basename(moduleRoot)}/index.ts as the configuration module entry point.`
|
|
@@ -2113,7 +2130,7 @@ function toKebabCase(value) {
|
|
|
2113
2130
|
}
|
|
2114
2131
|
|
|
2115
2132
|
// eslint/rules/support-folder-shape.ts
|
|
2116
|
-
import
|
|
2133
|
+
import fs5 from "fs";
|
|
2117
2134
|
import path16 from "path";
|
|
2118
2135
|
var SUPPORT_FOLDERS3 = /* @__PURE__ */ new Set(["constants", "types", "schemas"]);
|
|
2119
2136
|
var INDEX_NAMES = /* @__PURE__ */ new Set(["index.ts", "index.tsx", "index.mts", "index.cts"]);
|
|
@@ -2134,7 +2151,7 @@ var supportFolderShapeRule = {
|
|
|
2134
2151
|
const directory = path16.dirname(filename);
|
|
2135
2152
|
let entries;
|
|
2136
2153
|
try {
|
|
2137
|
-
entries =
|
|
2154
|
+
entries = fs5.readdirSync(directory);
|
|
2138
2155
|
} catch {
|
|
2139
2156
|
return {};
|
|
2140
2157
|
}
|
|
@@ -4797,7 +4814,7 @@ var sourceUnderSrcRule = {
|
|
|
4797
4814
|
};
|
|
4798
4815
|
|
|
4799
4816
|
// eslint/rules/zirka-baseline.ts
|
|
4800
|
-
import
|
|
4817
|
+
import fs6 from "fs";
|
|
4801
4818
|
import path44 from "path";
|
|
4802
4819
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
4803
4820
|
var PRETTIER_CONFIGS = [
|
|
@@ -4836,12 +4853,12 @@ var zirkaBaselineRule = {
|
|
|
4836
4853
|
);
|
|
4837
4854
|
}
|
|
4838
4855
|
const tsconfigPath = path44.join(projectRoot, "tsconfig.json");
|
|
4839
|
-
if (!
|
|
4856
|
+
if (!fs6.existsSync(tsconfigPath)) {
|
|
4840
4857
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
4841
4858
|
} else {
|
|
4842
4859
|
let extendsValue;
|
|
4843
4860
|
try {
|
|
4844
|
-
const parsed = JSON.parse(
|
|
4861
|
+
const parsed = JSON.parse(fs6.readFileSync(tsconfigPath, "utf8"));
|
|
4845
4862
|
extendsValue = typeof parsed === "object" && parsed !== null && "extends" in parsed ? parsed.extends : void 0;
|
|
4846
4863
|
} catch {
|
|
4847
4864
|
report3(
|
|
@@ -4853,13 +4870,13 @@ var zirkaBaselineRule = {
|
|
|
4853
4870
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
4854
4871
|
}
|
|
4855
4872
|
}
|
|
4856
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) =>
|
|
4873
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs6.existsSync(path44.join(projectRoot, name)));
|
|
4857
4874
|
if (!prettierConfigFile) {
|
|
4858
4875
|
report3(
|
|
4859
4876
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
4860
4877
|
);
|
|
4861
4878
|
} else {
|
|
4862
|
-
const content =
|
|
4879
|
+
const content = fs6.readFileSync(path44.join(projectRoot, prettierConfigFile), "utf8");
|
|
4863
4880
|
if (!content.includes("zirka")) {
|
|
4864
4881
|
report3(
|
|
4865
4882
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|