@qlover/eslint-plugin
v1.1.0
Published
ESLint plugin for qlover's TypeScript projects
Maintainers
Readme
@qlover/eslint-plugin
ESLint plugin for qlover's TypeScript projects.
👉 中文文档 | English Docs
Installation
npm install --save-dev @qlover/eslint-pluginUsage
Add @qlover to the plugins section of your .eslintrc configuration file:
{
"plugins": ["@qlover"]
}Then configure the rules you want to use:
{
"rules": {
"@qlover-eslint/ts-class-method-return": ["error", {
"allowConstructors": true,
"allowPrivateMethods": false
}]
}
}Or use the recommended configuration:
{
"extends": ["plugin:@qlover-eslint/recommended"]
}Rules
ts-class-method-return
Enforces return type annotations for class methods to improve code readability and type safety.
Options
allowConstructors(default:true) - When true, constructors are allowed to omit return type annotationsallowPrivateMethods(default:false) - When true, private methods (prefixed with #) are allowed to omit return type annotations
Example of incorrect code:
class Example {
method() { // Missing return type
return true;
}
#privateMethod() { // Missing return type (not allowed by default)
return 'private';
}
}Example of correct code:
class Example {
constructor() { // Constructor return type is optional by default
// initialization
}
method(): boolean {
return true;
}
#privateMethod(): string {
return 'private';
}
}For more detailed information about each rule, please check the rule documentation.
