| name | typescript-jsdoc-standards |
| description | Enforces TypeScript/React code comment standards and JSDoc formatting requirements. Use when writing TypeScript or React code, adding comments, documenting functions, or when code review requires proper JSDoc comments. |
TypeScript/React Code Comment and JSDoc Standards
Comment Language
All code comments must be in English. Do not use Chinese or other languages for comments.
Comment Format
- Use
/** */ format for comments (JSDoc style)
- Comments should be placed above the code being commented
- Use single-line format for single-line comments, multi-line format for multi-line comments
Function Comment Requirements
All exported functions must include complete JSDoc comments with:
- Function description
@param parameter descriptions (every parameter must be described)
@returns return value description
Correct Example:
export function calculateTotalWithTax(price: number, taxRate: number, quantity: number = 1): number {
const subtotal = price * quantity
return subtotal * (1 + taxRate)
}
Incorrect Examples:
export function calculateTotal(price: number, quantity: number): number {
return price * quantity
}
export function calculateArea(width: number, height: number): number {
return width * height
}
export function processUserData(data: any) {}
Variable and Property Comments
- Complex or non-self-explanatory variables and properties should be commented
- Constants must be commented to explain their purpose
- Simple, self-explanatory variables may not need comments
Correct Examples:
const MAX_RETRY_ATTEMPTS = 3
let authToken: string | null = null
Class and Interface Comments
- All exported classes and interfaces must include descriptive comments
- Public methods of classes should be commented
- Properties of interfaces should be commented
Correct Examples:
export class UserService {
async authenticate(email: string, password: string): Promise<string> {
}
}
export interface UserProfile {
id: string
email: string
}
Common Mistakes to Avoid
- ❌ Do not use Chinese comments: All comments must be in English
- ❌ Do not omit JSDoc comments: All exported functions must have complete JSDoc comments
- ❌ Do not use incomplete JSDoc: Every
@param and @returns must have descriptions