Skip to content

Commit 16e4c0e

Browse files
committed
lint: sync rules with mysqljs/mysql
1 parent 8cc043d commit 16e4c0e

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

.eslintrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
"rules": {
66
"comma-dangle": [2, "never"],
77
"consistent-return": 2,
8-
"indent": ["error", 2, {"SwitchCase": 1}],
8+
"eqeqeq": [2, "allow-null"],
9+
"indent": [2, 2, { "VariableDeclarator": 2, "SwitchCase": 1 }],
910
"key-spacing": [2, { "align": { "beforeColon": true, "afterColon": true, "on": "colon" } }],
11+
"keyword-spacing": 2,
12+
"new-parens": 2,
1013
"no-cond-assign": 2,
1114
"no-constant-condition": 2,
1215
"no-control-regex": 2,
@@ -23,6 +26,7 @@
2326
"no-inner-declarations": 2,
2427
"no-invalid-regexp": 2,
2528
"no-irregular-whitespace": 2,
29+
"no-multiple-empty-lines": [2, { "max": 1 }],
2630
"no-negated-in-lhs": 2,
2731
"no-obj-calls": 2,
2832
"no-regex-spaces": 2,
@@ -31,7 +35,9 @@
3135
"no-unexpected-multiline": 2,
3236
"no-unreachable": 2,
3337
"no-unused-vars": 2,
38+
"quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
3439
"semi": [2, "always"],
40+
"semi-spacing": 2,
3541
"space-infix-ops": 2,
3642
"use-isnan": 2,
3743
"valid-jsdoc": 2,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ If you feel the need to escape queries by yourself, you can also use the escapin
9292
function directly:
9393

9494
```js
95-
var sql = 'SELECT * FROM posts WHERE title=' + SqlString.escape("Hello MySQL");
95+
var sql = 'SELECT * FROM posts WHERE title=' + SqlString.escape('Hello MySQL');
9696
console.log(sql); // SELECT * FROM posts WHERE title='Hello MySQL'
9797
```
9898

lib/SqlString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ SqlString.dateToString = function dateToString(date, timeZone) {
155155
};
156156

157157
SqlString.bufferToString = function bufferToString(buffer) {
158-
return "X" + escapeString(buffer.toString('hex'));
158+
return 'X' + escapeString(buffer.toString('hex'));
159159
};
160160

161161
SqlString.objectToValues = function objectToValues(object, timeZone) {
@@ -212,7 +212,7 @@ function convertTimezone(tz) {
212212

213213
var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/);
214214
if (m) {
215-
return (m[1] == '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60;
215+
return (m[1] === '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60;
216216
}
217217
return false;
218218
}

test/unit/test-SqlString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ test('SqlString.escapeId', {
2828
},
2929

3030
'arrays are turned into lists': function() {
31-
assert.equal(SqlString.escapeId(['a', 'b', 't.c']), "`a`, `b`, `t`.`c`");
31+
assert.equal(SqlString.escapeId(['a', 'b', 't.c']), '`a`, `b`, `t`.`c`');
3232
},
3333

3434
'nested arrays are flattened': function() {
35-
assert.equal(SqlString.escapeId(['a', ['b', ['t.c']]]), "`a`, `b`, `t`.`c`");
35+
assert.equal(SqlString.escapeId(['a', ['b', ['t.c']]]), '`a`, `b`, `t`.`c`');
3636
}
3737
});
3838

0 commit comments

Comments
 (0)