frontend-standards-checker
Version:
A comprehensive frontend standards validation tool with TypeScript support
118 lines • 4.51 kB
TypeScript
import type { IFileScanner, ILogger, IFileInfo, IScanOptions, IGitIgnorePattern, IFileScanResult } from '../types/index.js';
/**
* Scans files and directories within a project, respecting ignore patterns and .gitignore rules.
* Provides methods for scanning zones, directories, and retrieving file statistics.
* Supports detection of staged files, changed files in CI/CD pipelines, and React Native project detection.
*
* @remarks
* - Ignores files and directories based on default patterns and .gitignore.
* - Supports recursive scanning and filtering by file extensions.
* - Integrates with git to detect staged and changed files for commit or CI/CD pipelines.
* - Can determine project zones and detect React Native projects.
*
* @example
* ```typescript
* const scanner = new FileScanner('/project/root', logger);
* const files = await scanner.scanZone('apps/web', { extensions: ['.ts', '.tsx'], ignorePatterns: [] });
* ```
*
* @see IFileScanner
* @see ILogger
* @see IFileInfo
* @see IScanOptions
* @see IGitIgnorePattern
* @see IFileScanResult
*/
export declare class FileScanner implements IFileScanner {
readonly rootDir: string;
readonly logger: ILogger;
readonly gitignorePatterns: IGitIgnorePattern[];
private readonly defaultIgnorePatterns;
constructor(rootDir: string, logger: ILogger);
/**
* Scan a specific zone for files
* @param zone Zone to scan
* @param options Scan options
* @returns Array of file information
*/
scanZone(zone: string, options: IScanOptions): Promise<IFileInfo[]>;
/**
* Scan directory recursively for files
* @param dirPath Directory path to scan
* @param options Scan options
* @returns Array of file information
*/
scanDirectory(dirPath: string, options: IScanOptions): Promise<IFileInfo[]>;
/**
* Load gitignore patterns from .gitignore file
* @returns Array of gitignore patterns
*/
loadGitignorePatterns(): Promise<IGitIgnorePattern[]>;
/**
* Check if a file path should be ignored based on patterns
* @param filePath File path to check
* @param patterns Array of gitignore patterns
* @returns True if file should be ignored
*/
isIgnored(filePath: string, patterns: IGitIgnorePattern[]): boolean;
/**
* Check if path matches a simple pattern
* @param filePath File path to check
* @param pattern Pattern to match
* @returns True if matches
*/
private matchesPattern;
/**
* Check if path matches a gitignore pattern
* @param filePath File path to check
* @param pattern Gitignore pattern
* @param isDirectory Whether pattern is for directories only
* @returns True if matches
*/
private matchesGitignorePattern;
/**
* Determine which zone a file belongs to
* @param filePath File path
* @param options Scan options
* @returns Zone name
*/
private determineZone;
/**
* Get file statistics
* @param options Scan options
* @returns File scan statistics
*/
getStatistics(options: IScanOptions): Promise<IFileScanResult>;
/**
* Get files that are staged for commit
* @returns Array of file paths that are staged for commit
*/
getFilesInCommit(): Promise<string[]>;
/**
* Get files that are changed in recent commits (for CI/CD pipelines)
* This method uses multiple git strategies to find changed files in pipeline environments
* @returns Array of file paths that are changed in recent commits
*/
getChangedFilesInPipeline(): Promise<string[]>;
/**
* Get combined files: staged files first, then pipeline changed files as fallback
* @param forcePipelineMode Force using pipeline mode regardless of environment
* @returns Array of file paths that are staged for commit or recently changed
*/
getFilesInCommitOrPipeline(forcePipelineMode?: boolean): Promise<string[]>;
/**
* Get git strategies specifically for pipeline environments
* @returns Array of git strategies to try in pipeline/CI environments
*/
private getGitStrategiesForPipeline;
/**
* Check if running in a CI/CD environment
* @returns True if running in CI/CD environment
*/
private isRunningInCI;
}
/**
* Detect if the current project is a React Native project
*/
export declare function isReactNativeProject(filePath: string): boolean;
//# sourceMappingURL=file-scanner.d.ts.map