Skip to content

Commit

Permalink
[Refactor] no-internal-modules: simplify a reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 28, 2023
1 parent e7c2486 commit be928ae
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/rules/no-internal-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}, []);
}

Expand Down

0 comments on commit be928ae

Please sign in to comment.