From 2604892caa67b7b183951b7ae153027ac2a067e2 Mon Sep 17 00:00:00 2001 From: Matt Straathof <11823378+bruuuuuuuce@users.noreply.github.com> Date: Fri, 10 Nov 2023 11:31:41 -0800 Subject: [PATCH] chore: code cleanup, standardize logging (#1027) --- .../src/internal/cache-control-client.ts | 56 ++++++++++--------- packages/client-sdk-web/.eslintrc.json | 13 ++++- .../src/internal/cache-control-client.ts | 11 ++-- .../common-integration-tests/.eslintrc.json | 13 ++++- packages/core/.eslintrc.json | 13 ++++- 5 files changed, 66 insertions(+), 40 deletions(-) diff --git a/packages/client-sdk-nodejs/src/internal/cache-control-client.ts b/packages/client-sdk-nodejs/src/internal/cache-control-client.ts index 751e5efb2..bda4eb123 100644 --- a/packages/client-sdk-nodejs/src/internal/cache-control-client.ts +++ b/packages/client-sdk-nodejs/src/internal/cache-control-client.ts @@ -78,27 +78,28 @@ export class CacheControlClient { } catch (err) { return new CreateCache.Error(normalizeSdkError(err as Error)); } - this.logger.info(`Creating cache: ${name}`); + this.logger.debug(`Creating cache: ${name}`); const request = new grpcControl._CreateCacheRequest({ cache_name: name, }); return await new Promise(resolve => { - this.clientWrapper.getClient().CreateCache( - request, - {interceptors: this.interceptors}, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - (err, resp) => { - if (err) { - if (err.code === Status.ALREADY_EXISTS) { - resolve(new CreateCache.AlreadyExists()); + this.clientWrapper + .getClient() + .CreateCache( + request, + {interceptors: this.interceptors}, + (err, _resp) => { + if (err) { + if (err.code === Status.ALREADY_EXISTS) { + resolve(new CreateCache.AlreadyExists()); + } else { + resolve(new CreateCache.Error(cacheServiceErrorMapper(err))); + } } else { - resolve(new CreateCache.Error(cacheServiceErrorMapper(err))); + resolve(new CreateCache.Success()); } - } else { - resolve(new CreateCache.Success()); } - } - ); + ); }); } @@ -111,20 +112,21 @@ export class CacheControlClient { const request = new grpcControl._DeleteCacheRequest({ cache_name: name, }); - this.logger.info(`Deleting cache: ${name}`); + this.logger.debug(`Deleting cache: ${name}`); return await new Promise(resolve => { - this.clientWrapper.getClient().DeleteCache( - request, - {interceptors: this.interceptors}, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - (err, resp) => { - if (err) { - resolve(new DeleteCache.Error(cacheServiceErrorMapper(err))); - } else { - resolve(new DeleteCache.Success()); + this.clientWrapper + .getClient() + .DeleteCache( + request, + {interceptors: this.interceptors}, + (err, _resp) => { + if (err) { + resolve(new DeleteCache.Error(cacheServiceErrorMapper(err))); + } else { + resolve(new DeleteCache.Success()); + } } - } - ); + ); }); } @@ -134,7 +136,7 @@ export class CacheControlClient { } catch (err) { return new CacheFlush.Error(normalizeSdkError(err as Error)); } - this.logger.trace(`Flushing cache: ${cacheName}`); + this.logger.debug(`Flushing cache: ${cacheName}`); return await this.sendFlushCache(cacheName); } diff --git a/packages/client-sdk-web/.eslintrc.json b/packages/client-sdk-web/.eslintrc.json index acf17e33e..16ed9076f 100644 --- a/packages/client-sdk-web/.eslintrc.json +++ b/packages/client-sdk-web/.eslintrc.json @@ -47,7 +47,16 @@ // async without await is often an error and in other uses it obfuscates // the intent of the developer. Functions are async when they want to await. "require-await": "error", - "import/no-duplicates": "error" + "import/no-duplicates": "error", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_" + } + ] }, "settings": { "import/resolver": { @@ -56,4 +65,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/client-sdk-web/src/internal/cache-control-client.ts b/packages/client-sdk-web/src/internal/cache-control-client.ts index f5146e8c7..6ac443e24 100644 --- a/packages/client-sdk-web/src/internal/cache-control-client.ts +++ b/packages/client-sdk-web/src/internal/cache-control-client.ts @@ -70,7 +70,7 @@ export class CacheControlClient< } catch (err) { return new CreateCache.Error(normalizeSdkError(err as Error)); } - this.logger.info(`Creating cache: ${name}`); + this.logger.debug(`Creating cache: ${name}`); const request = new _CreateCacheRequest(); request.setCacheName(name); @@ -78,8 +78,7 @@ export class CacheControlClient< this.clientWrapper.createCache( request, this.clientMetadataProvider.createClientMetadata(), - // eslint-disable-next-line @typescript-eslint/no-unused-vars - (err, resp) => { + (err, _resp) => { if (err) { if (err.code === StatusCode.ALREADY_EXISTS) { resolve(new CreateCache.AlreadyExists()); @@ -102,13 +101,12 @@ export class CacheControlClient< } const request = new _DeleteCacheRequest(); request.setCacheName(name); - this.logger.info(`Deleting cache: ${name}`); + this.logger.debug(`Deleting cache: ${name}`); return await new Promise(resolve => { this.clientWrapper.deleteCache( request, this.clientMetadataProvider.createClientMetadata(), - // eslint-disable-next-line @typescript-eslint/no-unused-vars - (err, resp) => { + (err, _resp) => { if (err) { resolve(new DeleteCache.Error(cacheServiceErrorMapper(err))); } else { @@ -138,7 +136,6 @@ export class CacheControlClient< this.clientWrapper.flushCache( request, this.clientMetadataProvider.createClientMetadata(), - // eslint-disable-next-line @typescript-eslint/no-unused-vars (err, resp) => { if (resp) { resolve(new CacheFlush.Success()); diff --git a/packages/common-integration-tests/.eslintrc.json b/packages/common-integration-tests/.eslintrc.json index 558c2f14c..6cb2cf5ac 100644 --- a/packages/common-integration-tests/.eslintrc.json +++ b/packages/common-integration-tests/.eslintrc.json @@ -47,7 +47,16 @@ // async without await is often an error and in other uses it obfuscates // the intent of the developer. Functions are async when they want to await. "require-await": "error", - "import/no-duplicates": "error" + "import/no-duplicates": "error", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_" + } + ] }, "settings": { "import/resolver": { @@ -56,4 +65,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/core/.eslintrc.json b/packages/core/.eslintrc.json index acf17e33e..16ed9076f 100644 --- a/packages/core/.eslintrc.json +++ b/packages/core/.eslintrc.json @@ -47,7 +47,16 @@ // async without await is often an error and in other uses it obfuscates // the intent of the developer. Functions are async when they want to await. "require-await": "error", - "import/no-duplicates": "error" + "import/no-duplicates": "error", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_" + } + ] }, "settings": { "import/resolver": { @@ -56,4 +65,4 @@ } } } -} \ No newline at end of file +}