Skip to content

Commit

Permalink
MOMO-14: Added explicit return type to eslint
Browse files Browse the repository at this point in the history
Signed-off-by: Yani Kolev <[email protected]>
  • Loading branch information
YaniKolev committed Aug 27, 2021
1 parent 3f2b97a commit 11e4ff9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ module.exports = {
lib: 'always',
},
],
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
allowDirectConstAssertionInArrowFunctions: false,
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
},
],
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unified-signatures': 'error',
'arrow-parens': ['error', 'always'],
Expand Down
4 changes: 2 additions & 2 deletions src/logging/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface Logger {
error: (message: string, type: MomoErrorType, data?: MomoEventData, error?: Error) => void;
}

export function debug(this: TypedEmitter<MomoEvents>, message: string, data?: MomoEventData) {
export function debug(this: TypedEmitter<MomoEvents>, message: string, data?: MomoEventData): void {
this.emit('debug', { message, data });
}

Expand All @@ -18,6 +18,6 @@ export function error(
type: MomoErrorType,
data?: MomoEventData,
error?: Error
) {
): void {
this.emit('error', { message, type, data, error });
}
2 changes: 1 addition & 1 deletion src/repository/ExecutionsRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ExecutionsRepository extends MongoRepository<ExecutionsEntity> {
await this.save(new ExecutionsEntity(scheduleId, DateTime.now().toMillis(), {}));
}

async removeJob(scheduleId: string, name: string) {
async removeJob(scheduleId: string, name: string): Promise<void> {
const executionsEntity = await this.findOne({ scheduleId });
if (executionsEntity === undefined) {
throw new Error(`executionsEntity not found for scheduleId=${scheduleId}`);
Expand Down
5 changes: 4 additions & 1 deletion src/repository/JobRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export class JobRepository extends MongoRepository<JobEntity> {
}
}

function merge(savedJob: JobEntity, { interval, concurrency, maxRunning, executionInfo }: Partial<JobEntity>) {
function merge(
savedJob: JobEntity,
{ interval, concurrency, maxRunning, executionInfo }: Partial<JobEntity>
): JobEntity {
if (interval !== undefined) {
savedJob.interval = interval;
}
Expand Down
2 changes: 1 addition & 1 deletion test/job/findLatest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Job } from '../../src/job/Job';
import { JobEntity } from '../../src/repository/JobEntity';
import { findLatest } from '../../src/job/findLatest';

function createJob(lastFinished?: number) {
function createJob(lastFinished?: number): JobEntity {
const job = JobEntity.from({ name: 'test' } as Job);
if (lastFinished !== undefined) {
job.executionInfo = { lastFinished: DateTime.fromMillis(lastFinished).toISO() } as ExecutionInfo;
Expand Down
2 changes: 1 addition & 1 deletion test/utils/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MomoEventData, MomoEvents } from '../../src/logging/MomoEvents';
const logger = Pino();
const errorLogger = Pino({ level: 'error' });

export function initLoggingForTests(eventEmitter: TypedEmitter<MomoEvents>) {
export function initLoggingForTests(eventEmitter: TypedEmitter<MomoEvents>): void {
eventEmitter.on('debug', (event) => {
logger.info(event);
});
Expand Down

0 comments on commit 11e4ff9

Please sign in to comment.