Skip to content

Commit a1daf46

Browse files
committed
eslint: Update to v4 and fix indentation errors
1 parent f9867da commit a1daf46

File tree

6 files changed

+81
-92
lines changed

6 files changed

+81
-92
lines changed

lib/Connection.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ const Connection = require('mysql/lib/Connection');
1010
* passed to {@link PoolPlus~transactionHandler|`transactionHandler`}.
1111
*/
1212

13-
/**
14-
* The same as the `query` method except when not passed a callback it returns
15-
* a promise that resolves with the results of the query.
16-
*
17-
* @param {string|Object} sql - An SqlString or options object.
18-
* @param {Array} [values] - Values to replace placeholders in the SqlString.
19-
* @param {module:mysql-plus~queryCallback} [cb] - An optional callback that gets called with
20-
* the results of the query.
21-
* @return {?Promise} If the `cb` parameter is omitted, a promise that will resolve with the results
22-
* of the query is returned.
23-
* @see {@link https://github.com/mysqljs/mysql#performing-queries}
24-
*
25-
* @example
26-
* connection.pquery('SELECT * FROM `books` WHERE `author` = "David"')
27-
* .then((results) => {
28-
* // results will contain the results of the query
29-
* })
30-
* .catch((error) => {
31-
* // error will be the Error that occurred during the query
32-
* });
33-
*/
13+
/**
14+
* The same as the `query` method except when not passed a callback it returns
15+
* a promise that resolves with the results of the query.
16+
*
17+
* @param {string|Object} sql - An SqlString or options object.
18+
* @param {Array} [values] - Values to replace placeholders in the SqlString.
19+
* @param {module:mysql-plus~queryCallback} [cb] - An optional callback that gets called with
20+
* the results of the query.
21+
* @return {?Promise} If the `cb` parameter is omitted, a promise that will resolve with the results
22+
* of the query is returned.
23+
* @see {@link https://github.com/mysqljs/mysql#performing-queries}
24+
*
25+
* @example
26+
* connection.pquery('SELECT * FROM `books` WHERE `author` = "David"')
27+
* .then((results) => {
28+
* // results will contain the results of the query
29+
* })
30+
* .catch((error) => {
31+
* // error will be the Error that occurred during the query
32+
* });
33+
*/
3434
Connection.prototype.pquery = function pquery(sql, values, cb) {
3535
if (typeof (cb || values || sql) === 'function') {
3636
return this.query(sql, values, cb);

lib/MySQLTable.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -101,33 +101,33 @@ class MySQLTable {
101101
);
102102
}
103103

104-
/**
105-
* Checks if rows in the table exist.
106-
*
107-
* @param {string} sqlString - SQL that specifies rows to check for existence.<br>
108-
* The first example shows how this parameter is used in the query.
109-
* @param {Array} [values] - Values to replace the placeholders in `sqlString`.
110-
* @param {module:mysql-plus~queryCallback} [cb] - A callback that gets called with
111-
* the results of the query where the `results` will be either `true` or `false`.
112-
* @returns {?Promise} If the `cb` parameter is omitted, a promise that will
113-
* resolve with either `true` or `false` is returned.
114-
*
115-
* @example <caption>Using a promise</caption>
116-
* userTable.exists('WHERE `id` > 10')
117-
* .then(exists => console.log(exists)); // true or false
118-
*
119-
* // SELECT EXISTS (
120-
* // SELECT 1 FROM `user`
121-
* // WHERE `id` > 10 # This is where `sqlString` gets inserted
122-
* // LIMIT 1
123-
* // )
124-
*
125-
* @example <caption>Using a callback and the `values` argument</caption>
126-
* userTable.exists('WHERE `id` = ?', [10], (err, exists) => {
127-
* if (err) throw err;
128-
* console.log(exists); // true or false
129-
* });
130-
*/
104+
/**
105+
* Checks if rows in the table exist.
106+
*
107+
* @param {string} sqlString - SQL that specifies rows to check for existence.<br>
108+
* The first example shows how this parameter is used in the query.
109+
* @param {Array} [values] - Values to replace the placeholders in `sqlString`.
110+
* @param {module:mysql-plus~queryCallback} [cb] - A callback that gets called with
111+
* the results of the query where the `results` will be either `true` or `false`.
112+
* @returns {?Promise} If the `cb` parameter is omitted, a promise that will
113+
* resolve with either `true` or `false` is returned.
114+
*
115+
* @example <caption>Using a promise</caption>
116+
* userTable.exists('WHERE `id` > 10')
117+
* .then(exists => console.log(exists)); // true or false
118+
*
119+
* // SELECT EXISTS (
120+
* // SELECT 1 FROM `user`
121+
* // WHERE `id` > 10 # This is where `sqlString` gets inserted
122+
* // LIMIT 1
123+
* // )
124+
*
125+
* @example <caption>Using a callback and the `values` argument</caption>
126+
* userTable.exists('WHERE `id` = ?', [10], (err, exists) => {
127+
* if (err) throw err;
128+
* console.log(exists); // true or false
129+
* });
130+
*/
131131
exists(sqlString, values, cb) {
132132
if (typeof values === 'function') {
133133
cb = values;

lib/PoolPlus.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,25 @@ class PoolPlus extends Pool {
108108
return new MySQLTable(name, schema, this);
109109
}
110110

111-
/**
112-
* Syncs the defined tables to the database by creating new tables and dropping
113-
* or migrating existing tables (depending on the migration setting).
114-
*
115-
* Generally, this should only be called once when starting up a server.
116-
*
117-
* __Warning:__ If an error occurs while syncing, the database will be in an unknown state.
118-
* Always keep a backup of your database so you can restore it to the latest working state.
119-
*
120-
* @param {function} cb - A callback that is called once all defined table schemas have been synced to the
121-
* database. If an error occured, the first argument passed to the callback will be the error object.
122-
* @returns {void}
123-
*
124-
* @example
125-
* pool.sync((err) => {
126-
* if (err) throw err;
127-
* // Now do something such as start an HTTP server
128-
* });
129-
*/
111+
/**
112+
* Syncs the defined tables to the database by creating new tables and dropping
113+
* or migrating existing tables (depending on the migration setting).
114+
*
115+
* Generally, this should only be called once when starting up a server.
116+
*
117+
* __Warning:__ If an error occurs while syncing, the database will be in an unknown state.
118+
* Always keep a backup of your database so you can restore it to the latest working state.
119+
*
120+
* @param {function} cb - A callback that is called once all defined table schemas have been synced to the
121+
* database. If an error occured, the first argument passed to the callback will be the error object.
122+
* @returns {void}
123+
*
124+
* @example
125+
* pool.sync((err) => {
126+
* if (err) throw err;
127+
* // Now do something such as start an HTTP server
128+
* });
129+
*/
130130
sync(cb) {
131131
var tablesRemaining = this._tables.size;
132132
if (!tablesRemaining) {

lib/TableDefinition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class TableDefinition {
106106
alterOperations.sort(Operation.sorter);
107107
operations.push(Operation.create(
108108
Operation.Types.ALTER_TABLE,
109-
'ALTER TABLE ' + this._escapedName + spacer + alterOperations.map(op => op.sql).join(',' + spacer)
109+
'ALTER TABLE ' + this._escapedName + spacer + alterOperations.map(op => op.sql).join(',' + spacer)
110110
));
111111
}
112112

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"devDependencies": {
2424
"coveralls": "^2.11.6",
2525
"es6-callback-manager": "^2.0.0",
26-
"eslint": "^3.15.0",
26+
"eslint": "^4.1.1",
2727
"grunt": "^1.0.1",
2828
"grunt-env": "^0.4.4",
29-
"grunt-eslint": "^19.0.0",
29+
"grunt-eslint": "^20.0.0",
3030
"grunt-jsdoc-to-markdown": "^3.0.0",
3131
"grunt-mocha-istanbul": "^5.0.1",
3232
"grunt-mocha-test": "^0.13.2",

test/unit/PoolPlus.test.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,15 @@ describe('PoolPlus', () => {
309309
trxnDone(null, 'success!');
310310
});
311311
});
312-
})
313-
.then(result => {
312+
}).then(result => {
314313
result.should.equal('success!');
315314
return pool.pquery('SELECT * from mysql_plus_transaction_test')
316315
.then(rows => {
317316
rows.should.have.length(1);
318317
rows[0].id.should.equal(2);
319318
done();
320319
});
321-
})
322-
.catch(done);
320+
}).catch(done);
323321
});
324322

