@regele/devtools
Version:
A collection of developer utilities for code processing and text analysis
69 lines (68 loc) • 2.22 kB
TypeScript
import * as parser from '@babel/parser';
import * as t from '@babel/types';
import { Rule } from '../rule';
import { CategoryType, CodeFinding, SeverityLevel } from '../../types';
/**
* Rule to enforce consistent semicolon usage
*/
export declare class SemicolonRule extends Rule {
readonly id = "style-semicolon";
readonly name = "Semicolon Usage";
readonly description = "Enforces consistent semicolon usage";
readonly category = CategoryType.Style;
readonly defaultSeverity = SeverityLevel.Info;
readonly requiresAST = false;
/**
* Apply the rule to the given code
*
* @param code - Source code
* @param ast - Parsed AST
* @param filePath - Path to the file
* @returns Array of findings
*/
apply(code: string, _ast: parser.ParseResult<t.File>, filePath: string): CodeFinding[];
/**
* Apply the rule without AST parsing
*
* @param code - Source code
* @param filePath - Path to the file
* @returns Array of findings
*/
applyWithoutAST(code: string, filePath: string): CodeFinding[];
/**
* Detect the semicolon style used in the file
*
* @param code - Source code
* @returns Semicolon style ('always', 'never', or 'unknown')
*/
private detectSemicolonStyle;
/**
* Check if a line should be skipped for semicolon checking
*
* @param line - Line to check
* @returns True if the line should be skipped
*/
private shouldSkipLine;
/**
* Check if a line is definitely exempt from semicolon rules
*
* @param line - Line to check
* @returns True if the line is definitely exempt
*/
private isDefinitelyExemptFromSemicolonRule;
/**
* Check if a line might be exempt from semicolon rules
*
* @param line - Line to check
* @returns True if the line might be exempt
*/
private isExemptFromSemicolonRule;
/**
* Generate a suggestion for fixing inconsistent semicolon usage
*
* @param line - Original line
* @param style - Target semicolon style
* @returns Suggested line
*/
protected generateSuggestion(line: string, style?: 'always' | 'never'): string;
}