Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add jsdoc lint #182

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
],
extends: [
'@concepta/eslint-config/nest',
'plugin:jsdoc/recommended-typescript',
],
ignorePatterns: [
'packages/*/dist/**',
Expand All @@ -30,7 +31,8 @@ module.exports = {
rules: {
'import/no-extraneous-dependencies': 'error',
'@darraghor/nestjs-typed/param-decorator-name-matches-route-param': 'off',
'tsdoc/syntax': 'warn',
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
'tsdoc/syntax': 'error',
},
overrides: [
{
Expand All @@ -40,11 +42,21 @@ module.exports = {
jsonSyntax: 'JSON',
},
},
{
files: ['*.ts'],
rules: {
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param': 'off',
'jsdoc/require-returns': 'off',
},
},
{
files: ['*.spec.ts', '*.fixture.ts'],
rules: {
'@darraghor/nestjs-typed/controllers-should-supply-api-tags': 'off',
'@darraghor/nestjs-typed/api-method-should-specify-api-response': 'off',
'plugin:jsdoc/recommended-typescript': 'off',
'jsdoc/tag-lines': 'off',
'tsdoc/syntax': 'off',
},
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsdoc": "^48.5.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-tsdoc": "^0.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AccessControlCreateOne } from './access-control-create-one.decorator';
/**
* Create many resource grant shortcut.
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
*/
export const AccessControlCreateMany = (resource: string) =>
AccessControlCreateOne(resource);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { applyDecorators } from '@nestjs/common';
/**
* Create one resource grant shortcut.
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
* @returns Decorator function
*/
export const AccessControlCreateOne = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { applyDecorators } from '@nestjs/common';
import { ActionEnum } from '../enums/action.enum';

/**
* Delete one resource grant shortcut
* Delete one resource grant shortcut.
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
* @returns Decorator function
*/
export const AccessControlDeleteOne = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AccessControlGrant } from './access-control-grant.decorator';
/**
* Read many resource grant shortcut.
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
* @returns Decorator function
*/
export const AccessControlReadMany = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AccessControlGrant } from './access-control-grant.decorator';
/**
* Read one resource grant shortcut
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
* @returns Decorator function
*/
export const AccessControlReadOne = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AccessControlCreateOne } from './access-control-create-one.decorator';
/**
* Recover one resource grant shortcut.
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
*/
export const AccessControlRecoverOne = (resource: string) =>
AccessControlCreateOne(resource);
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AccessControlUpdateOne } from './access-control-update-one.decorator';

/**
* Update one resource grant shortcut
* Update one resource grant shortcut.
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
*/
export const AccessControlReplaceOne = (resource: string) =>
AccessControlUpdateOne(resource);
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ActionEnum } from '../enums/action.enum';
import { AccessControlGrant } from './access-control-grant.decorator';

