UNPKG

@layuplabs/layup-autoid

Version:

A tool to inject stable, unique IDs into React components

50 lines (44 loc) 1.77 kB
declare module "layup-id-injector" { /** * Injects or removes data-testid attributes from a React component file * @param filePath The path to the file to process * @returns boolean indicating whether the file was modified */ export function injectIdsInFile(filePath: string): boolean; /** * Runs the ID injector on all matching files in the project * @param options Optional configuration options * @param customElements Optional array of custom component names to process * @param ignoreDefaults When true, ignores default HTML elements (requires customElements to be provided) * @param ignorePath Optional path to ignore when processing files * @param remove When true, removes data-testid attributes instead of adding them */ export function run(options?: { staged?: boolean; path?: string; customElements?: string[]; ignoreDefaults?: boolean; ignorePath?: string; remove?: boolean; }): Promise<void>; /** * Sets the custom elements to be processed by the injector * @param elements Array of custom component names to process */ export function setCustomElements(elements: string[]): void; /** * Sets whether to ignore default HTML elements (requires custom elements to be set) * @param ignore Whether to ignore default HTML elements */ export function setIgnoreDefaults(ignore: boolean): void; /** * Sets paths to ignore when processing files * @param paths Array of paths to ignore */ export function setIgnorePaths(paths: string[]): void; /** * Sets whether to remove data-testid attributes instead of adding them * @param remove Whether to remove data-testid attributes */ export function setRemoveTestIds(remove: boolean): void; }