UNPKG

@conarti/eslint-plugin-feature-sliced

Version:
25 lines (24 loc) 894 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertToPublicApi = void 0; const shared_1 = require("../../../lib/shared"); function addSlashToStart(targetPath) { if ((0, shared_1.isNull)(targetPath)) { return ''; } return `/${targetPath}`; } function extractValueToRemove(pathsInfo) { const { isSameSlice, fsdPartsOfTarget, } = pathsInfo; if (isSameSlice) { return fsdPartsOfTarget.segmentFiles; } return `${fsdPartsOfTarget.segment}${addSlashToStart(fsdPartsOfTarget.segmentFiles)}`; } function convertToPublicApi(pathsInfo) { const { normalizedTargetPath } = pathsInfo; const valueToRemove = extractValueToRemove(pathsInfo); const publicApiPath = normalizedTargetPath.replace(`/${valueToRemove}`, ''); return [publicApiPath, valueToRemove]; } exports.convertToPublicApi = convertToPublicApi;