eslint-plugin-venuex-require-decorator
v0.0.1
Published
This is a custom plugin for eslint which enforces the use of decorators on NestJS methods.
Downloads
27
Maintainers
Readme
venuex-eslint-plugin-require-decorator
Installation
$ npm install --save-dev eslint-plugin-venuex-require-decorator
or
$ yarn add -D eslint-plugin-venuex-require-decorator
Usage
// .eslintrc
{
"plugins": ["require-decorator"],
"rules": {
"venuex-require-decorator/require-decorator": [
1,
{
"classDecorators": ["Controller"],
"methodDecorators": [
"ApiOperation",
"ApiResponse",
{
"oneOfThem": ["Get", "Post", "Put", "Delete", "Patch", "Options", "Head", "All"]
}
]
},
{
// You can define multiple options
"classDecorators": ["Service"],
"methodDecorators": ["ServiceDecorator"]
}
]
}
}
// any.controller.ts
@Controller("users")
class UserController {
test!: number;
constructor(test: number) {
this.test = test;
}
@ApiOperation()
@Get()
// Missing decorators; ApiResponse
private getUserById(userId: number): void {
return;
}
@ApiOperation()
@ApiResponse()
// Require one of them; Get || Post || Put || Delete || Patch || Options || Head || All
deleteUserById(userId: number): void {
return;
}
@Put()
// Missing decorators; ApiOperation, ApiResponse
async updateUserById(userId: number): void {
return;
}
}
Features
| | Completed | | ------------------------------ | :-------: | | One of them | ✔️ | | Validate fields | ❌ | | Validate async | ❌ | | Validate access modifiers | ❌ | | Fix (push required decorators) | ✔️ |