eslint-plugin-conarti-fsd
Version:
Feature-sliced design methodology plugin
35 lines (28 loc) • 686 B
JavaScript
module.exports.shouldBeRelative = (pathsInfo) => {
const {
isRelative,
importLayer,
importSlice,
currentFileLayer,
currentFileSlice,
} = pathsInfo;
if (isRelative) {
return false;
}
if (!importLayer || !importSlice) {
return false;
}
if (!currentFileLayer && !currentFileSlice) {
return false;
}
if (!currentFileSlice && importSlice && currentFileLayer === importLayer) {
return true;
}
if (
currentFileLayer === 'shared' && importLayer === 'shared'
|| currentFileLayer === 'app' && importLayer === 'app'
) {
return true;
}
return currentFileSlice === importSlice && currentFileLayer === importLayer;
};