darraghoriordan / eslint-plugin-nestjs-typed

Some eslint rules for working with NestJs projects
http://www.darraghoriordan.com
171 stars 34 forks source link

api-property-matches-property-optionality gets confused when property has default provided #156

Open karlismelderis-mckinsey opened 7 months ago

karlismelderis-mckinsey commented 7 months ago

This is bit of a grey area but still would be nice if we wouldn't need to disable @darraghor/nestjs-typed/api-property-matches-property-optionality for every such property

  @IsOptional()
  @IsString()
  @Expose()
  @ApiPropertyOptional({
    type: String,
    default: 'example',
  })
  label: string  = 'example';

@ApiPropertyOptional tells that users don't need to provide this data in body and it will be filled in with default

Can we add an option for the rule to accept @IsOptional if default is provided in @ApiPropertyOptional and property is required

darraghoriordan commented 6 months ago

Yes, if you submit a PR for this it would be awesome. Thank you!