From 68caf5027d308b270f17ac79eba0418365cd596f Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 29 Nov 2023 04:44:02 +0000 Subject: [PATCH] fix: add new-for-builtins rule (#5116) --- .eslintrc.js | 1 + packages/backend/server/tests/exception-logger.e2e.ts | 2 +- packages/frontend/graphql/src/utils.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4e59b55aaf..a94e1e5012 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -214,6 +214,7 @@ const config = { 'unicorn/prefer-date-now': 'error', 'unicorn/no-typeof-undefined': 'error', 'unicorn/no-useless-promise-resolve-reject': 'error', + 'unicorn/new-for-builtins': 'error', 'sonarjs/no-all-duplicated-branches': 'error', 'sonarjs/no-element-overwrite': 'error', 'sonarjs/no-empty-collection': 'error', diff --git a/packages/backend/server/tests/exception-logger.e2e.ts b/packages/backend/server/tests/exception-logger.e2e.ts index 982225fdeb..12f00ee9eb 100644 --- a/packages/backend/server/tests/exception-logger.e2e.ts +++ b/packages/backend/server/tests/exception-logger.e2e.ts @@ -17,7 +17,7 @@ class FakePrisma { get workspace() { return { async findUnique() { - throw Error('exception from graphql'); + throw new Error('exception from graphql'); }, }; } diff --git a/packages/frontend/graphql/src/utils.ts b/packages/frontend/graphql/src/utils.ts index fb9804c504..138a427bdd 100644 --- a/packages/frontend/graphql/src/utils.ts +++ b/packages/frontend/graphql/src/utils.ts @@ -3,7 +3,7 @@ export const TRACE_ID_BYTES = 16; export const TRACE_VERSION = '00'; export const TRACE_FLAG = '01'; -const BytesBuffer = Array(32); +const BytesBuffer = new Array(32); type TraceSpan = { name: string;