@regele/devtools
Version:
A collection of developer utilities for code processing and text analysis
79 lines (78 loc) • 2.3 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 detect missing JSDoc comments
*/
export declare class MissingJSDocRule extends Rule {
readonly id = "maint-missing-jsdoc";
readonly name = "Missing JSDoc";
readonly description = "Detects functions and classes without proper JSDoc comments";
readonly category = CategoryType.Maintainability;
readonly defaultSeverity = SeverityLevel.Info;
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[];
/**
* Check if a node has a JSDoc comment
*
* @param path - AST path
* @param code - Source code
* @returns True if the node has a JSDoc comment
*/
private hasJSDocComment;
/**
* Check if a function has a return value
*
* @param path - AST path
* @returns True if the function has a return value
*/
private functionHasReturnValue;
/**
* Generate a JSDoc comment for a function
*
* @param node - Function node
* @param _ - Source code (unused)
* @param functionName - Optional function name
* @returns JSDoc comment
*/
private generateFunctionJSDoc;
/**
* Generate a JSDoc comment for a class
*
* @param node - Class node
* @param _ - Source code (unused)
* @returns JSDoc comment
*/
private generateClassJSDoc;
/**
* Generate a JSDoc comment for a method
*
* @param node - Method node
* @param _ - Source code (unused)
* @returns JSDoc comment
*/
private generateMethodJSDoc;
/**
* Get the name of the class containing a method
*
* @param path - AST path
* @returns Class name or undefined
*/
private getClassName;
/**
* Get the name of the object containing a method
*
* @param path - AST path
* @returns Object name or undefined
*/
private getObjectName;
}