From 1241dfeb43e99eb39ebccfad8d567dd8ed5db11e Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Wed, 31 Jul 2024 14:37:19 -0700 Subject: [PATCH] Node: fix lints (#2062) * Fix linting on Node.js --------- Signed-off-by: Yury-Fridlyand --- .github/workflows/lint-ts.yml | 1 + node/npm/glide/index.ts | 1 + node/tests/AsyncClient.test.ts | 2 +- node/tests/SharedTests.ts | 14 ++++++++------ node/tests/TestUtilities.ts | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint-ts.yml b/.github/workflows/lint-ts.yml index 23d6f348e3..72b51ba16c 100644 --- a/.github/workflows/lint-ts.yml +++ b/.github/workflows/lint-ts.yml @@ -14,6 +14,7 @@ on: - node/** - benchmarks/utilities/* - .github/workflows/lint-ts.yml + workflow_dispatch: concurrency: group: node-lint-${{ github.head_ref || github.ref }} diff --git a/node/npm/glide/index.ts b/node/npm/glide/index.ts index 23fd2c3caa..12997f2547 100644 --- a/node/npm/glide/index.ts +++ b/node/npm/glide/index.ts @@ -9,6 +9,7 @@ import { arch, platform } from "process"; let globalObject = global as unknown; +/* eslint-disable @typescript-eslint/no-require-imports */ function loadNativeBinding() { let nativeBinding = null; switch (platform) { diff --git a/node/tests/AsyncClient.test.ts b/node/tests/AsyncClient.test.ts index ec75809878..762e33fede 100644 --- a/node/tests/AsyncClient.test.ts +++ b/node/tests/AsyncClient.test.ts @@ -7,7 +7,7 @@ import { AsyncClient } from "glide-rs"; import RedisServer from "redis-server"; import { runCommonTests } from "./SharedTests"; import { flushallOnPort } from "./TestUtilities"; -/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable @typescript-eslint/no-require-imports */ const FreePort = require("find-free-port"); const PORT_NUMBER = 4000; diff --git a/node/tests/SharedTests.ts b/node/tests/SharedTests.ts index 57a638560e..4173725cde 100644 --- a/node/tests/SharedTests.ts +++ b/node/tests/SharedTests.ts @@ -5647,10 +5647,12 @@ export function runBaseTests(config: { await client.zmpop([key2, key1], ScoreFilter.MAX, 10), ).toEqual([key2, { a2: 0.1, b2: 0.2 }]); - expect(await client.zmpop([nonExistingKey], ScoreFilter.MIN)) - .toBeNull; - expect(await client.zmpop([nonExistingKey], ScoreFilter.MIN, 1)) - .toBeNull; + expect( + await client.zmpop([nonExistingKey], ScoreFilter.MIN), + ).toBeNull(); + expect( + await client.zmpop([nonExistingKey], ScoreFilter.MIN, 1), + ).toBeNull(); // key exists, but it is not a sorted set expect(await client.set(stringKey, "value")).toEqual("OK"); @@ -5748,7 +5750,7 @@ export function runBaseTests(config: { // ensure that command doesn't time out even if timeout > request timeout (250ms by default) expect( await client.bzmpop([nonExistingKey], ScoreFilter.MAX, 0.5), - ).toBeNull; + ).toBeNull(); expect( await client.bzmpop( [nonExistingKey], @@ -5756,7 +5758,7 @@ export function runBaseTests(config: { 0.55, 1, ), - ).toBeNull; + ).toBeNull(); // key exists, but it is not a sorted set expect(await client.set(stringKey, "value")).toEqual("OK"); diff --git a/node/tests/TestUtilities.ts b/node/tests/TestUtilities.ts index 58ce767594..731ac6740a 100644 --- a/node/tests/TestUtilities.ts +++ b/node/tests/TestUtilities.ts @@ -411,7 +411,7 @@ export function validateTransactionResponse( try { expect(response?.[i]).toEqual(expectedResponse); - } catch (e) { + } catch { const expected = expectedResponse instanceof Map ? JSON.stringify(Array.from(expectedResponse.entries()))