persona-community-5/.pnpm-store/v3/files/6b/c6a0977cf2617e4d15ba2cf8d7b24fb866d628e412a3072e4c6527c8086bc0cc9d36f0e8e2c35de79d3f1ed01de8f950b97aae2f7d3aea3da43d5c2e09948c
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

46 lines
1.5 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NoAmbiguousPaths = void 0;
const NoAmbiguousPaths = () => {
return {
Paths(pathMap, { report, location }) {
const seenPaths = [];
for (const currentPath of Object.keys(pathMap)) {
const ambiguousPath = seenPaths.find((seenPath) => arePathsAmbiguous(seenPath, currentPath));
if (ambiguousPath) {
report({
message: `Paths should resolve unambiguously. Found two ambiguous paths: \`${ambiguousPath}\` and \`${currentPath}\`.`,
location: location.child([currentPath]).key(),
});
}
seenPaths.push(currentPath);
}
},
};
};
exports.NoAmbiguousPaths = NoAmbiguousPaths;
function arePathsAmbiguous(a, b) {
const partsA = a.split('/');
const partsB = b.split('/');
if (partsA.length !== partsB.length)
return false;
let aVars = 0;
let bVars = 0;
let ambiguous = true;
for (let i = 0; i < partsA.length; i++) {
const aIsVar = partsA[i].match(/^{.+?}$/);
const bIsVar = partsB[i].match(/^{.+?}$/);
if (aIsVar || bIsVar) {
if (aIsVar)
aVars++;
if (bIsVar)
bVars++;
continue;
}
else if (partsA[i] !== partsB[i]) {
ambiguous = false;
}
}
return ambiguous && aVars === bVars;
}