UNPKG

eslint-plugin-sonarjs

Version:
47 lines (46 loc) • 2.29 kB
import { type NormalizedAbsolutePath, type NormalizedPath } from './path-normalization.js'; export { isAbsolutePath, normalizePath, normalizeToAbsolutePath, ROOT_PATH, } from './path-normalization.js'; export type { NormalizedAbsolutePath, NormalizedPath } from './path-normalization.js'; export type File = { readonly filePath: NormalizedAbsolutePath; readonly fileContent: string; }; /** * Removes any Byte Order Marker (BOM) from a string's head * * A string's head is nothing else but its first character. * * @param str the input string * @returns the stripped string */ export declare function stripBOM(str: string): string; export declare function isRoot(file: string): boolean; export declare function assertNestedPath(from: NormalizedAbsolutePath, topDir: NormalizedAbsolutePath): void; /** * Returns the filesystem root that contains the given absolute path. * Examples: '/a/b' -> '/', 'C:/a/b' -> 'C:/', 'D:/foo' -> 'D:/'. * Used as a cross-platform "no upper bound" sentinel for find-up callers. */ export declare function getPathRoot(filePath: NormalizedAbsolutePath): NormalizedAbsolutePath; /** * Type-safe dirname that preserves the NormalizedAbsolutePath brand. * The dirname of an absolute path is always absolute. * @param filePath the absolute path to get the directory of * @returns the parent directory as a branded NormalizedAbsolutePath */ export declare function dirnamePath(filePath: NormalizedAbsolutePath): NormalizedAbsolutePath; export declare function relativeToAncestorPath(filePath: NormalizedAbsolutePath, topDir: NormalizedAbsolutePath): string | undefined; /** * Type-safe path join that preserves the NormalizedAbsolutePath brand. * Joins path segments using posix separators. * @param base the base absolute path * @param segments additional path segments to join * @returns the joined path as a branded NormalizedAbsolutePath */ export declare function joinPaths(base: NormalizedAbsolutePath, ...segments: string[]): NormalizedAbsolutePath; /** * Type-safe basename that extracts the filename from a path. * @param filePath the path to extract the basename from * @returns the filename (last segment of the path) */ export declare function basenamePath(filePath: NormalizedPath | NormalizedAbsolutePath): string;