refactor(backend): fix nestjs-typed linting errors

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2023-06-25 19:35:38 +02:00 committed by Tilman Vatteroth
parent 8daffbb11b
commit a5d8c9cc33
16 changed files with 60 additions and 20 deletions

View file

@ -29,9 +29,10 @@ export class NoteMetadataDto extends BaseDto {
/**
* All aliases of the note (including the primaryAlias)
*/
@Type(() => AliasDto)
@IsArray()
@ValidateNested()
@ApiProperty()
@ValidateNested({ each: true })
@ApiProperty({ isArray: true, type: AliasDto })
aliases: AliasDto[];
/**
@ -67,7 +68,7 @@ export class NoteMetadataDto extends BaseDto {
*/
@IsArray()
@IsString({ each: true })
@ApiProperty()
@ApiProperty({ isArray: true, type: String })
tags: string[];
@IsNumber()
@ -86,8 +87,9 @@ export class NoteMetadataDto extends BaseDto {
/**
* User that last edited the note
*/
@IsString()
// eslint-disable-next-line @darraghor/nestjs-typed/api-property-matches-property-optionality
@ApiPropertyOptional()
@IsString()
@IsOptional()
updateUsername: string | null;
@ -114,13 +116,13 @@ export class NoteMetadataDto extends BaseDto {
*/
@IsArray()
@IsString({ each: true })
@ApiProperty()
@ApiProperty({ isArray: true, type: String })
editedBy: string[];
/**
* Permissions currently in effect for the note
*/
@ValidateNested({ each: true })
@ValidateNested()
@Type(() => NotePermissionsDto)
@ApiProperty({ type: NotePermissionsDto })
permissions: NotePermissionsDto;
@ -151,6 +153,6 @@ export class NoteMetadataUpdateDto {
*/
@IsArray()
@IsString({ each: true })
@ApiProperty()
@ApiProperty({ isArray: true, type: String })
tags: string[];
}

View file

@ -21,6 +21,7 @@ export class NoteUserPermissionEntryDto extends BaseDto {
/**
* Username of the User this permission applies to
*/
@Type(() => String)
@IsString()
@IsLowercase()
@ApiProperty()
@ -40,6 +41,7 @@ export class NoteUserPermissionUpdateDto {
* Username of the user this permission should apply to
* @example "john.smith"
*/
@Type(() => String)
@IsString()
@IsLowercase()
@ApiProperty()
@ -93,6 +95,9 @@ export class NotePermissionsDto {
/**
* Username of the User this permission applies to
*/
// nestjs-typed does not detect '| null' types as optional
// eslint-disable-next-line @darraghor/nestjs-typed/api-property-matches-property-optionality
@Type(() => String)
@IsString()
@ApiPropertyOptional()
@IsOptional()

View file

@ -23,6 +23,7 @@ export class NoteDto extends BaseDto {
/**
* Metadata of the note
*/
@Type(() => NoteMetadataDto)
@ValidateNested()
@ApiProperty({ type: NoteMetadataDto })
metadata: NoteMetadataDto;