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,lib: enable strict equality lint rule #12446

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.yaml
Expand Up @@ -34,6 +34,7 @@ rules:
# Best Practices
# http://eslint.org/docs/rules/#best-practices
dot-location: [2, property]
eqeqeq: [2, smart]
no-fallthrough: 2
no-global-assign: 2
no-multi-spaces: 2
Expand Down
1 change: 1 addition & 0 deletions lib/_debugger.js
Expand Up @@ -1391,6 +1391,7 @@ Interface.prototype.setBreakpoint = function(script, line,
};
} else {
// setBreakpoint('scriptname')
// eslint-disable-next-line eqeqeq
if (script != +script && !this.client.scripts[script]) {
var scripts = this.client.scripts;
for (var id in scripts) {
Expand Down
3 changes: 3 additions & 0 deletions lib/assert.js
Expand Up @@ -112,6 +112,7 @@ assert.ok = ok;
// assert.equal(actual, expected, message_opt);
/* eslint-disable no-restricted-properties */
assert.equal = function equal(actual, expected, message) {
// eslint-disable-next-line eqeqeq
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
};

Expand All @@ -120,6 +121,7 @@ assert.equal = function equal(actual, expected, message) {
// assert.notEqual(actual, expected, message_opt);

assert.notEqual = function notEqual(actual, expected, message) {
// eslint-disable-next-line eqeqeq
if (actual == expected) {
fail(actual, expected, message, '!=', assert.notEqual);
}
Expand Down Expand Up @@ -176,6 +178,7 @@ function _deepEqual(actual, expected, strict, memos) {
// (determined by typeof value !== 'object'),
// or null, equivalence is determined by === or ==.
if (isNullOrNonObj(actual) && isNullOrNonObj(expected)) {
// eslint-disable-next-line eqeqeq
return strict ? actual === expected : actual == expected;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/buffer.js
Expand Up @@ -192,6 +192,7 @@ Buffer.allocUnsafeSlow = function(size) {
// If --zero-fill-buffers command line argument is set, a zero-filled
// buffer is returned.
function SlowBuffer(length) {
// eslint-disable-next-line eqeqeq
if (+length != length)
length = 0;
assertSize(+length);
Expand Down Expand Up @@ -306,7 +307,7 @@ function fromObject(obj) {
return b;
}

if (obj != undefined) {
if (obj != null) {
if (obj.length !== undefined || isAnyArrayBuffer(obj.buffer)) {
if (typeof obj.length !== 'number' || obj.length !== obj.length) {
return new FastBuffer();
Expand Down
1 change: 1 addition & 0 deletions lib/fs.js
Expand Up @@ -1161,6 +1161,7 @@ fs.chownSync = function(path, uid, gid) {

// converts Date or number to a fractional UNIX timestamp
function toUnixTimestamp(time) {
// eslint-disable-next-line eqeqeq
if (typeof time === 'string' && +time == time) {
return +time;
}
Expand Down
1 change: 1 addition & 0 deletions lib/internal/process.js
Expand Up @@ -169,6 +169,7 @@ function setupKillAndExit() {
process.kill = function(pid, sig) {
var err;

// eslint-disable-next-line eqeqeq
if (pid != (pid | 0)) {
throw new TypeError('invalid pid');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/url.js
Expand Up @@ -1365,7 +1365,7 @@ function getPathFromURLPosix(url) {
}

function getPathFromURL(path) {
if (path == undefined || !path[searchParams] ||
if (path == null || !path[searchParams] ||
!path[searchParams][searchParams]) {
return path;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/net.js
Expand Up @@ -179,9 +179,10 @@ function Socket(options) {
} else if (options.fd !== undefined) {
this._handle = createHandle(options.fd);
this._handle.open(options.fd);
// options.fd can be string (since it user-defined),
// options.fd can be string (since it is user-defined),
// so changing this to === would be semver-major
// See: https://github.com/nodejs/node/pull/11513
// eslint-disable-next-line eqeqeq
if ((options.fd == 1 || options.fd == 2) &&
(this._handle instanceof Pipe) &&
process.platform === 'win32') {
Expand Down Expand Up @@ -748,7 +749,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {

// If it was entirely flushed, we can write some more right now.
// However, if more is left in the queue, then wait until that clears.
if (req.async && this._handle.writeQueueSize != 0)
if (req.async && this._handle.writeQueueSize !== 0)
req.cb = cb;
else
cb();
Expand Down