Skip to content

Commit 07931d1

Browse files
committed
Merge remote-tracking branch 'origin/amqplib-modernisation-2'
2 parents 2ec1731 + 4de03e7 commit 07931d1

File tree

13 files changed

+69
-56
lines changed

13 files changed

+69
-56
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Add automated formatting via pre-commit hooks using Lefthook
77
- Format entire codebase with standardised formatting rules
88
- Add npm format script for manual code formatting
9+
- Enable noUnusedFunctionParameters lint rule and fix all violations
910

1011
## v0.10.9
1112
- Add support for IPv6 urls

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Project-Specific Guidelines for amqplib
2+
3+
## Generated Files - DO NOT EDIT
4+
- `lib/defs.js` - This file is generated code. NEVER modify it directly.
5+
- Generated via `make lib/defs.js` from the AMQP specification
6+
- If linting issues arise, exclude this file from linting rules rather than modifying it
7+
8+
## Commit Requirements
9+
- NEVER commit when tests are failing
10+
- NEVER commit when there are lint errors
11+
- Always run `npm test` and `npm run lint` before committing
12+
- If tests are failing, investigate and fix the issue before proceeding

biome.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"useLiteralKeys": "off"
2121
},
2222
"correctness": {
23-
"noUnusedFunctionParameters": "off",
23+
"noUnusedFunctionParameters": "error",
2424
"noUnusedVariables": "off",
2525
"noInnerDeclarations": "off",
2626
"useParseIntRadix": "off",
@@ -59,6 +59,6 @@
5959
}
6060
},
6161
"files": {
62-
"includes": ["**/*.js"]
62+
"includes": ["**/*.js", "!lib/defs.js"]
6363
}
6464
}

examples/tutorials/callback_api/receive_logs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ amqp.connect((err, connection) => {
1515
});
1616
});
1717

