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

Update dependencies and fix ESLint warnings accordingly #2433

Merged
merged 8 commits into from Feb 1, 2018
Merged
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -14,7 +14,7 @@ module.exports = {
"no-console": warning,
"no-var": 2,
"no-debugger": warning,
"indent": [warning, 2, {"SwitchCase": 1}],
"indent": [warning, 2, {"SwitchCase": 1, "ignoreComments": true}],
"max-len": [warning, 100, 2],
"prefer-const": warning,
"no-fallthrough": warning
Expand Down
21 changes: 11 additions & 10 deletions package.json
Expand Up @@ -20,37 +20,38 @@
"readable-stream": "2.3.3",
"safe-buffer": "^5.1.1",
"tildify": "1.2.0",
"uuid": "^3.1.0",
"uuid": "^3.2.1",
"v8flags": "^3.0.1"
},
"devDependencies": {
"JSONStream": "^1.3.2",
"async": "^0.9.0",
"async": "^2.6.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^5.0.4",
"babel-eslint": "^8.2.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-lodash": "3.3.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"chai": "^3.5.0",
"coveralls": "~2.11.1",
"chai": "^4.1.2",
"coveralls": "~3.0.0",
"dockerode": "^2.5.3",
"eslint": "2.2.0",
"eslint-plugin-import": "^1.8.0",
"eslint": "4.16.0",
"eslint-plugin-import": "^2.8.0",
"estraverse": "^4.2.0",
"istanbul": "^0.4.5",
"json-loader": "^0.5.7",
"mariasql": "^0.2.6",
"mocha": "^3.1.2",
"mocha": "^3.5.3",
"mock-fs": "^4.4.2",
"mssql": "^4.1.0",
"mysql": "^2.15.0",
"mysql2": "^1.5.1",
"pg": "^7.4.1",
"pg-query-stream": "^1.1.1",
"rimraf": "^2.6.2",
"sinon": "^1.10.0",
"sinon": "^4.2.2",
"sinon-chai": "^2.14.0",
"source-map-support": "^0.5.0",
"source-map-support": "^0.5.3",
"sqlite3": "^3.1.13",
"tap-spec": "^4.1.1",
"tape": "^4.8.0",
Expand Down
2 changes: 1 addition & 1 deletion src/dialects/mssql/index.js
Expand Up @@ -67,7 +67,7 @@ assign(Client_MSSQL.prototype, {
},

wrapIdentifierImpl(value) {
return (value !== '*' ? `[${value.replace(/\[/g, '\[')}]` : '*')
return (value !== '*' ? `[${value.replace(/\[/g, '[')}]` : '*')
},

// Get a raw connection, called by the `pool` whenever a new
Expand Down
4 changes: 2 additions & 2 deletions src/dialects/mssql/query/compiler.js
Expand Up @@ -23,7 +23,7 @@ assign(QueryCompiler_MSSQL.prototype, {
select() {
const sql = this.with();
const statements = components.map(component =>
this[component](this)
this[component](this)
);
return sql + compact(statements).join(' ');
},
Expand Down Expand Up @@ -87,7 +87,7 @@ assign(QueryCompiler_MSSQL.prototype, {
return {
sql: this.with() + `update ${top ? top + ' ' : ''}${this.tableName}` +
' set ' + updates.join(', ') +
(returning ? ` ${this._returning('update', returning)}` : '') +
(returning ? ` ${this._returning('update', returning)}` : '') +
(join ? ` from ${this.tableName} ${join}` : '') +
(where ? ` ${where}` : '') +
(order ? ` ${order}` : '') +
Expand Down
2 changes: 1 addition & 1 deletion src/dialects/oracle/schema/columncompiler.js
Expand Up @@ -69,7 +69,7 @@ assign(ColumnCompiler_Oracle.prototype, {
allowed = uniq(allowed);
const maxLength = (allowed || []).reduce((maxLength, name) =>
Math.max(maxLength, String(name).length)
, 1);
, 1);

// implicitly add the enum values as checked values
this.columnBuilder._modifiers.checkIn = [allowed];
Expand Down
8 changes: 5 additions & 3 deletions src/dialects/oracledb/query/compiler.js
Expand Up @@ -23,7 +23,7 @@ _.assign(Oracledb_Compiler.prototype, {
return this._addReturningToSqlAndConvert('insert into ' +
this.tableName +
' (' + this.formatter.wrap(this.single.returning) + ') values (default)',
outBinding[0], this.tableName, returning);
outBinding[0], this.tableName, returning);
}

if (_.isEmpty(this.single.insert) && typeof this.single.insert !== 'function') {
Expand All @@ -37,14 +37,14 @@ _.assign(Oracledb_Compiler.prototype, {
if (_.isString(insertData)) {
return this._addReturningToSqlAndConvert('insert into ' +
this.tableName + ' ' + insertData, outBinding[0],
this.tableName, returning);
this.tableName, returning);
}

if (insertData.values.length === 1) {
return this._addReturningToSqlAndConvert('insert into ' +
this.tableName + ' (' + this.formatter.columnize(insertData.columns) +
') values (' + this.formatter.parameterize(insertData.values[0]) + ')',
outBinding[0], this.tableName, returning);
outBinding[0], this.tableName, returning);
}

const insertDefaultsOnly = (insertData.columns.length === 0);
Expand All @@ -67,6 +67,8 @@ _.assign(Oracledb_Compiler.prototype, {

let returningClause = '';
let intoClause = '';
// ToDo review if this code is still needed or could be dropped
// eslint-disable-next-line no-unused-vars
let usingClause = '';
let outClause = '';

Expand Down
42 changes: 21 additions & 21 deletions src/dialects/sqlite3/schema/ddl.js
Expand Up @@ -199,28 +199,28 @@ assign(SQLite3_DDL.prototype, {
return this.client.transaction(trx => {
this.trx = trx
return Promise.all(columns.map(column => this.getColumn(column)))
.bind(this)
.then(this.getTableSql)
.then(function(sql) {
const createTable = sql[0];
let newSql = createTable.sql;
columns.forEach(column => {
const a = this.client.wrapIdentifier(column);
newSql = this._doReplace(newSql, a, '');
})
if (sql === newSql) {
throw new Error('Unable to find the column to change');
}
return Promise.bind(this)
.then(this.createTempTable(createTable))
.then(this.copyData)
.then(this.dropOriginal)
.then(function() {
return this.trx.raw(newSql);
.bind(this)
.then(this.getTableSql)
.then(function(sql) {
const createTable = sql[0];
let newSql = createTable.sql;
columns.forEach(column => {
const a = this.client.wrapIdentifier(column);
newSql = this._doReplace(newSql, a, '');
})
.then(this.reinsertData(row => omit(row, ...columns)))
.then(this.dropTempTable);
})
if (sql === newSql) {
throw new Error('Unable to find the column to change');
}
return Promise.bind(this)
.then(this.createTempTable(createTable))
.then(this.copyData)
.then(this.dropOriginal)
.then(function() {
return this.trx.raw(newSql);
})
.then(this.reinsertData(row => omit(row, ...columns)))
.then(this.dropTempTable);
})
}, {connection: this.connection})
})

Expand Down
4 changes: 2 additions & 2 deletions src/query/compiler.js
Expand Up @@ -185,8 +185,8 @@ assign(QueryCompiler.prototype, {
if (sql.length === 0) sql = ['*'];
return `select ${distinct ? 'distinct ' : ''}` +
sql.join(', ') + (this.tableName
? ` from ${this.single.only ? 'only ' : ''}${this.tableName}`
: '');
? ` from ${this.single.only ? 'only ' : ''}${this.tableName}`
: '');
},

aggregate(stmt) {
Expand Down
4 changes: 2 additions & 2 deletions src/query/string.js
@@ -1,6 +1,6 @@
/*eslint max-len: 0, no-var:0 */

export const charsRegex = /[\0\b\t\n\r\x1a\"\'\\]/g; // eslint-disable-line no-control-regex
export const charsRegex = /[\0\b\t\n\r\x1a"'\\]/g; // eslint-disable-line no-control-regex
export const charsMap = {
'\0': '\\0',
'\b': '\\b',
Expand Down Expand Up @@ -153,7 +153,7 @@ function convertTimezone(tz) {
if (tz === 'Z') {
return 0;
}
const m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/);
const m = tz.match(/([+\-\s])(\d\d):?(\d\d)?/);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I wonder why eslint left \-escaping there.

if (m) {
return (m[1] == '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60;
}
Expand Down
18 changes: 9 additions & 9 deletions src/runner.js
Expand Up @@ -45,18 +45,18 @@ assign(Runner.prototype, {
// If there are any "error" listeners, we fire an error event
// and then re-throw the error to be eventually handled by
// the promise chain. Useful if you're wrapping in a custom `Promise`.
.catch(function(err) {
if (runner.builder._events && runner.builder._events.error) {
runner.builder.emit('error', err);
}
throw err;
})
.catch(function(err) {
if (runner.builder._events && runner.builder._events.error) {
runner.builder.emit('error', err);
}
throw err;
})

// Fire a single "end" event on the builder when
// all queries have successfully completed.
.tap(function() {
runner.builder.emit('end');
})
.tap(function() {
runner.builder.emit('end');
})

},

Expand Down
52 changes: 26 additions & 26 deletions src/transaction.js
Expand Up @@ -35,27 +35,27 @@ export default class Transaction extends EventEmitter {
init.then(() => {
return makeTransactor(this, connection, trxClient)
})
.then((transactor) => {
.then((transactor) => {
// If we've returned a "thenable" from the transaction container, assume
// the rollback and commit are chained to this object's success / failure.
// Directly thrown errors are treated as automatic rollbacks.
let result
try {
result = container(transactor)
} catch (err) {
result = Promise.reject(err)
}
if (result && result.then && typeof result.then === 'function') {
result.then((val) => {
return transactor.commit(val)
})
.catch((err) => {
return transactor.rollback(err)
})
}
return null;
})
.catch((e) => this._rejecter(e))
let result
try {
result = container(transactor)
} catch (err) {
result = Promise.reject(err)
}
if (result && result.then && typeof result.then === 'function') {
result.then((val) => {
return transactor.commit(val)
})
.catch((err) => {
return transactor.rollback(err)
})
}
return null;
})
.catch((e) => this._rejecter(e))

return new Promise((resolver, rejecter) => {
this._resolver = resolver
Expand Down Expand Up @@ -148,14 +148,14 @@ export default class Transaction extends EventEmitter {
acquireConnection(client, config, txid) {
const configConnection = config && config.connection
return Promise.try(() => configConnection || client.acquireConnection())
.disposer(function(connection) {
if (!configConnection) {
debug('%s: releasing connection', txid)
client.releaseConnection(connection)
} else {
debug('%s: not releasing external connection', txid)
}
})
.disposer(function(connection) {
if (!configConnection) {
debug('%s: releasing connection', txid)
client.releaseConnection(connection)
} else {
debug('%s: not releasing external connection', txid)
}
})
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/util/batchInsert.js
Expand Up @@ -17,7 +17,7 @@ export default function batchInsert(client, tableName, batch, chunkSize = 1000)

autoTransaction = true;
client.transaction(resolve)
.catch(reject);
.catch(reject);
});

const wrapper = assign(new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/dialects/oracledb.js
Expand Up @@ -38,7 +38,7 @@ describe("OracleDb externalAuth", function() {
});

after(function() {
sinon.restore(knexInstance.client.driver.getConnection);
knexInstance.client.driver.getConnection.restore();
});

});
Expand Down