Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools,test,lib: enable no-cond-assign ESLint rule #41614

Merged
merged 9 commits into from
Jan 23, 2022
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 6 additions & 4 deletions lib/internal/crypto/scrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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');
}
Expand All @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/policy/sri.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/task_queues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions lib/internal/streams/buffer_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -129,7 +129,7 @@ module.exports = class BufferList {
break;
}
++c;
} while (p = p.next);
} while ((p = p.next) !== null);
this.length -= c;
return ret;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ module.exports = class BufferList {
break;
}
++c;
} while (p = p.next);
} while ((p = p.next) !== null);
this.length -= c;
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-flush-stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};
2 changes: 1 addition & 1 deletion test/parallel/test-net-server-max-connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-unshift-empty-chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-zlib-brotli-flush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-zlib-flush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-zlib-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down