18-
channel.assertExchange(exchange, 'fanout', {durable: false}, (err, {queue}) => {
18+
channel.assertExchange(exchange, 'fanout', {durable: false}, (err, {queue: _queue}) => {
1919
if (err) return bail(err, connection);
2020
channel.assertQueue('', {exclusive: true}, (err, {queue}) => {
2121
if (err) return bail(err, connection);

lib/callback_model.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CallbackModel extends EventEmitter {
3535
}
3636
var ch = new Channel(this.connection);
3737
ch.setOptions(options);
38-
ch.open(function (err, ok) {
38+
ch.open(function (err, _ok) {
3939
if (err === null) cb && cb(null, ch);
4040
else cb && cb(err);
4141
});
@@ -244,7 +244,7 @@ class Channel extends BaseChannel {
244244
// values. Also substitutes a stub if the callback is `undefined` or
245245
// otherwise falsey, for convenience in methods for which the callback
246246
// is optional (that is, most of them).
247-
function callbackWrapper(ch, cb) {
247+
function callbackWrapper(_ch, cb) {
248248
return cb
249249
? function (err, ok) {
250250
if (err === null) {

lib/connect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function openFrames(vhost, query, credentials, extraClientProperties) {
4747
if (!vhost) vhost = '/';
4848
else vhost = QS.unescape(vhost);
4949

50-
var query = query || {};
50+
query = query || {};
5151

5252
function intOrDefault(val, def) {
5353
return val === undefined ? def : parseInt(val);
@@ -147,7 +147,7 @@ function connect(url, socketOptions, openCallback) {
147147
if (keepAlive) sock.setKeepAlive(keepAlive, keepAliveDelay);
148148

149149
var c = new Connection(sock);
150-
c.open(fields, function (err, ok) {
150+
c.open(fields, function (err, _ok) {
151151
// disable timeout once the connection is open, we don't want
152152
// it fouling things
153153
if (timeout) sock.setTimeout(0);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"scripts": {
2727
"test": "make test",
2828
"format": "biome format . --write",
29-
"lint": "biome lint ."
29+
"lint": "biome lint --max-diagnostics=1000 ."
3030
},
3131
"keywords": [
3232
"AMQP",

test/callback_api.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var channel_test = channel_test_fn('createChannel');
100100
var confirm_channel_test = channel_test_fn('createConfirmChannel');
101101

102102
suite('channel open', function () {
103-
channel_test('at all', function (ch, done) {
103+
channel_test('at all', function (_ch, done) {
104104
done();
105105
});
106106

@@ -114,10 +114,10 @@ suite('assert, check, delete', function () {
114114
ch.assertQueue(
115115
'test.cb.queue',
116116
{},
117-
kCallback(function (q) {
117+
kCallback(function (_q) {
118118
ch.checkQueue(
119119
'test.cb.queue',
120-
kCallback(function (ok) {
120+
kCallback(function (_ok) {
121121
ch.deleteQueue('test.cb.queue', {}, doneCallback(done));
122122
}, done),
123123
);
@@ -130,10 +130,10 @@ suite('assert, check, delete', function () {
130130
'test.cb.exchange',
131131
'topic',
132132
{},
133-
kCallback(function (ex) {
133+
kCallback(function (_ex) {
134134
ch.checkExchange(
135135
'test.cb.exchange',
136-
kCallback(function (ok) {
136+
kCallback(function (_ok) {
137137
ch.deleteExchange('test.cb.exchange', {}, doneCallback(done));
138138
}, done),
139139
);
@@ -335,7 +335,7 @@ suite('Error handling', function () {
335335
var dom = domain.createDomain();
336336
dom.on('error', failCallback(done));
337337
connect(
338-
dom.bind(function (err, conn) {
338+
dom.bind(function (_err, _conn) {
339339
throw new Error('Spurious connection open callback error');
340340
}),
341341
);
@@ -366,21 +366,21 @@ suite('Error handling', function () {
366366
});
367367
}
368368

369-
error_test('Channel open callback throws an error', function (ch, done, dom) {
369+
error_test('Channel open callback throws an error', function (_ch, done, dom) {
370370
dom.on('error', failCallback(done));
371371
throw new Error('Error in open callback');
372372
});
373373

374374
error_test('RPC callback throws error', function (ch, done, dom) {
375375
dom.on('error', failCallback(done));
376-
ch.prefetch(0, false, function (err, ok) {
376+
ch.prefetch(0, false, function (_err, _ok) {
377377
throw new Error('Spurious callback error');
378378
});
379379
});
380380

381381
error_test('Get callback throws error', function (ch, done, dom) {
382382
dom.on('error', failCallback(done));
383-
ch.assertQueue('test.cb.get-with-error', {}, function (err, ok) {
383+
ch.assertQueue('test.cb.get-with-error', {}, function (_err, _ok) {
384384
ch.get('test.cb.get-with-error', {noAck: true}, function () {
385385
throw new Error('Spurious callback error');
386386
});
@@ -389,7 +389,7 @@ suite('Error handling', function () {
389389

390390
error_test('Consume callback throws error', function (ch, done, dom) {
391391
dom.on('error', failCallback(done));
392-
ch.assertQueue('test.cb.consume-with-error', {}, function (err, ok) {
392+
ch.assertQueue('test.cb.consume-with-error', {}, function (_err, _ok) {
393393
ch.consume('test.cb.consume-with-error', ignore, {noAck: true}, function () {
394394
throw new Error('Spurious callback error');
395395
});

test/channel.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function baseChannelTest(client, server) {
2525

2626
if (LOG_ERRORS) c.on('error', console.warn);
2727

28-
c.open(OPEN_OPTS, function (err, ok) {
28+
c.open(OPEN_OPTS, function (err, _ok) {
2929
if (err === null) client(c, bothDone);
3030
else fail(bothDone);
3131
});
@@ -90,7 +90,7 @@ suite('channel open and close', function () {
9090
function (ch, done) {
9191
open(ch).then(succeed(done), fail(done));
9292
},
93-
function (send, wait, done) {
93+
function (_send, _wait, done) {
9494
done();
9595
},
9696
),
@@ -127,7 +127,7 @@ suite('channel open and close', function () {
127127
},
128128
function (send, wait, done, ch) {
129129
return wait(defs.ChannelClose)()
130-
.then(function (close) {
130+
.then(function (_close) {
131131
send(defs.ChannelCloseOk, {}, ch);
132132
})
133133
.then(succeed(done), fail(done));
@@ -174,7 +174,7 @@ suite('channel open and close', function () {
174174
ch.closeBecause('Bye', defs.constants.REPLY_SUCCESS);
175175
}, fail(both));
176176
},
177-
function (send, wait, done, ch) {
177+
function (send, wait, done, _ch) {
178178
wait(defs.ChannelClose)()
179179
.then(function () {
180180
send(
@@ -227,7 +227,7 @@ suite('channel machinery', function () {
227227
var rpcLatch = latch(3, done);
228228
open(ch)
229229
.then(function () {
230-
function wheeboom(err, f) {
230+
function wheeboom(err, _f) {
231231
if (err !== null) rpcLatch(err);
232232
else rpcLatch();
233233
}
@@ -245,7 +245,7 @@ suite('channel machinery', function () {
245245
.then(null, fail(rpcLatch));
246246
},
247247
function (send, wait, done, ch) {
248-
function sendOk(f) {
248+
function sendOk(_f) {
249249
send(defs.BasicQosOk, {}, ch);
250250
}
251251

@@ -368,7 +368,7 @@ suite('channel machinery', function () {
368368
})
369369
.then(succeed(done), fail(done));
370370
},
371-
function (send, wait, done, ch) {
371+
function (_send, wait, done, _ch) {
372372
wait(defs.BasicPublish)()
373373
.then(wait(defs.BasicProperties))
374374
.then(wait(undefined)) // content frame
@@ -399,7 +399,7 @@ suite('channel machinery', function () {
399399
);
400400
}, done);
401401
},
402-
function (send, wait, done, ch) {
402+
function (_send, wait, done, _ch) {
403403
wait(defs.BasicPublish)()
404404
.then(wait(defs.BasicProperties))
405405
.then(wait(undefined)) // content frame
@@ -432,7 +432,7 @@ suite('channel machinery', function () {
432432
);
433433
}, done);
434434
},
435-
function (send, wait, done, ch) {
435+
function (_send, wait, done, _ch) {
436436
wait(defs.BasicPublish)()
437437
.then(wait(defs.BasicProperties))
438438
.then(wait(undefined)) // content frame
@@ -474,7 +474,7 @@ suite('channel machinery', function () {
474474
);
475475
}, done);
476476
},
477-
function (send, wait, done, ch) {
477+
function (_send, wait, done, _ch) {
478478
wait(defs.BasicPublish)()
479479
.then(wait(defs.BasicProperties))
480480
// no content frame for a zero-length message
@@ -495,7 +495,7 @@ suite('channel machinery', function () {
495495
}, done);
496496
});
497497
},
498-
function (send, wait, done, ch) {
498+
function (send, _wait, done, ch) {
499499
completes(function () {
500500
send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
501501
}, done);
@@ -514,7 +514,7 @@ suite('channel machinery', function () {
514514
}, done);
515515
});
516516
},
517-
function (send, wait, done, ch) {
517+
function (send, _wait, done, ch) {
518518
completes(function () {
519519
send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from(''));
520520
}, done);
@@ -560,7 +560,7 @@ suite('channel machinery', function () {
560560
});
561561
}, done);
562562
},
563-
function (send, wait, done, ch) {
563+
function (_send, _wait, done, _ch) {
564564
done();
565565
},
566566
),
@@ -577,7 +577,7 @@ suite('channel machinery', function () {
577577
});
578578
}, done);
579579
},
580-
function (send, wait, done, ch) {
580+
function (_send, _wait, done, _ch) {
581581
done();
582582
},
583583
),
@@ -654,7 +654,7 @@ suite('channel machinery', function () {
654654
});
655655
open(ch);
656656
},
657-
function (send, wait, done, ch) {
657+
function (send, _wait, done, ch) {
658658
completes(function () {
659659
send(defs.BasicReturn, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
660660
}, done);
@@ -673,7 +673,7 @@ suite('channel machinery', function () {
673673
});
674674
open(ch);
675675
},
676-
function (send, wait, done, ch) {
676+
function (send, _wait, done, ch) {
677677
completes(function () {
678678
send(
679679
defs.BasicCancel,
@@ -700,7 +700,7 @@ suite('channel machinery', function () {
700700
});
701701
open(ch);
702702
},
703-
function (send, wait, done, ch) {
703+
function (send, _wait, done, ch) {
704704
completes(function () {
705705
send(
706706
Method,
@@ -734,7 +734,7 @@ suite('channel machinery', function () {
734734
ch.pushConfirmCallback(allConfirms);
735735
open(ch);
736736
},
737-
function (send, wait, done, ch) {
737+
function (send, _wait, done, ch) {
738738
completes(function () {
739739
send(defs.BasicAck, {deliveryTag: 2, multiple: false}, ch);
740740
send(defs.BasicAck, {deliveryTag: 3, multiple: false}, ch);
@@ -761,7 +761,7 @@ suite('channel machinery', function () {
761761
});
762762
open(ch);
763763
},
764-
function (send, wait, done, ch) {
764+
function (send, _wait, done, ch) {
765765
completes(function () {
766766
send(defs.BasicAck, {deliveryTag: 2, multiple: false}, ch);
767767
send(defs.BasicAck, {deliveryTag: 1, multiple: false}, ch);

test/channel_api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var EX_OPTS = {durable: false};
8585

8686
suite('assert, check, delete', function () {
8787
chtest('assert and check queue', function (ch) {
88-
return ch.assertQueue('test.check-queue', QUEUE_OPTS).then(function (qok) {
88+
return ch.assertQueue('test.check-queue', QUEUE_OPTS).then(function (_qok) {
8989
return ch.checkQueue('test.check-queue');
9090
});
9191
});
@@ -154,7 +154,7 @@ suite('assert, check, delete', function () {
154154
function waitForQueue(q, condition) {
155155
return connect(URL).then(function (c) {
156156
return c.createChannel().then(function (ch) {
157-
return ch.checkQueue(q).then(function (qok) {
157+
return ch.checkQueue(q).then(function (_qok) {
158158
function check() {
159159
return ch.checkQueue(q).then(function (qok) {
160160
if (condition(qok)) {
@@ -380,7 +380,7 @@ suite('binding, consuming', function () {
380380
chtest('cancel consumer', function (ch) {
381381
var q = 'test.consumer-cancel';
382382
var ctag;
383-
var recv1 = new Promise(function (resolve, reject) {
383+
var recv1 = new Promise(function (resolve, _reject) {
384384
Promise.all([
385385
ch.assertQueue(q, QUEUE_OPTS),
386386
ch.purgeQueue(q),

0 commit comments

Comments
 (0)