fix types
This commit is contained in:
parent
22fdde6e39
commit
44cd30b23a
|
@ -16,15 +16,11 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
export function getPluginTarget(filePath: string) {
|
||||||
* @param {string} filePath
|
|
||||||
* @returns {string | null}
|
|
||||||
*/
|
|
||||||
export function getPluginTarget(filePath) {
|
|
||||||
const pathParts = filePath.split(/[/\\]/);
|
const pathParts = filePath.split(/[/\\]/);
|
||||||
if (/^index\.tsx?$/.test(pathParts.at(-1))) pathParts.pop();
|
if (/^index\.tsx?$/.test(pathParts.at(-1)!)) pathParts.pop();
|
||||||
|
|
||||||
const identifier = pathParts.at(-1).replace(/\.tsx?$/, "");
|
const identifier = pathParts.at(-1)!.replace(/\.tsx?$/, "");
|
||||||
const identiferBits = identifier.split(".");
|
const identiferBits = identifier.split(".");
|
||||||
return identiferBits.length === 1 ? null : identiferBits.at(-1);
|
return identiferBits.length === 1 ? null : identiferBits.at(-1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue