Skip to content

Commit 7c3ea3d

Browse files
author
spalger
committed
normalize path segments to before doing comparisons
1 parent f072e8a commit 7c3ea3d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/rules/no-reaching-inside.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ module.exports = function noReachingInside(context) {
2121
return step === '' || step === '.' || step === '..'
2222
}
2323

24+
function normalizeSep(somePath) {
25+
return somePath.split('\\').join('/')
26+
}
27+
2428
function report(reachedTo, node) {
2529
context.report({
2630
node,
@@ -29,11 +33,11 @@ module.exports = function noReachingInside(context) {
2933
}
3034

3135
function findNotAllowedReach(importPath, startingBase, join, ignoreStep) {
32-
const steps = importPath.split('/').filter(Boolean)
36+
const steps = normalizeSep(importPath).split('/').filter(Boolean)
3337
let parentDir = startingBase
3438
while (steps.length) {
3539
const step = steps.shift()
36-
parentDir = join(parentDir, step)
40+
parentDir = normalizeSep(join(parentDir, step))
3741

3842
if (ignoreStep && ignoreStep(step)) continue
3943

0 commit comments

Comments
 (0)