eslint-plugin-conarti-fsd
Version:
Feature-sliced design methodology plugin
19 lines (14 loc) • 464 B
JavaScript
const addSlashToStart = (targetPath) => targetPath ? `/${targetPath}` : '';
module.exports.convertToPublicApi = (pathsInfo) => {
const {
normalizedImportPath,
isSameSlice,
segmentFiles,
segment,
} = pathsInfo;
const valueToRemove = isSameSlice
? segmentFiles
: `${segment}${addSlashToStart(segmentFiles)}`;
const publicApiPath = normalizedImportPath.replace(`/${valueToRemove}`, '');
return [publicApiPath, valueToRemove];
};