325323
it('should rollback changes if an errors occur', done => {
@@ -343,20 +341,17 @@ describe('PoolPlus', () => {
343341
trxnDone(null, 'success!');
344342
});
345343
});
346-
})
347-
.then(result => {
344+
}).then(result => {
348345
done(new Error(result));
349-
})
350-
.catch(err => {
346+
}).catch(err => {
351347
err.code.should.equal('ER_BAD_FIELD_ERROR');
352348
return pool.pquery('SELECT * from mysql_plus_transaction_test')
353349
.then(rows => {
354350
rows.should.have.length(1);
355351
rows[0].id.should.equal(2);
356352
done();
357353
});
358-
})
359-
.catch(done);
354+
}).catch(done);
360355
});
361356

362357
});
@@ -379,8 +374,7 @@ describe('PoolPlus', () => {
379374
result.affectedRows.should.equal(1);
380375
return 'success!';
381376
});
382-
})
383-
.then(result => {
377+
}).then(result => {
384378
result.should.equal('success!');
385379
return pool.pquery('SELECT * FROM mysql_plus_transaction_test')
386380
.then(rows => {
@@ -401,11 +395,9 @@ describe('PoolPlus', () => {
401395
result.affectedRows.should.equal(1);
402396
return 'success!';
403397
});
404-
})
405-
.then(result => {
398+
}).then(result => {
406399
throw new Error(result);
407-
})
408-
.catch(err => {
400+
}).catch(err => {
409401
err.code.should.equal('ER_BAD_FIELD_ERROR');
410402
return pool.pquery('SELECT * FROM mysql_plus_transaction_test')
411403
.then(rows => {
@@ -501,20 +493,17 @@ describe('PoolPlus', () => {
501493
it('should reject with an error', done => {
502494
pool.transaction(trxn => {
503495
return trxn.pquery('INSERT INTO mysql_plus_transaction_test VALUES (3)');
504-
})
505-
.then(result => {
496+
}).then(result => {
506497
done(new Error(result));
507-
})
508-
.catch(err => {
498+
}).catch(err => {
509499
err.should.equal(error);
510500
return pool.pquery('SELECT * FROM mysql_plus_transaction_test')
511501
.then(rows => {
512502
rows.should.have.length(1);
513503
rows[0].id.should.equal(2);
514504
done();
515505
});
516-
})
517-
.catch(done);
506+
}).catch(done);
518507
});
519508

520509
});

0 commit comments

Comments
 (0)