From e7a72b9cd49da4c04d36ceae676e5c784e644a25 Mon Sep 17 00:00:00 2001 From: Emily Marigold Klassen Date: Mon, 7 Feb 2022 18:02:45 -0800 Subject: [PATCH] refactor: simplify toPosixPath for the sake of coverage --- src/rules/no-relative-packages.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/rules/no-relative-packages.js b/src/rules/no-relative-packages.js index 3c9e6f2b6e..7bf1ce5cea 100644 --- a/src/rules/no-relative-packages.js +++ b/src/rules/no-relative-packages.js @@ -6,11 +6,10 @@ import moduleVisitor, { makeOptionsSchema } from 'eslint-module-utils/moduleVisi import importType from '../core/importType'; import docsUrl from '../docsUrl'; -/** @type {(filePath: string) => string} */ -const toPosixPath = - path.sep === '\\' - ? (filePath) => filePath.replace(/\\/g, '/') - : (filePath) => filePath; +/** @param {string} filePath */ +function toPosixPath(filePath) { + return filePath.replace(/\\/g, '/'); +} function findNamedPackage(filePath) { const found = readPkgUp({ cwd: filePath });