diff --git a/src/rules/no-extraneous-dependencies.ts b/src/rules/no-extraneous-dependencies.ts index b7f16ba1f..5124d3b08 100644 --- a/src/rules/no-extraneous-dependencies.ts +++ b/src/rules/no-extraneous-dependencies.ts @@ -337,7 +337,7 @@ function testConfig(config: string[] | boolean | undefined, filename: string) { return config.some( c => minimatch(filename, c) || - minimatch(filename, path.resolve(c).replaceAll(path.sep, '/')), + minimatch(filename, path.resolve(c), { windowsPathsNoEscape: true }), ) } diff --git a/src/rules/no-restricted-paths.ts b/src/rules/no-restricted-paths.ts index 8284079d7..aa810b2f6 100644 --- a/src/rules/no-restricted-paths.ts +++ b/src/rules/no-restricted-paths.ts @@ -14,7 +14,7 @@ const containsPath = (filepath: string, target: string) => { function isMatchingTargetPath(filename: string, targetPath: string) { if (isGlob(targetPath)) { - const mm = new Minimatch(targetPath.replaceAll(path.sep, '/')) + const mm = new Minimatch(targetPath, { windowsPathsNoEscape: true }) return mm.match(filename) } @@ -171,14 +171,14 @@ export = createRule<[Options?], MessageId>({ ) { let isPathException: ((absoluteImportPath: string) => boolean) | undefined - const mm = new Minimatch(absoluteFrom.replaceAll(path.sep, '/')) + const mm = new Minimatch(absoluteFrom, { windowsPathsNoEscape: true }) const isPathRestricted = (absoluteImportPath: string) => mm.match(absoluteImportPath) const hasValidExceptions = zoneExcept.every(it => isGlob(it)) if (hasValidExceptions) { const exceptionsMm = zoneExcept.map( - except => new Minimatch(except.replaceAll(path.sep, '/')), + except => new Minimatch(except, { windowsPathsNoEscape: true }), ) isPathException = (absoluteImportPath: string) => exceptionsMm.some(mm => mm.match(absoluteImportPath)) diff --git a/src/rules/no-unassigned-import.ts b/src/rules/no-unassigned-import.ts index e09fecf34..02d3be51d 100644 --- a/src/rules/no-unassigned-import.ts +++ b/src/rules/no-unassigned-import.ts @@ -22,7 +22,7 @@ function testIsAllow( return globs.some( glob => minimatch(filePath, glob) || - minimatch(filePath, path.resolve(glob).replaceAll(path.sep, '/')), + minimatch(filePath, path.resolve(glob), { windowsPathsNoEscape: true }), ) }