pasika 0.10.9 → 0.10.11
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 +37 -16
- 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
|
}
|
|
@@ -3161,6 +3178,9 @@ function analyzeHandlerBody(body, sourceText) {
|
|
|
3161
3178
|
if (ts4.isTryStatement(node)) kinds.add("try");
|
|
3162
3179
|
if (isLoop(node)) kinds.add("loop");
|
|
3163
3180
|
if (ts4.isIfStatement(node)) kinds.add("if");
|
|
3181
|
+
if (ts4.isCallExpression(node) && ts4.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map") {
|
|
3182
|
+
kinds.add("map");
|
|
3183
|
+
}
|
|
3164
3184
|
if (ts4.isCallExpression(node) && ts4.isIdentifier(node.expression)) calledNames.add(node.expression.text);
|
|
3165
3185
|
if (isFunctionBoundary(node)) return;
|
|
3166
3186
|
ts4.forEachChild(node, visit);
|
|
@@ -3171,7 +3191,8 @@ function analyzeHandlerBody(body, sourceText) {
|
|
|
3171
3191
|
var CONTROL_FLOW_MESSAGES = {
|
|
3172
3192
|
try: "a try statement",
|
|
3173
3193
|
loop: "a loop",
|
|
3174
|
-
if: "an if statement"
|
|
3194
|
+
if: "an if statement",
|
|
3195
|
+
map: "a map operation"
|
|
3175
3196
|
};
|
|
3176
3197
|
function isFunctionLikeInit(node) {
|
|
3177
3198
|
return node?.type === "ArrowFunctionExpression" || node?.type === "FunctionExpression";
|
|
@@ -4797,7 +4818,7 @@ var sourceUnderSrcRule = {
|
|
|
4797
4818
|
};
|
|
4798
4819
|
|
|
4799
4820
|
// eslint/rules/zirka-baseline.ts
|
|
4800
|
-
import
|
|
4821
|
+
import fs6 from "fs";
|
|
4801
4822
|
import path44 from "path";
|
|
4802
4823
|
var ESLINT_CONFIG = /^eslint\.config\.(?:ts|mts|cts|js|mjs|cjs)$/;
|
|
4803
4824
|
var PRETTIER_CONFIGS = [
|
|
@@ -4836,12 +4857,12 @@ var zirkaBaselineRule = {
|
|
|
4836
4857
|
);
|
|
4837
4858
|
}
|
|
4838
4859
|
const tsconfigPath = path44.join(projectRoot, "tsconfig.json");
|
|
4839
|
-
if (!
|
|
4860
|
+
if (!fs6.existsSync(tsconfigPath)) {
|
|
4840
4861
|
report3('No tsconfig.json found. Create one extending the zirka TypeScript base config ("zirka/typescript").');
|
|
4841
4862
|
} else {
|
|
4842
4863
|
let extendsValue;
|
|
4843
4864
|
try {
|
|
4844
|
-
const parsed = JSON.parse(
|
|
4865
|
+
const parsed = JSON.parse(fs6.readFileSync(tsconfigPath, "utf8"));
|
|
4845
4866
|
extendsValue = typeof parsed === "object" && parsed !== null && "extends" in parsed ? parsed.extends : void 0;
|
|
4846
4867
|
} catch {
|
|
4847
4868
|
report3(
|
|
@@ -4853,13 +4874,13 @@ var zirkaBaselineRule = {
|
|
|
4853
4874
|
report3('tsconfig.json must extend the zirka TypeScript base config ("zirka/typescript").');
|
|
4854
4875
|
}
|
|
4855
4876
|
}
|
|
4856
|
-
const prettierConfigFile = PRETTIER_CONFIGS.find((name) =>
|
|
4877
|
+
const prettierConfigFile = PRETTIER_CONFIGS.find((name) => fs6.existsSync(path44.join(projectRoot, name)));
|
|
4857
4878
|
if (!prettierConfigFile) {
|
|
4858
4879
|
report3(
|
|
4859
4880
|
"No prettier config found. Create one that takes its configuration from zirka (styleguide({ prettier: true }).prettierConfig)."
|
|
4860
4881
|
);
|
|
4861
4882
|
} else {
|
|
4862
|
-
const content =
|
|
4883
|
+
const content = fs6.readFileSync(path44.join(projectRoot, prettierConfigFile), "utf8");
|
|
4863
4884
|
if (!content.includes("zirka")) {
|
|
4864
4885
|
report3(
|
|
4865
4886
|
"The prettier config must take its configuration from zirka (styleguide({ prettier: true }).prettierConfig) instead of restating it locally."
|