diff --git a/.claude/commands/lint-enforce.md b/.claude/commands/lint-enforce.md new file mode 100644 index 00000000..fe4e3323 --- /dev/null +++ b/.claude/commands/lint-enforce.md @@ -0,0 +1,13 @@ +Please follow the following process when I ask you to enfore a new lint rule using /lint-enforce $rule + +1. Create and change to a new branch. Ask for the branch name. +2. Configure the rule to error in biome.json +3. Run lint (npm run lint). If there are NO errors, goto step 9 +4. If there are no errors goto X +5. Use biome to SAFELY auto fix (npm run lint -- --fix). If there are errors stop and ask for instruction. +7. Run the tests (npm test). If there are errors, stop and ask for instruction. +8. If the rule defaults to error, delete it (See https://biomejs.dev/linter/javascript/rules/ for rule details) +9. Update the project changelog +10. Add the changes +11. Commit the changes +12. Push the changes diff --git a/CHANGELOG.md b/CHANGELOG.md index be6fee36..069141ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Add node: protocol prefix to Node.js builtin module imports for clarity - Use modern exponentiation operator (**) instead of Math.pow() - Replace string concatenation with modern template literals +- Remove redundant 'use strict' directives as modules are automatically in strict mode ## v0.10.9 - Add support for IPv6 urls diff --git a/biome.json b/biome.json index a0469411..8981412e 100644 --- a/biome.json +++ b/biome.json @@ -20,7 +20,7 @@ "useLiteralKeys": "off" }, "suspicious": { - "noRedundantUseStrict": "off", + "noRedundantUseStrict": "error", "noAssignInExpressions": "off", "noAsyncPromiseExecutor": "off", "noDoubleEquals": "off", diff --git a/examples/receive_generator.js b/examples/receive_generator.js index 4136f7d0..73da1392 100644 --- a/examples/receive_generator.js +++ b/examples/receive_generator.js @@ -1,6 +1,4 @@ #!/usr/bin/env node - -'use strict'; const co = require('co'); const amqp = require('amqplib'); const readline = require('node:readline'); diff --git a/examples/send_generators.js b/examples/send_generators.js index e1ca1978..7f97d321 100755 --- a/examples/send_generators.js +++ b/examples/send_generators.js @@ -1,7 +1,5 @@ #!/usr/bin/env node -'use strict'; - // NB this requires the module 'co': // npm install co const co = require('co'); diff --git a/lib/api_args.js b/lib/api_args.js index 83410498..0ef4734f 100644 --- a/lib/api_args.js +++ b/lib/api_args.js @@ -1,9 +1,3 @@ -// -// -// - -'use strict'; - /* The channel (promise) and callback APIs have similar signatures, and in particular, both need AMQP fields prepared from the same arguments diff --git a/lib/bitset.js b/lib/bitset.js index aa396ab0..a352b5c1 100644 --- a/lib/bitset.js +++ b/lib/bitset.js @@ -1,9 +1,3 @@ -// -// -// - -'use strict'; - /** * A bitset implementation, after that in java.util. Yes there * already exist such things, but none implement next{Clear|Set}Bit or diff --git a/lib/callback_model.js b/lib/callback_model.js index 591c5963..c7822151 100644 --- a/lib/callback_model.js +++ b/lib/callback_model.js @@ -1,9 +1,3 @@ -// -// -// - -'use strict'; - const defs = require('./defs'); const EventEmitter = require('node:events'); const BaseChannel = require('./channel').BaseChannel; diff --git a/lib/channel.js b/lib/channel.js index 9af453b6..f510d7ad 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -1,11 +1,3 @@ -// -// -// - -// Channel machinery. - -'use strict'; - const defs = require('./defs'); const closeMsg = require('./format').closeMessage; const inspect = require('./format').inspect; diff --git a/lib/channel_model.js b/lib/channel_model.js index 530e929d..4a8a7d27 100644 --- a/lib/channel_model.js +++ b/lib/channel_model.js @@ -1,9 +1,3 @@ -// -// -// - -'use strict'; - const EventEmitter = require('node:events'); const promisify = require('node:util').promisify; const defs = require('./defs'); diff --git a/lib/codec.js b/lib/codec.js index 5ef40f10..0b456461 100644 --- a/lib/codec.js +++ b/lib/codec.js @@ -1,9 +1,4 @@ -// -// -// - /* - The AMQP 0-9-1 is a mess when it comes to the types that can be encoded on the wire. @@ -48,11 +43,8 @@ except that they appear in content header frames, which include a content size, and they carry a set of flags indicating which properties are present. This scheme can save ones of bytes per message (messages which take a minimum of three frames each to send). - */ -'use strict'; - const ints = require('buffer-more-ints'); // JavaScript uses only doubles so what I'm testing for is whether diff --git a/lib/connect.js b/lib/connect.js index 5d13eefb..4446facd 100644 --- a/lib/connect.js +++ b/lib/connect.js @@ -1,11 +1,3 @@ -// -// -// - -// General-purpose API for glueing everything together. - -'use strict'; - const URL = require('url-parse'); const QS = require('node:querystring'); const Connection = require('./connection').Connection; diff --git a/lib/connection.js b/lib/connection.js index f4d4cded..04b862cb 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -1,9 +1,3 @@ -// -// -// - -'use strict'; - const defs = require('./defs'); const constants = defs.constants; const frame = require('./frame'); diff --git a/lib/format.js b/lib/format.js index bd69786d..ff638df0 100644 --- a/lib/format.js +++ b/lib/format.js @@ -1,11 +1,3 @@ -// -// -// - -// Stringifying various things - -'use strict'; - const defs = require('./defs'); const format = require('node:util').format; const HEARTBEAT = require('./frame').HEARTBEAT; diff --git a/lib/frame.js b/lib/frame.js index 74dfe549..e1373e0a 100644 --- a/lib/frame.js +++ b/lib/frame.js @@ -1,9 +1,3 @@ -// The river sweeps through -// Silt and twigs, gravel and leaves -// Driving the wheel on - -'use strict'; - const ints = require('buffer-more-ints'); const defs = require('./defs'); const constants = defs.constants; diff --git a/lib/heartbeat.js b/lib/heartbeat.js index 3e38dd4f..b0037dde 100644 --- a/lib/heartbeat.js +++ b/lib/heartbeat.js @@ -1,7 +1,3 @@ -// -// -// - // Heartbeats. In AMQP both clients and servers may expect a heartbeat // frame if there is no activity on the connection for a negotiated // period of time. If there's no activity for two such intervals, the @@ -45,8 +41,6 @@ // %% Yes, I could apply the same 'actually passage of time' thing to // %% send as well as to recv. -'use strict'; - const EventEmitter = require('node:events'); // Exported so that we can mess with it in tests diff --git a/lib/mux.js b/lib/mux.js index a3941aa8..0ece5aa9 100644 --- a/lib/mux.js +++ b/lib/mux.js @@ -1,9 +1,3 @@ -// -// -// - -'use strict'; - // A Mux is an object into which other readable streams may be piped; // it then writes 'packets' from the upstreams to the given // downstream. diff --git a/test/bitset.js b/test/bitset.js index 8083a218..ce852577 100644 --- a/test/bitset.js +++ b/test/bitset.js @@ -1,5 +1,3 @@ -'use strict'; - const claire = require('claire'); const {BitSet} = require('../lib/bitset'); diff --git a/test/callback_api.js b/test/callback_api.js index 89c19191..8bc9be29 100644 --- a/test/callback_api.js +++ b/test/callback_api.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('node:assert'); const api = require('../callback_api'); const util = require('./util'); diff --git a/test/channel.js b/test/channel.js index f69dfcec..b4107fcf 100644 --- a/test/channel.js +++ b/test/channel.js @@ -1,7 +1,3 @@ -// Test the channel machinery - -'use strict'; - const assert = require('node:assert'); const promisify = require('node:util').promisify; const Channel = require('../lib/channel').Channel; diff --git a/test/channel_api.js b/test/channel_api.js index b4748e4d..bb909be5 100644 --- a/test/channel_api.js +++ b/test/channel_api.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('node:assert'); const api = require('../channel_api'); const util = require('./util'); diff --git a/test/codec.js b/test/codec.js index 5523e9b9..a6dbe882 100644 --- a/test/codec.js +++ b/test/codec.js @@ -1,5 +1,3 @@ -'use strict'; - const codec = require('../lib/codec'); const defs = require('../lib/defs'); const assert = require('node:assert'); diff --git a/test/connect.js b/test/connect.js index 8ada9d98..3c1fd8d3 100644 --- a/test/connect.js +++ b/test/connect.js @@ -1,5 +1,3 @@ -'use strict'; - const connect = require('../lib/connect').connect; const credentialsFromUrl = require('../lib/connect').credentialsFromUrl; const defs = require('../lib/defs'); diff --git a/test/connection.js b/test/connection.js index bd54dea9..d4bbfc45 100644 --- a/test/connection.js +++ b/test/connection.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('node:assert'); const defs = require('../lib/defs'); const Connection = require('../lib/connection').Connection; diff --git a/test/data.js b/test/data.js index f0a01697..bb4bce1d 100644 --- a/test/data.js +++ b/test/data.js @@ -1,7 +1,3 @@ -// Property-based testing representations of various things in AMQP - -'use strict'; - const C = require('claire'); const forAll = C.forAll; const arb = C.data; diff --git a/test/frame.js b/test/frame.js index 54756b40..5535040c 100644 --- a/test/frame.js +++ b/test/frame.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('node:assert'); const connection = require('../lib/connection'); const Frames = connection.Connection; diff --git a/test/mux.js b/test/mux.js index 92f03725..2394f841 100644 --- a/test/mux.js +++ b/test/mux.js @@ -1,5 +1,3 @@ -'use strict'; - const assert = require('node:assert'); const Mux = require('../lib/mux').Mux; const PassThrough = require('node:stream').PassThrough; diff --git a/test/util.js b/test/util.js index 2bcac09d..baf84834 100644 --- a/test/util.js +++ b/test/util.js @@ -1,5 +1,3 @@ -'use strict'; - const crypto = require('node:crypto'); const Connection = require('../lib/connection').Connection; const PassThrough = require('node:stream').PassThrough;