UNPKG

eslint-plugin-sonarjs

Version:
32 lines (31 loc) • 1.42 kB
export type NormalizedPath = string & { readonly __normalizedPathBrand: 'NormalizedPath'; }; export type NormalizedAbsolutePath = string & { readonly __normalizedAbsolutePathBrand: 'NormalizedAbsolutePath'; }; /** * Root path constant for Unix filesystem */ export declare const ROOT_PATH: NormalizedAbsolutePath; /** * Normalizes a path to Unix format (forward slashes). * For absolute paths on Windows, resolves them to ensure they have a drive letter. * For relative paths, only converts slashes without resolving. * Cross-platform behavior: * - On Windows: all absolute paths are resolved with win32 to add drive letter * - On Linux: paths are only converted (slashes), no resolution needed * @param filePath the path to normalize * @returns the normalized path as a branded UnixPath type */ export declare function normalizePath(filePath: string): NormalizedPath; /** * Normalizes a path to an absolute Unix format. * Guarantees the returned path is absolute. * @param filePath the path to normalize * @param baseDir base directory to resolve relative paths against * @returns the normalized path as a branded AbsoluteUnixPath type */ export declare function normalizeToAbsolutePath(filePath: string, baseDir?: NormalizedAbsolutePath): NormalizedAbsolutePath; export declare function isAbsolutePath(path: string): boolean; export declare function toUnixPath(filePath: string): string;