Fix linting errors

This commit is contained in:
Amir Jafarian 2016-04-09 15:00:28 -04:00
parent fc33ced470
commit 70277da109
7 changed files with 15 additions and 19 deletions

View File

@ -1,7 +1,7 @@
{
"extends": "loopback",
"rules": {
"max-len": ["error", 80, 4, {
"max-len": ["error", 90, 4, {
"ignoreComments": true,
"ignoreUrls": true,
"ignorePattern": "^\\s*var\\s.+=\\s*(require\\s*\\()|(/)"

View File

@ -407,7 +407,8 @@ SQLConnector.prototype.execute = function(sql, params, options, callback) {
options: options,
};
this.notifyObserversAround('execute', context, function(context, done) {
self.executeSQL(context.req.sql, context.req.params, context.options, function(err, info) {
self.executeSQL(context.req.sql, context.req.params, context.options,
function(err, info) {
if (err) {
debug('Error: %j %j %j', err, context.req.sql, context.req.params);
}
@ -718,7 +719,8 @@ SQLConnector.prototype.buildWhere = function(model, where) {
* @param {*} propertyValue Property value
* @returns {ParameterizedSQL} The SQL expression
*/
SQLConnector.prototype.buildExpression = function(columnName, operator, columnValue, propertyValue) {
SQLConnector.prototype.buildExpression =
function(columnName, operator, columnValue, propertyValue) {
function buildClause(columnValue, separator, grouping) {
var values = [];
for (var i = 0, n = columnValue.length; i < n; i++) {
@ -839,10 +841,12 @@ SQLConnector.prototype._buildWhere = function(model, where) {
debug('Unknown property %s is skipped for model %s', key, model);
continue;
}
/* eslint-disable one-var */
var columnName = self.columnEscaped(model, key);
var expression = where[key];
var columnValue;
var sqlExp;
/* eslint-enable one-var */
if (expression === null || expression === undefined) {
stmt.merge(columnName + ' IS NULL');
} else if (expression && expression.constructor === Object) {
@ -1120,7 +1124,6 @@ SQLConnector.prototype.buildSelect = function(model, filter, options) {
);
if (filter) {
if (filter.where) {
var whereStmt = this.buildWhere(model, filter.where);
selectStmt.merge(whereStmt);
@ -1134,7 +1137,6 @@ SQLConnector.prototype.buildSelect = function(model, filter, options) {
selectStmt = this.applyPagination(
model, selectStmt, filter);
}
}
return this.parameterize(selectStmt);
};
@ -1145,7 +1147,8 @@ SQLConnector.prototype.buildSelect = function(model, filter, options) {
* @param {object} rowData An object representing the row data from DB
* @returns {object} Model data object
*/
SQLConnector.prototype.fromRow = SQLConnector.prototype.fromDatabase = function(model, rowData) {
SQLConnector.prototype.fromRow = SQLConnector.prototype.fromDatabase =
function(model, rowData) {
if (rowData == null) {
return rowData;
}

View File

@ -13,7 +13,8 @@
},
"main": "index.js",
"scripts": {
"pretest": "eslint .",
"lint": "eslint .",
"posttest": "npm run lint",
"test": "mocha"
},
"license": "MIT",

View File

@ -43,5 +43,4 @@ describe('sql connector', function() {
done();
});
});
});

View File

@ -214,8 +214,7 @@ TestConnector.prototype.executeSQL = function(sql, params, options, callback) {
debug('INSERT', transaction.connection.data, sql,
transaction.connection.name);
callback(null, 1);
}
else {
} else {
debug('SELECT', transaction.connection.data, sql,
transaction.connection.name);
callback(null, transaction.connection.data[model] || []);

View File

@ -8,8 +8,10 @@ var ds = new juggler.DataSource({
connector: testConnector,
debug: true,
});
/* eslint-disable one-var */
var connector;
var Customer;
/* eslint-enable one-var */
describe('sql connector', function() {
before(function() {

View File

@ -4,12 +4,8 @@ var expect = require('chai').expect;
var testConnector = require('./connectors/test-sql-connector');
var juggler = require('loopback-datasource-juggler');
var db, Post;
var Review;
var db, Post, Review;
describe('transactions', function() {
before(function(done) {
db = new juggler.DataSource({
connector: testConnector,
@ -108,7 +104,6 @@ describe('transactions', function() {
}
describe('commit', function() {
var post = { title: 't1', content: 'c1' };
before(createPostInTx(post));
@ -135,7 +130,6 @@ describe('transactions', function() {
});
describe('rollback', function() {
before(function() {
// Reset the collection
db.connector.data = {};
@ -167,7 +161,6 @@ describe('transactions', function() {
});
describe('timeout', function() {
before(function() {
// Reset the collection
db.connector.data = {};
@ -194,6 +187,5 @@ describe('transactions', function() {
done();
});
});
});
});