Skip to content

Commit 2aa8b6c

Browse files
committed
lint: prefer triple equal operator
1 parent c19c867 commit 2aa8b6c

File tree

9 files changed

+21
-20
lines changed

9 files changed

+21
-20
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"rules": {
66
"comma-dangle": [2, "never"],
77
"consistent-return": 2,
8+
"eqeqeq": [2, "allow-null"],
89
"indent": [2, 2, { "VariableDeclarator": 2, "SwitchCase": 1 }],
910
"new-parens": 2,
1011
"no-cond-assign": 2,

lib/Connection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Connection.prototype.query = function query(sql, values, cb) {
201201
var query = Connection.createQuery(sql, values, cb);
202202
query._connection = this;
203203

204-
if (!(typeof sql == 'object' && 'typeCast' in sql)) {
204+
if (!(typeof sql === 'object' && 'typeCast' in sql)) {
205205
query.typeCast = this.config.typeCast;
206206
}
207207

@@ -281,7 +281,7 @@ Connection.prototype.escapeId = function escapeId(value) {
281281
};
282282

283283
Connection.prototype.format = function(sql, values) {
284-
if (typeof this.config.queryFormat == 'function') {
284+
if (typeof this.config.queryFormat === 'function') {
285285
return this.config.queryFormat.call(this, sql, values, this.config.timezone);
286286
}
287287
return SqlString.format(sql, values, this.config.stringifyObjects, this.config.timezone);

lib/ConnectionConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function ConnectionConfig(options) {
3838
? true
3939
: options.typeCast;
4040

41-
if (this.timezone[0] == ' ') {
41+
if (this.timezone[0] === ' ') {
4242
// "+" is a url encoded char for space so it
4343
// gets translated to space when giving a
4444
// connection string..

lib/Pool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Pool.prototype.releaseConnection = function releaseConnection(connection) {
159159
Pool.prototype.end = function (cb) {
160160
this._closed = true;
161161

162-
if (typeof cb != 'function') {
162+
if (typeof cb !== 'function') {
163163
cb = function (err) {
164164
if (err) throw err;
165165
};

lib/protocol/Auth.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ Auth.hashPassword = function(password) {
4040
nr2 = [0x1234, 0x5671],
4141
result = new Buffer(8);
4242

43-
if (typeof password == 'string'){
43+
if (typeof password === 'string'){
4444
password = new Buffer(password);
4545
}
4646

4747
for (var i = 0; i < password.length; i++) {
4848
var c = password[i];
49-
if (c == 32 || c == 9) {
49+
if (c === 32 || c === 9) {
5050
// skip space in password
5151
continue;
5252
}
@@ -109,12 +109,12 @@ Auth.fmt32 = function(x){
109109
var a = x[0].toString(16),
110110
b = x[1].toString(16);
111111

112-
if (a.length == 1) a = '000'+a;
113-
if (a.length == 2) a = '00'+a;
114-
if (a.length == 3) a = '0'+a;
115-
if (b.length == 1) b = '000'+b;
116-
if (b.length == 2) b = '00'+b;
117-
if (b.length == 3) b = '0'+b;
112+
if (a.length === 1) a = '000'+a;
113+
if (a.length === 2) a = '00'+a;
114+
if (a.length === 3) a = '0'+a;
115+
if (b.length === 1) b = '000'+b;
116+
if (b.length === 2) b = '00'+b;
117+
if (b.length === 3) b = '0'+b;
118118
return '' + a + '/' + b;
119119
};
120120

lib/protocol/packets/Field.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Field.prototype.geometry = function () {
2727

2828
function typeToString(t) {
2929
for (var k in Types) {
30-
if (Types[k] == t) return k;
30+
if (Types[k] === t) return k;
3131
}
3232

3333
return undefined;

lib/protocol/packets/HandshakeInitializationPacket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ HandshakeInitializationPacket.prototype.write = function(writer) {
8989

9090
HandshakeInitializationPacket.prototype.scrambleBuff = function() {
9191
var buffer = new Buffer(this.scrambleBuff1.length +
92-
(typeof this.scrambleBuff2 != 'undefined' ? this.scrambleBuff2.length : 0));
92+
(typeof this.scrambleBuff2 !== 'undefined' ? this.scrambleBuff2.length : 0));
9393

9494
this.scrambleBuff1.copy(buffer);
95-
if (typeof this.scrambleBuff2 != 'undefined') {
95+
if (typeof this.scrambleBuff2 !== 'undefined') {
9696
this.scrambleBuff2.copy(buffer, this.scrambleBuff1.length);
9797
}
9898

lib/protocol/packets/RowDataPacket.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function parse(parser, fieldPackets, typeCast, nestTables, connection) {
2929
var fieldPacket = fieldPackets[i];
3030
var value;
3131

32-
if (typeof typeCast == 'function') {
32+
if (typeof typeCast === 'function') {
3333
value = typeCast.apply(connection, [ new Field({ packet: fieldPacket, parser: parser }), next ]);
3434
} else {
3535
value = (typeCast)
@@ -39,7 +39,7 @@ function parse(parser, fieldPackets, typeCast, nestTables, connection) {
3939
: parser.parseLengthCodedString() );
4040
}
4141

42-
if (typeof nestTables == 'string' && nestTables.length) {
42+
if (typeof nestTables === 'string' && nestTables.length) {
4343
this[fieldPacket.table + nestTables + fieldPacket.name] = value;
4444
} else if (nestTables) {
4545
this[fieldPacket.table] = this[fieldPacket.table] || {};
@@ -93,12 +93,12 @@ function typeCast(field, parser, timeZone, supportBigNumbers, bigNumberStrings,
9393
case Types.FLOAT:
9494
case Types.DOUBLE:
9595
numberString = parser.parseLengthCodedString();
96-
return (numberString === null || (field.zeroFill && numberString[0] == '0'))
96+
return (numberString === null || (field.zeroFill && numberString[0] === '0'))
9797
? numberString : Number(numberString);
9898
case Types.NEWDECIMAL:
9999
case Types.LONGLONG:
100100
numberString = parser.parseLengthCodedString();
101-
return (numberString === null || (field.zeroFill && numberString[0] == '0'))
101+
return (numberString === null || (field.zeroFill && numberString[0] === '0'))
102102
? numberString
103103
: ((supportBigNumbers && (bigNumberStrings || (Number(numberString) >= IEEE_754_BINARY_64_PRECISION) || Number(numberString) <= -IEEE_754_BINARY_64_PRECISION))
104104
? numberString

test/unit/pool/test-destroy-connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ server.listen(common.fakeServerPort, function (err) {
1414
assert.strictEqual(connection, pool._allConnections[0]);
1515
connection.destroy();
1616

17-
assert.ok(pool._allConnections.length == 0);
17+
assert.strictEqual(pool._allConnections.length, 0);
1818
assert.ok(!connection._pool);
1919

2020
assert.doesNotThrow(function () { connection.release(); });

0 commit comments

Comments
 (0)