UNPKG

@regele/devtools

Version:

A collection of developer utilities for code processing and text analysis

33 lines (32 loc) 1.19 kB
import * as parser from '@babel/parser'; import * as t from '@babel/types'; import { Rule } from '../rule'; import { CategoryType, CodeFinding, SeverityLevel } from '../../types'; /** * Rule to detect inconsistent return types */ export declare class InconsistentReturnRule extends Rule { readonly id = "bugs-inconsistent-return"; readonly name = "Inconsistent Return"; readonly description = "Detects functions with inconsistent return types or missing returns"; readonly category = CategoryType.Bugs; readonly defaultSeverity = SeverityLevel.Warning; readonly requiresAST = true; /** * 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[]; /** * Generate a suggestion for fixing inconsistent returns * * @param code - Original code * @param returnInfo - Return analysis information * @returns Suggested code */ protected generateSuggestion(_code: string, _returnInfo?: any): string; }