This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new 6b0bcc42 [Node.js] Fix ESLint errors in src and test so the lint gate 
passes (#1396)
6b0bcc42 is described below

commit 6b0bcc422ff1ee66198df6b4a48a4a44ad7218fa
Author: Quan <[email protected]>
AuthorDate: Mon Oct 12 16:13:35 2026 +0800

    [Node.js] Fix ESLint errors in src and test so the lint gate passes (#1396)
    
    - parenthesize ambiguous conditional arrow bodies and normalize 
array-bracket-spacing
    - add eslint-disable-next-line for intentionally-unused positional params
    - convert empty mock methods to () => undefined
    - wrap test-only require() in an eslint-disable no-var-requires block
---
 nodejs/src/consumer/PushSubscriptionSettings.ts     |  2 +-
 nodejs/src/hook/InflightRequestCountInterceptor.ts  |  2 ++
 nodejs/src/retry/ExponentialBackoffRetryPolicy.ts   |  2 +-
 nodejs/src/route/IpNameResolver.ts                  |  3 ++-
 nodejs/test/consumer/ProcessQueue.test.ts           | 10 +++++-----
 nodejs/test/fixes.test.ts                           |  4 ++--
 nodejs/test/hook.test.ts                            |  4 +++-
 nodejs/test/producer/PublishingLoadBalancer.test.ts |  2 +-
 nodejs/test/route/IpNameResolver.test.ts            |  5 +++--
 nodejs/test/util/Semaphore.test.ts                  |  4 ++--
 10 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/nodejs/src/consumer/PushSubscriptionSettings.ts 
b/nodejs/src/consumer/PushSubscriptionSettings.ts
index a69dfbe1..3d8518ce 100644
--- a/nodejs/src/consumer/PushSubscriptionSettings.ts
+++ b/nodejs/src/consumer/PushSubscriptionSettings.ts
@@ -127,7 +127,7 @@ export class PushSubscriptionSettings extends Settings {
       // Convert protobuf Duration (seconds + nanos) to milliseconds without
       // losing sub-second precision.
       const toMillis = (duration?: Duration) =>
-        duration ? duration.getSeconds() * 1000 + duration.getNanos() / 1e6 : 
0;
+        (duration ? duration.getSeconds() * 1000 + duration.getNanos() / 1e6 : 
0);
       switch (backoffPolicy.getStrategyCase()) {
         case RetryPolicyPB.StrategyCase.EXPONENTIAL_BACKOFF: {
           const exponential = backoffPolicy.getExponentialBackoff()!;
diff --git a/nodejs/src/hook/InflightRequestCountInterceptor.ts 
b/nodejs/src/hook/InflightRequestCountInterceptor.ts
index c508532c..7162e5b9 100644
--- a/nodejs/src/hook/InflightRequestCountInterceptor.ts
+++ b/nodejs/src/hook/InflightRequestCountInterceptor.ts
@@ -26,12 +26,14 @@ import { GeneralMessage, MessageInterceptor } from 
'./MessageInterceptor';
 export class InflightRequestCountInterceptor implements MessageInterceptor {
   #inflightReceiveRequestCount = 0;
 
+  // eslint-disable-next-line @typescript-eslint/no-unused-vars
   doBefore(context: MessageInterceptorContext, _messages: GeneralMessage[]) {
     if (context.getMessageHookPoints() === MessageHookPoints.RECEIVE) {
       this.#inflightReceiveRequestCount++;
     }
   }
 
+  // eslint-disable-next-line @typescript-eslint/no-unused-vars
   doAfter(context: MessageInterceptorContext, _messages: GeneralMessage[]) {
     if (context.getMessageHookPoints() === MessageHookPoints.RECEIVE) {
       this.#inflightReceiveRequestCount--;
diff --git a/nodejs/src/retry/ExponentialBackoffRetryPolicy.ts 
b/nodejs/src/retry/ExponentialBackoffRetryPolicy.ts
index e851d0e8..b26d80a2 100644
--- a/nodejs/src/retry/ExponentialBackoffRetryPolicy.ts
+++ b/nodejs/src/retry/ExponentialBackoffRetryPolicy.ts
@@ -62,7 +62,7 @@ export class ExponentialBackoffRetryPolicy implements 
RetryPolicy {
     // losing sub-second precision (e.g. an initial backoff of 0.5s used to
     // be truncated to plain 0, causing immediate retries).
     const toMillis = (duration?: { seconds?: number; nanos?: number }) =>
-      duration ? (duration.seconds ?? 0) * 1000 + (duration.nanos ?? 0) / 1e6 
: 0;
+      (duration ? (duration.seconds ?? 0) * 1000 + (duration.nanos ?? 0) / 1e6 
: 0);
     return new ExponentialBackoffRetryPolicy(this.#maxAttempts,
       toMillis(backoff.initial),
       toMillis(backoff.max),
diff --git a/nodejs/src/route/IpNameResolver.ts 
b/nodejs/src/route/IpNameResolver.ts
index d2bb2c60..246db5d5 100644
--- a/nodejs/src/route/IpNameResolver.ts
+++ b/nodejs/src/route/IpNameResolver.ts
@@ -53,6 +53,7 @@ class IpResolver {
   private error: { code: Status; details: string; metadata: Metadata } | null 
= null;
   private hasReturnedResult = false;
 
+  // eslint-disable-next-line @typescript-eslint/no-unused-vars
   constructor(target: experimental.GrpcUri, listener: 
experimental.ResolverListener, _channelOptions: ChannelOptions) {
     this.listener = listener;
     const pathList = (target.path || '').split(',').map(s => 
s.trim()).filter(Boolean);
@@ -72,7 +73,7 @@ class IpResolver {
         port: hostPort.port ?? DEFAULT_PORT,
       });
     }
-    this.endpoints = shuffle(addresses).map(address => ({ addresses: [address] 
}));
+    this.endpoints = shuffle(addresses).map(address => ({ addresses: [ address 
] }));
   }
 
   updateResolution(): void {
diff --git a/nodejs/test/consumer/ProcessQueue.test.ts 
b/nodejs/test/consumer/ProcessQueue.test.ts
index dbd194f1..22956385 100644
--- a/nodejs/test/consumer/ProcessQueue.test.ts
+++ b/nodejs/test/consumer/ProcessQueue.test.ts
@@ -32,8 +32,8 @@ function makeConsumer(consumeConcurrentlyMax: number): any {
     wrapChangeInvisibleDurationRequest: () => ({}),
     getConsumerGroup: () => 'cg',
     clientId: 'client',
-    logger: { info: () => {}, debug: () => {}, warn: () => {}, error: () => {} 
},
-    getConsumeService: () => ({ consume: () => {} }),
+    logger: { info: () => undefined, debug: () => undefined, warn: () => 
undefined, error: () => undefined },
+    getConsumeService: () => ({ consume: () => undefined }),
     cacheMessageCountThresholdPerQueue: () => 1024,
     cacheMessageBytesThresholdPerQueue: () => 1024 * 1024,
   };
@@ -55,7 +55,7 @@ const mq: any = { topic: { name: 't' }, broker: { name: 'b' 
}, queueId: 0 };
 describe('ProcessQueue consumption permit (backpressure)', () => {
   it('caps cached messages by consumeConcurrentlyMax and reports 
availablePermits', () => {
     const pq = new ProcessQueue(makeConsumer(2), mq, new 
FilterExpression('*'));
-    pq.cacheMessages([makeMessage('a'), makeMessage('b'), makeMessage('c')]);
+    pq.cacheMessages([ makeMessage('a'), makeMessage('b'), makeMessage('c') ]);
     // Only two permits exist, so only two messages are cached.
     assert.strictEqual(pq.cachedMessagesCount(), 2);
     assert.strictEqual(pq.availablePermits(), 0);
@@ -64,7 +64,7 @@ describe('ProcessQueue consumption permit (backpressure)', () 
=> {
   it('releases a permit when a message is settled (discarded/nacked)', async 
() => {
     const pq = new ProcessQueue(makeConsumer(2), mq, new 
FilterExpression('*'));
     const a = makeMessage('a');
-    pq.cacheMessages([a, makeMessage('b')]);
+    pq.cacheMessages([ a, makeMessage('b') ]);
     assert.strictEqual(pq.availablePermits(), 0);
     // discardMessage -> nack -> (async) evict -> release permit
     pq.discardMessage(a);
@@ -75,7 +75,7 @@ describe('ProcessQueue consumption permit (backpressure)', () 
=> {
   it('releases nothing for an unknown message (no double release)', async () 
=> {
     const pq = new ProcessQueue(makeConsumer(2), mq, new 
FilterExpression('*'));
     const a = makeMessage('a');
-    pq.cacheMessages([a]);
+    pq.cacheMessages([ a ]);
     assert.strictEqual(pq.availablePermits(), 1);
     pq.discardMessage(makeMessage('z')); // not in cache
     await new Promise(r => setTimeout(r, 30));
diff --git a/nodejs/test/fixes.test.ts b/nodejs/test/fixes.test.ts
index d230cbc1..95a6b0fc 100644
--- a/nodejs/test/fixes.test.ts
+++ b/nodejs/test/fixes.test.ts
@@ -83,7 +83,7 @@ describe('ExponentialBackoffRetryPolicy (ms contract)', () => 
{
 
 describe('CustomizedBackoffRetryPolicy', () => {
   it('should return the Nth duration and clamp to the last one', () => {
-    const policy = new CustomizedBackoffRetryPolicy([1000, 5000, 10000], 5);
+    const policy = new CustomizedBackoffRetryPolicy([ 1000, 5000, 10000 ], 5);
     assert.strictEqual(policy.getNextAttemptDelay(1), 1000);
     assert.strictEqual(policy.getNextAttemptDelay(2), 5000);
     assert.strictEqual(policy.getNextAttemptDelay(3), 10000);
@@ -98,7 +98,7 @@ describe('CustomizedBackoffRetryPolicy', () => {
     const retryPolicy = new RetryPolicyPB()
       .setMaxAttempts(4)
       .setCustomizedBackoff(customizedBackoff);
-    const policy = new CustomizedBackoffRetryPolicy([100], 
3).inheritBackoff(retryPolicy);
+    const policy = new CustomizedBackoffRetryPolicy([ 100 ], 
3).inheritBackoff(retryPolicy);
     assert.strictEqual(policy.getMaxAttempts(), 3);
     assert.strictEqual(policy.getNextAttemptDelay(1), 1000);
     assert.strictEqual(policy.getNextAttemptDelay(2), 500);
diff --git a/nodejs/test/hook.test.ts b/nodejs/test/hook.test.ts
index f9e31b39..30f7121c 100644
--- a/nodejs/test/hook.test.ts
+++ b/nodejs/test/hook.test.ts
@@ -117,9 +117,11 @@ function eventRecorder(events: string[], key?: 
AttributeKey<string>, value?: str
 
 describe('Telemetry command dispatch vs Java (J-1)', () => {
   it('should dispatch NOTIFY_UNSUBSCRIBE_LITE_COMMAND to the client', () => {
+    /* eslint-disable @typescript-eslint/no-var-requires */
     const { EventEmitter } = require('node:events');
     const { TelemetryCommand, NotifyUnsubscribeLiteCommand } = 
require('../proto/apache/rocketmq/v2/service_pb');
     const { TelemetrySession } = require('../src/client/TelemetrySession');
+    /* eslint-enable @typescript-eslint/no-var-requires */
 
     const received: Array<{ liteTopic: string; facade: string }> = [];
     const stream = new EventEmitter();
@@ -135,7 +137,7 @@ describe('Telemetry command dispatch vs Java (J-1)', () => {
       },
     };
     new TelemetrySession(fakeClient, new Endpoints('127.0.0.1:8081'),
-      { info() {}, warn() {}, error() {}, debug() {} });
+      { info: () => undefined, warn: () => undefined, error: () => undefined, 
debug: () => undefined });
 
     const telemetryCommand = new TelemetryCommand();
     telemetryCommand.setNotifyUnsubscribeLiteCommand(new 
NotifyUnsubscribeLiteCommand().setLiteTopic('lite-topic-1'));
diff --git a/nodejs/test/producer/PublishingLoadBalancer.test.ts 
b/nodejs/test/producer/PublishingLoadBalancer.test.ts
index aaf6de41..ca6a1535 100644
--- a/nodejs/test/producer/PublishingLoadBalancer.test.ts
+++ b/nodejs/test/producer/PublishingLoadBalancer.test.ts
@@ -62,7 +62,7 @@ describe('takeMessageQueueByMessageGroup floorMod semantics 
(C-1)', () => {
 
   it('should always yield a non-negative index matching Java LongMath.mod', () 
=> {
     const loadBalancer = buildLoadBalancer(8);
-    const groups = ['group-a', 'fifo-group', 'group-中文', 'x', 'order-12345', 
''];
+    const groups = [ 'group-a', 'fifo-group', 'group-中文', 'x', 'order-12345', 
'' ];
     for (const group of groups) {
       const mq = loadBalancer.takeMessageQueueByMessageGroup(group);
       assert.ok(mq, 'should resolve a message queue for group=' + group);
diff --git a/nodejs/test/route/IpNameResolver.test.ts 
b/nodejs/test/route/IpNameResolver.test.ts
index a76d8f0d..c0908d96 100644
--- a/nodejs/test/route/IpNameResolver.test.ts
+++ b/nodejs/test/route/IpNameResolver.test.ts
@@ -36,6 +36,7 @@ function makeTarget(path: string) {
  */
 function resolve(path: string): Promise<Endpoint[]> {
   return new Promise((resolvePromise, rejectPromise) => {
+    // eslint-disable-next-line @typescript-eslint/no-unused-vars
     const listener = (endpointList: any, _attrs: any, _cfg: any, _note: 
string) => {
       if (endpointList.ok) {
         resolvePromise(endpointList.value as Endpoint[]);
@@ -89,7 +90,7 @@ describe('IpNameResolver (custom ip scheme, mirrors Java 
IpNameResolverFactory)'
     try {
       const eps = await resolve('10.0.0.1:80,10.0.0.2:80,10.0.0.3:80');
       const order = eps.map(e => e.addresses[0].host);
-      assert.deepStrictEqual(order, ['10.0.0.2', '10.0.0.3', '10.0.0.1']);
+      assert.deepStrictEqual(order, [ '10.0.0.2', '10.0.0.3', '10.0.0.1' ]);
     } finally {
       Math.random = original;
     }
@@ -97,7 +98,7 @@ describe('IpNameResolver (custom ip scheme, mirrors Java 
IpNameResolverFactory)'
 
   it('returns a permutation (all original addresses, no duplicates) across 
runs', async () => {
     const input = '10.0.0.1:80,10.0.0.2:80,10.0.0.3:80,10.0.0.4:80';
-    const expected = new Set(['10.0.0.1:80', '10.0.0.2:80', '10.0.0.3:80', 
'10.0.0.4:80']);
+    const expected = new Set([ '10.0.0.1:80', '10.0.0.2:80', '10.0.0.3:80', 
'10.0.0.4:80' ]);
     for (let i = 0; i < 20; i++) {
       const eps = await resolve(input);
       assert.strictEqual(eps.length, 4);
diff --git a/nodejs/test/util/Semaphore.test.ts 
b/nodejs/test/util/Semaphore.test.ts
index 4fcff641..2884a98d 100644
--- a/nodejs/test/util/Semaphore.test.ts
+++ b/nodejs/test/util/Semaphore.test.ts
@@ -65,8 +65,8 @@ describe('Semaphore (consumption permit primitive)', () => {
     s.release();
     s.release();
     s.release();
-    await Promise.all([a, b, c]);
-    assert.deepStrictEqual(order, [1, 2, 3]);
+    await Promise.all([ a, b, c ]);
+    assert.deepStrictEqual(order, [ 1, 2, 3 ]);
     assert.strictEqual(s.availablePermits, 0);
   });
 

Reply via email to