From be928ae19461f405d813798e49d2968982823c17 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 27 Jul 2023 20:45:50 -0700 Subject: [PATCH] [Refactor] `no-internal-modules`: simplify a reduce --- src/rules/no-internal-modules.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/rules/no-internal-modules.js b/src/rules/no-internal-modules.js index 687193f5c..5ed456547 100644 --- a/src/rules/no-internal-modules.js +++ b/src/rules/no-internal-modules.js @@ -58,16 +58,14 @@ module.exports = { } function toSteps(somePath) { - return normalizeSep(somePath) + return normalizeSep(somePath) .split('/') + .filter((step) => step && step !== '.') .reduce((acc, step) => { - if (!step || step === '.') { - return acc; - } else if (step === '..') { + if (step === '..') { return acc.slice(0, -1); - } else { - return acc.concat(step); } + return acc.concat(step); }, []); }