/**
* Update one resource grant shortcut
* Update one resource grant shortcut.
*
* @param string - resource The grant resource.
* @param resource - The grant resource.
* @returns Decorator function
*/
export const AccessControlUpdateOne = (
Expand Down
4 changes: 1 addition & 3 deletions packages/nestjs-auth-local/src/auth-local.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ export class AuthLocalStrategy extends PassportStrategyFactory<Strategy>(
AUTH_LOCAL_STRATEGY_NAME,
) {
/**
*
* @param userLookupService - The service used to get the user
* @param settings - The settings for the local strategy
* @param passwordStorageService - The service used to hash and validate passwords
* @param validateUserService - The service used validate passwords
*/
constructor(
@Inject(AUTH_LOCAL_MODULE_SETTINGS_TOKEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class IssueTokenService implements IssueTokenServiceInterface {
/**
* Generate the response payload.
*
* @param identifier - user id or name for `sub` claim
* @param id - user id or name for `sub` claim
*/
async responsePayload(
id: ReferenceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export class CacheCrudController
/**
* Constructor.
*
* @param settings - cache settings
* @param allCrudServices - instances of all crud services
* @param cacheService - instance of cache service
*/
constructor(
@Inject(CACHE_MODULE_SETTINGS_TOKEN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ export class PhotoControllerFixture
{
/**
* Constructor.
*
* @param photoService instance of the photo crud service
*/
constructor(private photoService: PhotoServiceFixture) {}

/**
* Get many
*
* @param crudRequest the CRUD request object
*/
@CrudReadAll()
Expand All @@ -59,7 +57,6 @@ export class PhotoControllerFixture

/**
* Get one
*
* @param crudRequest the CRUD request object
*/
@CrudReadOne()
Expand All @@ -69,7 +66,6 @@ export class PhotoControllerFixture

/**
* Create many
*
* @param crudRequest the CRUD request object
* @param photoCreateManyDto photo create many dto
*/
Expand All @@ -83,7 +79,6 @@ export class PhotoControllerFixture

/**
* Create one
*
* @param crudRequest the CRUD request object
* @param photoCreateDto photo create dto
*/
Expand All @@ -97,7 +92,6 @@ export class PhotoControllerFixture

/**
* Update one
*
* @param crudRequest the CRUD request object
* @param photoUpdateDto photo update dto
*/
Expand All @@ -111,7 +105,6 @@ export class PhotoControllerFixture

/**
* Replace one
*
* @param crudRequest the CRUD request object
*/
@CrudReplaceOne()
Expand All @@ -124,7 +117,6 @@ export class PhotoControllerFixture

/**
* Delete one
*
* @param crudRequest the CRUD request object
*/
@CrudDeleteOne()
Expand All @@ -134,7 +126,6 @@ export class PhotoControllerFixture

/**
* Delete one (soft)
*
* @param crudRequest the CRUD request object
*/
@CrudDeleteOne({ path: 'soft/:id' })
Expand All @@ -145,7 +136,6 @@ export class PhotoControllerFixture

/**
* Recover one
*
* @param crudRequest the CRUD request object
*/
@CrudRecoverOne()
Expand Down
50 changes: 25 additions & 25 deletions packages/nestjs-event/src/services/event-dispatch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ export class EventDispatchService {
*
* @Injectable()
* class MyClass {
* constructor(private eventDispatchService: EventDispatchService) {}
* constructor(private eventDispatchService: EventDispatchService) {}
*
* didSomething() {
* // event instance
* const myEvent = new MyEvent({id: 1234});
* // dispatch the event
* this.eventDispatchService.sync(myEvent);
* }
* didSomething() {
* // event instance
* const myEvent = new MyEvent({id: 1234});
* // dispatch the event
* this.eventDispatchService.sync(myEvent);
* }
* }
* ```
*
Expand Down Expand Up @@ -82,25 +82,25 @@ export class EventDispatchService {
*
* @Injectable()
* class MyClass {
* constructor(private eventDispatchService: EventDispatchService) {}
* constructor(private eventDispatchService: EventDispatchService) {}
*
* // allow any listener to activate object
* async maybeActivate(myPayloadType: MyPayloadType): MyPayloadType {
* // event instance
* const myEvent = new MyEvent({...myPayloadType, active: false});
* // dispatch the event
* const allPayloads: MyPayloadType[] =
* await this.eventDispatchService.async(myEvent);
* // merge it
* allPayloads.forEach((payload) => {
* // did any listener set it to true?
* if (payload.active) {
* myPayloadType.active = true;
* }
* });
* // return possibly modified object
* return myPayloadType;
* }
* // allow any listener to activate object
* async maybeActivate(myPayloadType: MyPayloadType): MyPayloadType {
* // event instance
* const myEvent = new MyEvent({...myPayloadType, active: false});
* // dispatch the event
* const allPayloads: MyPayloadType[] =
* await this.eventDispatchService.async(myEvent);
* // merge it
* allPayloads.forEach((payload) => {
* // did any listener set it to true?
* if (payload.active) {
* myPayloadType.active = true;
* }
* });
* // return possibly modified object
* return myPayloadType;
* }
* }
* ```
*
Expand Down
20 changes: 10 additions & 10 deletions packages/nestjs-event/src/services/event-listen.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ export class EventListenService {
* import { TargetEvent } from 'target-module';
*
* class MyListener extends EventListenerOn<TargetEvent> {
* listen(event: TargetEvent) {
* console.log(event.payload);
* }
* listen(event: TargetEvent) {
* console.log(event.payload);
* }
* }
*
* @Injectable()
* class MyClass implements OnModuleInit {
* constructor(private eventListenService: EventListenService) {}
* constructor(private eventListenService: EventListenService) {}
*
* onModuleInit() {
* // listener instance
* const listener = new MyListener();
* // register the listener
* this.eventListenService.on(TargetEvent, listener);
* }
* onModuleInit() {
* // listener instance
* const listener = new MyListener();
* // register the listener
* this.eventListenService.on(TargetEvent, listener);
* }
* }
* ```
*
Expand Down
1 change: 0 additions & 1 deletion packages/nestjs-logger/src/logger-request.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export class LoggerRequestInterceptor implements NestInterceptor<Response> {
* @param res - Response
* @param startDate - Start date
* @param error - Error instance
* @returns
*/
responseError(req: Request, res: Response, startDate: Date, error: Error) {
// format the message
Expand Down
2 changes: 0 additions & 2 deletions packages/nestjs-logger/src/utils/message-format.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class MessageFormatUtil {
* Function to format message from request.
*
* @param req - request
* @returns
*/
static formatRequestMessage(req: Request): string {
const { method, url } = req;
Expand All @@ -29,7 +28,6 @@ export class MessageFormatUtil {
* @param res - response
* @param startDate - start date
* @param error - error
* @returns
*/
static formatResponseMessage(
req: Request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export class PasswordCreationService
/**
* Check if number of current attempt is allowed based on the amount of attempts left
* if the number of attempts left is greater then
*
* @returns Number of attempts user has to try
*/
checkAttempt(numOfAttempts = 0): boolean {
Expand All @@ -121,8 +122,8 @@ export class PasswordCreationService

/**
* Check number of attempts of using password
*
* @param numOfAttempts - number of attempts
* @returns
*/
checkAttemptLeft(numOfAttempts = 0): number {
// Get number of max attempts allowed
Expand Down
Loading
Loading