diff --git a/.eslintrc.js b/.eslintrc.js index 2ba2f71b45bbc9..65b7f170280450 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -295,7 +295,6 @@ module.exports = { 'valid-typeof': ['error', { requireStringLiterals: true }], // ESLint recommended rules that we disable - 'no-cond-assign': 'off', 'no-empty': 'off', 'no-inner-declarations': 'off', 'no-prototype-builtins': 'off', diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js index 63a5547e4cbf79..49e5b0624e1ae7 100644 --- a/lib/internal/crypto/scrypt.js +++ b/lib/internal/crypto/scrypt.js @@ -98,8 +98,8 @@ function check(password, salt, keylen, options) { let { N, r, p, maxmem } = defaults; if (options && options !== defaults) { - let has_N, has_r, has_p; - if (has_N = (options.N !== undefined)) { + const has_N = options.N !== undefined; + if (has_N) { N = options.N; validateUint32(N, 'N'); } @@ -108,7 +108,8 @@ function check(password, salt, keylen, options) { N = options.cost; validateUint32(N, 'cost'); } - if (has_r = (options.r !== undefined)) { + const has_r = (options.r !== undefined); + if (has_r) { r = options.r; validateUint32(r, 'r'); } @@ -117,7 +118,8 @@ function check(password, salt, keylen, options) { r = options.blockSize; validateUint32(r, 'blockSize'); } - if (has_p = (options.p !== undefined)) { + const has_p = options.p !== undefined; + if (has_p) { p = options.p; validateUint32(p, 'p'); } diff --git a/lib/internal/policy/sri.js b/lib/internal/policy/sri.js index 6728ff4de22bd1..22704704a310bc 100644 --- a/lib/internal/policy/sri.js +++ b/lib/internal/policy/sri.js @@ -38,7 +38,7 @@ const parse = (str) => { let prevIndex = 0; let match; const entries = []; - while (match = RegExpPrototypeExec(kSRIPattern, str)) { + while ((match = RegExpPrototypeExec(kSRIPattern, str)) !== null) { if (match.index !== prevIndex) { throw new ERR_SRI_PARSE(str, str[prevIndex], prevIndex); } diff --git a/lib/internal/process/task_queues.js b/lib/internal/process/task_queues.js index 2a14b9dea68080..2c53b21040e5d8 100644 --- a/lib/internal/process/task_queues.js +++ b/lib/internal/process/task_queues.js @@ -68,7 +68,7 @@ function runNextTicks() { function processTicksAndRejections() { let tock; do { - while (tock = queue.shift()) { + while ((tock = queue.shift()) !== null) { const asyncId = tock[async_id_symbol]; emitBefore(asyncId, tock[trigger_async_id_symbol], tock); diff --git a/lib/internal/streams/buffer_list.js b/lib/internal/streams/buffer_list.js index 2dc803d6fa0425..5279f65b4bdd23 100644 --- a/lib/internal/streams/buffer_list.js +++ b/lib/internal/streams/buffer_list.js @@ -57,7 +57,7 @@ module.exports = class BufferList { return ''; let p = this.head; let ret = '' + p.data; - while (p = p.next) + while ((p = p.next) !== null) ret += s + p.data; return ret; } @@ -129,7 +129,7 @@ module.exports = class BufferList { break; } ++c; - } while (p = p.next); + } while ((p = p.next) !== null); this.length -= c; return ret; } @@ -163,7 +163,7 @@ module.exports = class BufferList { break; } ++c; - } while (p = p.next); + } while ((p = p.next) !== null); this.length -= c; return ret; } diff --git a/lib/internal/timers.js b/lib/internal/timers.js index 2441d7b194a72b..f48b4057a37ef1 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -490,7 +490,7 @@ function getTimerCallbacks(runNextTicks) { let list; let ranAtLeastOneList = false; - while (list = timerListQueue.peek()) { + while ((list = timerListQueue.peek()) != null) { if (list.expiry > now) { nextExpiry = list.expiry; return refCount > 0 ? nextExpiry : -nextExpiry; @@ -511,7 +511,7 @@ function getTimerCallbacks(runNextTicks) { let ranAtLeastOneTimer = false; let timer; - while (timer = L.peek(list)) { + while ((timer = L.peek(list)) != null) { const diff = now - timer._idleStart; // Check if this loop iteration is too early for the next timer. diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 814e5bf0f37cd4..ca3227dea43c99 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1311,7 +1311,7 @@ function formatError(err, constructor, tag, ctx, keys) { let nodeModule; newStack += '\n'; let pos = 0; - while (nodeModule = nodeModulesRegExp.exec(line)) { + while ((nodeModule = nodeModulesRegExp.exec(line)) !== null) { // '/node_modules/'.length === 14 newStack += line.slice(pos, nodeModule.index + 14); newStack += ctx.stylize(nodeModule[1], 'module'); diff --git a/lib/repl.js b/lib/repl.js index 43af9c7c0e09a9..c576f5b7f3094d 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -381,7 +381,7 @@ function REPLServer(prompt, paused = false; let entry; const tmpCompletionEnabled = self.isCompletionEnabled; - while (entry = ArrayPrototypeShift(pausedBuffer)) { + while ((entry = ArrayPrototypeShift(pausedBuffer)) !== undefined) { const { 0: type, 1: payload, 2: isCompletionEnabled } = entry; switch (type) { case 'key': { @@ -1450,7 +1450,7 @@ function complete(line, callback) { ArrayPrototypePush(completionGroups, getGlobalLexicalScopeNames(this[kContextId])); let contextProto = this.context; - while (contextProto = ObjectGetPrototypeOf(contextProto)) { + while ((contextProto = ObjectGetPrototypeOf(contextProto)) !== null) { ArrayPrototypePush(completionGroups, filteredOwnPropertyNames(contextProto)); } diff --git a/test/parallel/test-child-process-flush-stdio.js b/test/parallel/test-child-process-flush-stdio.js index a7c1ea21be22a4..7b9a2a049cb20b 100644 --- a/test/parallel/test-child-process-flush-stdio.js +++ b/test/parallel/test-child-process-flush-stdio.js @@ -27,7 +27,7 @@ const spawnWithReadable = () => { })); p.stdout.on('readable', () => { let buf; - while (buf = p.stdout.read()) + while ((buf = p.stdout.read()) !== null) buffer.push(buf); }); }; diff --git a/test/parallel/test-net-server-max-connections.js b/test/parallel/test-net-server-max-connections.js index 705c99b7b9737a..ea9a8d29e9f1ed 100644 --- a/test/parallel/test-net-server-max-connections.js +++ b/test/parallel/test-net-server-max-connections.js @@ -68,7 +68,7 @@ function makeConnection(index) { if (closes === N / 2) { let cb; console.error('calling wait callback.'); - while (cb = waits.shift()) { + while ((cb = waits.shift()) !== undefined) { cb(); } server.close(); diff --git a/test/parallel/test-stream-readable-object-multi-push-async.js b/test/parallel/test-stream-readable-object-multi-push-async.js index 17c84c7310e053..3bdbe4d3517c48 100644 --- a/test/parallel/test-stream-readable-object-multi-push-async.js +++ b/test/parallel/test-stream-readable-object-multi-push-async.js @@ -47,7 +47,7 @@ const BATCH = 10; readable.on('readable', () => { let data; console.log('readable emitted'); - while (data = readable.read()) { + while ((data = readable.read()) !== null) { console.log(data); } }); diff --git a/test/parallel/test-stream-unshift-empty-chunk.js b/test/parallel/test-stream-unshift-empty-chunk.js index dbcafbfdcb7ad2..e8136a68e9e6aa 100644 --- a/test/parallel/test-stream-unshift-empty-chunk.js +++ b/test/parallel/test-stream-unshift-empty-chunk.js @@ -41,7 +41,7 @@ let readAll = false; const seen = []; r.on('readable', () => { let chunk; - while (chunk = r.read()) { + while ((chunk = r.read()) !== null) { seen.push(chunk.toString()); // Simulate only reading a certain amount of the data, // and then putting the rest of the chunk back into the diff --git a/test/parallel/test-zlib-brotli-flush.js b/test/parallel/test-zlib-brotli-flush.js index 6883fb903a6478..fd730bfacd3189 100644 --- a/test/parallel/test-zlib-brotli-flush.js +++ b/test/parallel/test-zlib-brotli-flush.js @@ -16,7 +16,7 @@ deflater.write(chunk, function() { deflater.flush(function() { const bufs = []; let buf; - while (buf = deflater.read()) + while ((buf = deflater.read()) !== null) bufs.push(buf); actualFull = Buffer.concat(bufs); }); diff --git a/test/parallel/test-zlib-flush.js b/test/parallel/test-zlib-flush.js index 965cb5c45b13ea..557775d5091a46 100644 --- a/test/parallel/test-zlib-flush.js +++ b/test/parallel/test-zlib-flush.js @@ -23,7 +23,7 @@ deflater.write(chunk, function() { deflater.flush(function() { const bufs = []; let buf; - while (buf = deflater.read()) + while ((buf = deflater.read()) !== null) bufs.push(buf); actualFull = Buffer.concat(bufs); }); diff --git a/test/parallel/test-zlib-params.js b/test/parallel/test-zlib-params.js index 293ceecf8fa02a..30d4f133ad43bd 100644 --- a/test/parallel/test-zlib-params.js +++ b/test/parallel/test-zlib-params.js @@ -21,7 +21,7 @@ deflater.write(chunk1, function() { deflater.end(chunk2, function() { const bufs = []; let buf; - while (buf = deflater.read()) + while ((buf = deflater.read()) !== null) bufs.push(buf); actual = Buffer.concat(bufs); });