diff --git a/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.js b/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.js index ecd14f7317aa..52b1b27ba360 100644 --- a/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.js +++ b/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.js @@ -58,7 +58,7 @@ function traverseToTopFolder(src, pattern) { const srcIdx = src.lastIndexOf(path.sep); src = src.slice(0, srcIdx); } - return src.replace(/\\/g, '/'); + return src.replace(/\\/g, '/').replace(/\/$/, ''); } function isSameFolderOrDescendent(src, imported, pattern) { diff --git a/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.test.js b/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.test.js index 06e7a9c39414..96251e8fe55c 100644 --- a/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.test.js +++ b/packages/osd-eslint-plugin-eslint/rules/no_restricted_paths.test.js @@ -97,6 +97,22 @@ ruleTester.run('@osd/eslint/no-restricted-paths', rule, { }, ], }, + { + code: 'import b from "testfiles/no_restricted_paths/server/deep/deeper/e.js"', + filename: path.join(__dirname, 'testfiles/no_restricted_paths/server/deep/d.js'), + options: [ + { + basePath: __dirname, + zones: [ + { + target: 'testfiles/**/server/**/*', + from: 'testfiles/**/server/**/*', + allowSameFolder: true, + }, + ], + }, + ], + }, // irrelevant function calls {