UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

76 lines (75 loc) 3.03 kB
import ts from "typescript"; import { TranslationHook, TranslationCall } from "../types/translation.additional"; import { TranslationKey } from "../../../types/translation.types"; /** * React-i18next specific translation call with additional context */ export interface ReactI18nextCall extends TranslationCall { /** Namespace from options object if present */ namespaceFromOptions?: string; /** Default value from options if present */ defaultValue?: string; /** Whether the key uses namespace prefix (namespace:key) */ hasNamespacePrefix: boolean; } /** * Finds all react-i18next translation hooks in a source file * @param sourceFile TypeScript source file * @param filePath Path to the source file * @returns Array of translation hooks found in the file */ export declare function findReactI18nextHooksInFile(sourceFile: ts.SourceFile, filePath: string): TranslationHook[]; /** * Finds all react-i18next translation calls for a specific hook * @param sourceFile TypeScript source file * @param hookName The variable name used for translations (usually 't') * @returns Array of react-i18next translation calls */ export declare function findReactI18nextCalls(sourceFile: ts.SourceFile, hookName: string): ReactI18nextCall[]; /** * Processes a react-i18next translation key and creates a TranslationKey object * @param call React-i18next call information * @param hookNamespace Namespace from the hook declaration * @param componentName The component name * @param sourceFile The source file * @param filePath The file path * @returns TranslationKey object */ export declare function processReactI18nextKey(call: ReactI18nextCall, hookNamespace: string | undefined, componentName: string, sourceFile: ts.SourceFile, filePath: string): TranslationKey; /** * Analyzes the usage context of a react-i18next translation call * @param node The call expression node * @param componentName The component name * @returns The usage context object */ export declare function analyzeReactI18nextUsageContext(node: ts.Node, componentName: string): { isInJSX: boolean; isInConditional: boolean; parentComponent: string | undefined; isInEventHandler: boolean; renderCount: number; }; /** * Gets context code for a node (line before, current line, line after) * @param node The AST node * @param sourceFile The source file * @returns Object with before, line, and after text */ export declare function getContextCode(node: ts.Node, sourceFile: ts.SourceFile): { before: string; line: string; after: string; }; /** * Creates a source file from content * @param filePath File path * @param content File content * @returns TypeScript source file */ export declare function createSourceFile(filePath: string, content: string): ts.SourceFile; /** * Determines if a file is a TypeScript/JavaScript file * @param filePath File path * @returns Boolean indicating if it's a TS/JS file */ export declare function isTypeScriptFile(filePath: string): boolean;