fix(linter): Normalize paths when in getSourceFilePath (#18601)
Co-authored-by: jgelin <jgelin@seligent.com>
This commit is contained in:
parent
2034cddf04
commit
1f9b3c4a5c
@ -9,6 +9,7 @@ import {
|
|||||||
DepConstraint,
|
DepConstraint,
|
||||||
findConstraintsFor,
|
findConstraintsFor,
|
||||||
findTransitiveExternalDependencies,
|
findTransitiveExternalDependencies,
|
||||||
|
getSourceFilePath,
|
||||||
hasBannedDependencies,
|
hasBannedDependencies,
|
||||||
hasBannedImport,
|
hasBannedImport,
|
||||||
hasNoneOfTheseTags,
|
hasNoneOfTheseTags,
|
||||||
@ -558,3 +559,19 @@ describe('hasNoneOfTheseTags', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getSourceFilePath', () => {
|
||||||
|
it.each([
|
||||||
|
['/root/libs/dev-kit/package.json', '/root'],
|
||||||
|
['/root/libs/dev-kit/package.json', 'C:\\root'],
|
||||||
|
['C:\\root\\libs\\dev-kit\\package.json', '/root'],
|
||||||
|
['C:\\root\\libs\\dev-kit\\package.json', 'C:\\root'],
|
||||||
|
])(
|
||||||
|
'should return "libs/dev-kit/package.json" when sourceFileName is "%s" and projectPath is "%s"',
|
||||||
|
(sourceFileName, projectPath) => {
|
||||||
|
expect(getSourceFilePath(sourceFileName, projectPath)).toBe(
|
||||||
|
'libs/dev-kit/package.json'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@ -222,8 +222,9 @@ export function onlyLoadChildren(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getSourceFilePath(sourceFileName: string, projectPath: string) {
|
export function getSourceFilePath(sourceFileName: string, projectPath: string) {
|
||||||
const relativePath = sourceFileName.slice(projectPath.length + 1);
|
const normalizedProjectPath = normalizePath(projectPath);
|
||||||
return normalizePath(relativePath);
|
const normalizedSourceFileName = normalizePath(sourceFileName);
|
||||||
|
return normalizedSourceFileName.slice(normalizedProjectPath.length + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user