UNPKG

@conarti/eslint-plugin-feature-sliced

Version:
22 lines (21 loc) 868 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractLayer = void 0; const config_1 = require("../../config"); const shared_1 = require("../shared"); function prepareToExtract(targetPath, cwd) { const lowerCasedTargetPath = targetPath.toLowerCase(); if (cwd === undefined) { return lowerCasedTargetPath; } const lowerCasedCwd = cwd.toLowerCase(); const pathWithoutCwd = lowerCasedTargetPath.replace(lowerCasedCwd, ''); return pathWithoutCwd; } function extractLayer(targetPath, cwd) { const layersRegExpPattern = `(${config_1.layers.join('|')})(?![\\w\\.-])`; const layersRegExp = new RegExp(layersRegExpPattern, 'ig'); const pathForExtract = prepareToExtract(targetPath, cwd); return (0, shared_1.getByRegExp)(pathForExtract, layersRegExp); } exports.extractLayer = extractLayer;