Skip to content

Commit

Permalink
chore: upgrade eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jan 17, 2025
1 parent fb346b4 commit 8935a17
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 1,467 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: npm ci --ignore-scripts
command: npm install --ignore-scripts
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
Expand Down
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

27 changes: 0 additions & 27 deletions .eslintrc.js

This file was deleted.

43 changes: 43 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: ['tests/**'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'warn',
},
},
);
4 changes: 2 additions & 2 deletions lib/decorators/cron.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export type CronOptions = {
* @default false
*/
disabled?: boolean;
} & // make timeZone & utcOffset mutually exclusive
(| {
} & ( // make timeZone & utcOffset mutually exclusive
| {
timeZone?: string;
utcOffset?: never;
}
Expand Down
7 changes: 4 additions & 3 deletions lib/decorators/interval.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ export function Interval(
nameOrTimeout: string | number,
timeout?: number,
): MethodDecorator {
const [name, intervalTimeout] = (typeof nameOrTimeout === "string")
? [nameOrTimeout, timeout]
: [undefined, nameOrTimeout];
const [name, intervalTimeout] =
typeof nameOrTimeout === 'string'
? [nameOrTimeout, timeout]
: [undefined, nameOrTimeout];

return applyDecorators(
SetMetadata(SCHEDULE_INTERVAL_OPTIONS, { timeout: intervalTimeout }),
Expand Down
7 changes: 4 additions & 3 deletions lib/decorators/timeout.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ export function Timeout(
nameOrTimeout: string | number,
timeout?: number,
): MethodDecorator {
const [name, timeoutValue] = typeof nameOrTimeout === 'string'
? [nameOrTimeout, timeout]
: [undefined, nameOrTimeout];
const [name, timeoutValue] =
typeof nameOrTimeout === 'string'
? [nameOrTimeout, timeout]
: [undefined, nameOrTimeout];

return applyDecorators(
SetMetadata(SCHEDULE_TIMEOUT_OPTIONS, { timeout: timeoutValue }),
Expand Down
17 changes: 9 additions & 8 deletions lib/scheduler.orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type CronJobOptions = TargetHost & CronOptionsHost & RefHost<CronJob>;

@Injectable()
export class SchedulerOrchestrator
implements OnApplicationBootstrap, OnApplicationShutdown {
implements OnApplicationBootstrap, OnApplicationShutdown
{
private readonly cronJobs: Record<string, CronJobOptions> = {};
private readonly timeouts: Record<string, TimeoutOptions> = {};
private readonly intervals: Record<string, IntervalOptions> = {};
Expand Down Expand Up @@ -70,7 +71,7 @@ export class SchedulerOrchestrator
const cronJob = CronJob.from({
...options,
onTick: target as CronCallback<null, false>,
start: !options.disabled
start: !options.disabled,
});

this.cronJobs[key].ref = cronJob;
Expand All @@ -79,15 +80,15 @@ export class SchedulerOrchestrator
}

clearTimeouts() {
this.schedulerRegistry.getTimeouts().forEach((key) =>
this.schedulerRegistry.deleteTimeout(key),
);
this.schedulerRegistry
.getTimeouts()
.forEach((key) => this.schedulerRegistry.deleteTimeout(key));
}

clearIntervals() {
this.schedulerRegistry.getIntervals().forEach((key) =>
this.schedulerRegistry.deleteInterval(key),
);
this.schedulerRegistry
.getIntervals()
.forEach((key) => this.schedulerRegistry.deleteInterval(key));
}

closeCronJobs() {
Expand Down
5 changes: 4 additions & 1 deletion lib/scheduler.registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ export class SchedulerRegistry {
this.timeouts.delete(name);
}

private wrapFunctionInTryCatchBlocks(methodRef: Function, instance: object): (...args: unknown[]) => Promise<void> {
private wrapFunctionInTryCatchBlocks(
methodRef: Function,
instance: object,
): (...args: unknown[]) => Promise<void> {
return async (...args: unknown[]) => {
try {
await methodRef.call(instance, ...args);
Expand Down
Loading

0 comments on commit 8935a17

Please sign in to comment.