From 9276f828a8eefe21e8cc2c2258a35b16ca6f070d Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 15 Jul 2023 22:14:50 +0200 Subject: [PATCH] style: lint files --- src/abstract_connection.ts | 9 ++++++--- src/define_config.ts | 4 ++-- src/redis_cluster_connection.ts | 2 +- src/redis_connection.ts | 2 +- src/redis_manager.ts | 20 ++++++++++---------- src/repl_bindings.ts | 6 +++--- src/types/main.ts | 10 +++++----- test/define_config.spec.ts | 4 ++-- test/redis_cluster_connection.spec.ts | 20 ++++++++++---------- test/redis_connection.spec.ts | 16 ++++++++-------- 10 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/abstract_connection.ts b/src/abstract_connection.ts index 9b7e227..695cf26 100644 --- a/src/abstract_connection.ts +++ b/src/abstract_connection.ts @@ -87,7 +87,10 @@ export abstract class AbstractConnection extends Even */ protected abstract makeSubscriberConnection(): void - constructor(public connectionName: string, application: ApplicationService) { + constructor( + public connectionName: string, + application: ApplicationService + ) { super() } @@ -177,11 +180,11 @@ export abstract class AbstractConnection extends Even this.ioSubscriberConnection!.on('connect', () => this.emit('subscriber:connect', this)) this.ioSubscriberConnection!.on('ready', () => this.emit('subscriber:ready', this)) this.ioSubscriberConnection!.on('error', (error: any) => - this.emit('subscriber:error', error, this), + this.emit('subscriber:error', error, this) ) this.ioSubscriberConnection!.on('close', () => this.emit('subscriber:close', this)) this.ioSubscriberConnection!.on('reconnecting', () => - this.emit('subscriber:reconnecting', this), + this.emit('subscriber:reconnecting', this) ) /** diff --git a/src/define_config.ts b/src/define_config.ts index 5ccc094..84bf469 100644 --- a/src/define_config.ts +++ b/src/define_config.ts @@ -24,7 +24,7 @@ type RedisConfig = { * Define config for redis */ export function defineConfig( - config: T, + config: T ): T { if (!config) { throw new InvalidArgumentsException('Invalid config. It must be a valid object') @@ -36,7 +36,7 @@ export function defineConfig { protected makeSubscriberConnection() { this.ioSubscriberConnection = new Redis.Cluster( this.#config.clusters as [], - this.#config.clusterOptions, + this.#config.clusterOptions ) } diff --git a/src/redis_connection.ts b/src/redis_connection.ts index 317609e..929ad98 100644 --- a/src/redis_connection.ts +++ b/src/redis_connection.ts @@ -26,7 +26,7 @@ export class RawRedisConnection extends AbstractConnection { constructor( connectionName: string, config: RedisConnectionConfig, - application: ApplicationService, + application: ApplicationService ) { super(connectionName, application) this.#config = this.#normalizeConfig(config) diff --git a/src/redis_manager.ts b/src/redis_manager.ts index 1166c9a..c3b0b95 100644 --- a/src/redis_manager.ts +++ b/src/redis_manager.ts @@ -65,13 +65,13 @@ export class RawRedisManager { connection: keyof ConnectionList connections: ConnectionList }, - emitter: EmitterService, + emitter: EmitterService ) { this.#app = app this.#config = config this.#emitter = emitter this.#healthCheckConnections = Object.keys(this.#config.connections).filter( - (connection) => this.#config.connections[connection].healthCheck, + (connection) => this.#config.connections[connection].healthCheck ) } @@ -107,22 +107,22 @@ export class RawRedisManager { this.#emitter.emit('redis:ready', { connection }) }) connection.on('ready', ($connection) => - this.#emitter.emit('redis:ready', { connection: $connection }), + this.#emitter.emit('redis:ready', { connection: $connection }) ) connection.on('connect', ($connection) => - this.#emitter.emit('redis:connect', { connection: $connection }), + this.#emitter.emit('redis:connect', { connection: $connection }) ) connection.on('error', (error, $connection) => - this.#emitter.emit('redis:error', { error, connection: $connection }), + this.#emitter.emit('redis:error', { error, connection: $connection }) ) connection.on('node:added', ($connection, node) => - this.#emitter.emit('redis:node:added', { node, connection: $connection }), + this.#emitter.emit('redis:node:added', { node, connection: $connection }) ) connection.on('node:removed', (node, $connection) => - this.#emitter.emit('redis:node:removed', { node, connection: $connection }), + this.#emitter.emit('redis:node:removed', { node, connection: $connection }) ) connection.on('node:error', (error, address, $connection) => - this.#emitter.emit('redis:node:error', { error, address, connection: $connection }), + this.#emitter.emit('redis:node:error', { error, address, connection: $connection }) ) /** @@ -138,7 +138,7 @@ export class RawRedisManager { * Returns redis factory for a given named connection */ connection( - connectionName?: ConnectionName, + connectionName?: ConnectionName ): GetConnectionType { const name = connectionName || this.#getDefaultConnection() @@ -223,7 +223,7 @@ export class RawRedisManager { */ async report() { const reports = await Promise.all( - this.#healthCheckConnections.map((connection) => this.connection(connection).getReport(true)), + this.#healthCheckConnections.map((connection) => this.connection(connection).getReport(true)) ) const healthy = !reports.find((report) => !!report.error) diff --git a/src/repl_bindings.ts b/src/repl_bindings.ts index 522ff36..7aadd15 100644 --- a/src/repl_bindings.ts +++ b/src/repl_bindings.ts @@ -21,10 +21,10 @@ export function defineReplBindings(app: ApplicationService, repl: Repl) { repl.server!.context.redis = await app.container.make('redis') repl.notify( `Loaded "redis" service. You can access it using the "${repl.colors.underline( - 'redis', - )}" variable`, + 'redis' + )}" variable` ) }, - { description: 'Load "redis" service in the REPL context' }, + { description: 'Load "redis" service in the REPL context' } ) } diff --git a/src/types/main.ts b/src/types/main.ts index aeb67c8..968f2c3 100644 --- a/src/types/main.ts +++ b/src/types/main.ts @@ -35,7 +35,7 @@ import { RawRedisManager } from '../redis_manager.js' export type PubSubChannelHandler = (data: T) => Promise | void export type PubSubPatternHandler = ( channel: string, - data: T, + data: T ) => Promise | void /** @@ -45,7 +45,7 @@ export interface RedisPubSubContract { publish( channel: string, message: string, - callback: (error: Error | null, count: number) => void, + callback: (error: Error | null, count: number) => void ): void publish(channel: string, message: string): Promise subscribe(channel: string, handler: PubSubChannelHandler | string): void @@ -121,7 +121,7 @@ export type RedisClusterConnectionFactory = { new ( connectionName: string, config: RedisClusterConfig, - application: ApplicationService, + application: ApplicationService ): RawRedisClusterConnection & AbstractConnection & IORedisCommands & RedisPubSubContract } @@ -129,7 +129,7 @@ export type RedisConnectionFactory = { new ( connectionName: string, config: RedisConnectionConfig, - application: ApplicationService, + application: ApplicationService ): RawRedisConnection & AbstractConnection & IORedisCommands & RedisPubSubContract } @@ -140,7 +140,7 @@ export type RedisManagerFactory = { connection: keyof ConnectionList connections: ConnectionList }, - emitter: Emitter, + emitter: Emitter ): RawRedisManager & IORedisCommands & RedisPubSubContract } diff --git a/test/define_config.spec.ts b/test/define_config.spec.ts index 18d681d..f3f75d9 100644 --- a/test/define_config.spec.ts +++ b/test/define_config.spec.ts @@ -20,7 +20,7 @@ test.group('Define Config', () => { assert.throws( // @ts-ignore () => defineConfig({ connection: 'hey' }), - 'Invalid config. Missing property "connections" inside it', + 'Invalid config. Missing property "connections" inside it' ) }) @@ -32,7 +32,7 @@ test.group('Define Config', () => { connection: 'hey', connections: {}, }), - 'Invalid config. Missing property "connection" or the connection name is not defined inside "connections" object', + 'Invalid config. Missing property "connection" or the connection name is not defined inside "connections" object' ) }) }) diff --git a/test/redis_cluster_connection.spec.ts b/test/redis_cluster_connection.spec.ts index 9c2c6d5..c0da4bf 100644 --- a/test/redis_cluster_connection.spec.ts +++ b/test/redis_cluster_connection.spec.ts @@ -21,7 +21,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: nodes }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('ready', async () => { @@ -35,7 +35,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: [{ host: process.env.REDIS_HOST!!, port: 7000 }] }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('node:added', async () => { @@ -49,7 +49,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: nodes }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) await factory.set('greeting', 'hello world') @@ -66,7 +66,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: nodes }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -88,7 +88,7 @@ test.group('Redis cluster factory', () => { { clusters: nodes, }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -108,7 +108,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: [{ host: process.env.REDIS_HOST!, port: 5000 }] }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -133,7 +133,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: nodes }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -154,7 +154,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: nodes }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -180,7 +180,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: [{ host: process.env.REDIS_HOST!, port: 5000 }] }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -203,7 +203,7 @@ test.group('Redis cluster factory', () => { const factory = new RedisClusterConnection( 'main', { clusters: nodes }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.defineCommand('defineValue', { diff --git a/test/redis_connection.spec.ts b/test/redis_connection.spec.ts index 77e6283..5f72bdb 100644 --- a/test/redis_connection.spec.ts +++ b/test/redis_connection.spec.ts @@ -11,7 +11,7 @@ test.group('Redis factory', () => { host: process.env.REDIS_HOST, port: Number(process.env.REDIS_PORT), }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('ready', async () => { @@ -28,7 +28,7 @@ test.group('Redis factory', () => { host: process.env.REDIS_HOST, port: Number(process.env.REDIS_PORT), }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) await factory.set('greeting', 'hello world') @@ -47,7 +47,7 @@ test.group('Redis factory', () => { host: process.env.REDIS_HOST, port: Number(process.env.REDIS_PORT), }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -68,7 +68,7 @@ test.group('Redis factory', () => { host: process.env.REDIS_HOST, port: Number(process.env.REDIS_PORT), }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -86,7 +86,7 @@ test.group('Redis factory', () => { const factory = new RedisConnection( 'main', { port: 4444 }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -111,7 +111,7 @@ test.group('Redis factory', () => { host: process.env.REDIS_HOST, port: Number(process.env.REDIS_PORT), }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -140,7 +140,7 @@ test.group('Redis factory', () => { host: process.env.REDIS_HOST, port: 4444, }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.on('end', () => { @@ -167,7 +167,7 @@ test.group('Redis factory', () => { host: process.env.REDIS_HOST, port: Number(process.env.REDIS_PORT), }, - new AppFactory().create(BASE_URL, () => {}), + new AppFactory().create(BASE_URL, () => {}) ) factory.defineCommand('defineValue', {