From 0f7a567f18facb4d04e4939ab95a5b168fca929b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 5 Dec 2016 15:14:09 +0100 Subject: [PATCH] Upgrade eslint & config to latest - eslint ^3.11.1 - eslint-config-loopback: ^6.0.0 - fix linter errors (mostly no-undef) --- examples/datasource-app.js | 2 +- lib/connectors/memory.js | 3 ++- package.json | 4 ++-- test/basic-querying.test.js | 1 + test/crud-with-options.test.js | 1 + test/datatype.test.js | 1 + test/default-scope.test.js | 1 + test/defaults.test.js | 1 + test/hooks.test.js | 1 + test/include.test.js | 1 + test/json.test.js | 2 ++ test/loopback-dl.test.js | 2 +- test/manipulation.test.js | 5 ++++- test/optional-validation.test.js | 2 ++ test/persistence-hooks.suite.js | 4 ++-- test/relations.test.js | 4 +++- test/schema.test.js | 2 ++ test/scope.test.js | 2 ++ test/validations.test.js | 2 ++ 19 files changed, 32 insertions(+), 9 deletions(-) diff --git a/examples/datasource-app.js b/examples/datasource-app.js index cf976de6..34b70cf6 100644 --- a/examples/datasource-app.js +++ b/examples/datasource-app.js @@ -107,7 +107,7 @@ Article.create(function(e, article) { // should be able to attach a data source to an existing model var modelBuilder = new ModelBuilder(); -Color = modelBuilder.define('Color', { +const Color = modelBuilder.define('Color', { name: String, }); diff --git a/lib/connectors/memory.js b/lib/connectors/memory.js index 8724ac55..e06d49c8 100644 --- a/lib/connectors/memory.js +++ b/lib/connectors/memory.js @@ -5,6 +5,7 @@ 'use strict'; +/* global window:false */ var g = require('strong-globalize')(); var util = require('util'); var Connector = require('loopback-connector').Connector; @@ -823,7 +824,7 @@ Memory.prototype.replaceOrCreate = function(model, data, options, callback) { // Calling _createSync to update the collection in a sync way and // to guarantee to create it in the same turn of even loop return self._createSync(model, data, function(err, id) { - if (err) return process.nextTick(function() { cb(err); }); + if (err) return process.nextTick(function() { callback(err); }); self.saveToFile(id, function(err, id) { self.setIdValue(model, data, id); callback(err, self.fromDb(model, data), {isNewInstance: true}); diff --git a/package.json b/package.json index 41c3bb93..db138f02 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,8 @@ }, "devDependencies": { "async-iterators": "^0.2.2", - "eslint": "^2.13.1", - "eslint-config-loopback": "^4.0.0", + "eslint": "^3.11.1", + "eslint-config-loopback": "^6.0.0", "mocha": "^2.1.0", "should": "^8.0.2" }, diff --git a/test/basic-querying.test.js b/test/basic-querying.test.js index a12b0e8a..447e550c 100644 --- a/test/basic-querying.test.js +++ b/test/basic-querying.test.js @@ -6,6 +6,7 @@ // This test written in mocha+should.js 'use strict'; +/* global getSchema:false, connectorCapabilities:false */ var should = require('./init.js'); var async = require('async'); var db, User; diff --git a/test/crud-with-options.test.js b/test/crud-with-options.test.js index 44ff3e84..3971b19d 100644 --- a/test/crud-with-options.test.js +++ b/test/crud-with-options.test.js @@ -6,6 +6,7 @@ // This test written in mocha+should.js 'use strict'; +/* global getSchema:false */ var should = require('./init.js'); var async = require('async'); var db, User, options, filter; diff --git a/test/datatype.test.js b/test/datatype.test.js index 549736cc..ecfbac14 100644 --- a/test/datatype.test.js +++ b/test/datatype.test.js @@ -6,6 +6,7 @@ // This test written in mocha+should.js 'use strict'; +/* global getSchema:false */ var should = require('./init.js'); var db, Model; diff --git a/test/default-scope.test.js b/test/default-scope.test.js index f48cd9c6..d6924fa7 100644 --- a/test/default-scope.test.js +++ b/test/default-scope.test.js @@ -6,6 +6,7 @@ // This test written in mocha+should.js 'use strict'; +/* global getSchema:false */ var should = require('./init.js'); var async = require('async'); diff --git a/test/defaults.test.js b/test/defaults.test.js index b63bdb2c..dab99ef7 100644 --- a/test/defaults.test.js +++ b/test/defaults.test.js @@ -6,6 +6,7 @@ // This test written in mocha+should.js 'use strict'; +/* global getSchema:false */ var should = require('./init.js'); var db = getSchema(); diff --git a/test/hooks.test.js b/test/hooks.test.js index a0de550b..8c49b884 100644 --- a/test/hooks.test.js +++ b/test/hooks.test.js @@ -6,6 +6,7 @@ 'use strict'; // This test written in mocha+should.js +/* global getSchema:false */ var should = require('./init.js'); var j = require('../'), diff --git a/test/include.test.js b/test/include.test.js index b3f76cda..50688963 100644 --- a/test/include.test.js +++ b/test/include.test.js @@ -5,6 +5,7 @@ 'use strict'; +/* global getSchema:false */ var should = require('./init.js'); var async = require('async'); var assert = require('assert'); diff --git a/test/json.test.js b/test/json.test.js index d5356185..6e8558ac 100644 --- a/test/json.test.js +++ b/test/json.test.js @@ -5,6 +5,8 @@ // This test written in mocha+should.js 'use strict'; + +/* global getSchema:false */ var should = require('./init.js'); var Schema = require('../').Schema; diff --git a/test/loopback-dl.test.js b/test/loopback-dl.test.js index 1d3adf42..b63a537d 100644 --- a/test/loopback-dl.test.js +++ b/test/loopback-dl.test.js @@ -1275,7 +1275,7 @@ describe('Model define with relations configuration', function() { var Post = modelBuilder.define('Post', {userId: Number, content: String}); var User = modelBuilder.define('User', {name: String}, { relations: {posts: {type: 'hasMany', model: 'Post'}, - }}); + }}); assert(!User.relations['posts']); Post.attachTo(ds); diff --git a/test/manipulation.test.js b/test/manipulation.test.js index a86bcbcb..8d8d5fb8 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -5,6 +5,8 @@ // This test written in mocha+should.js 'use strict'; + +/* global getSchema:false */ var async = require('async'); var should = require('./init.js'); @@ -442,7 +444,7 @@ describe('manipulation', function() { .catch(done); }); - it('should save throw error on validation', function() { + it('should save throw error on validation', function(done) { Person.findOne(function(err, p) { if (err) return done(err); p.isValid = function(cb) { @@ -454,6 +456,7 @@ describe('manipulation', function() { 'throws': true, }); }).should.throw(ValidationError); + done(); }); }); diff --git a/test/optional-validation.test.js b/test/optional-validation.test.js index 2dba8d80..8e1bd187 100644 --- a/test/optional-validation.test.js +++ b/test/optional-validation.test.js @@ -5,6 +5,8 @@ // This test written in mocha+should.js 'use strict'; + +/* global getSchema:false */ var async = require('async'); var should = require('./init.js'); var db, User, options, ModelWithForceId, whereCount = 0; diff --git a/test/persistence-hooks.suite.js b/test/persistence-hooks.suite.js index f772f35f..67e71608 100644 --- a/test/persistence-hooks.suite.js +++ b/test/persistence-hooks.suite.js @@ -1559,7 +1559,7 @@ module.exports = function(dataSource, should, connectorCapabilities) { }); }); - if (!getSchema().connector.replaceById) { + if (!dataSource.connector.replaceById) { describe.skip('replaceById - not implemented', function() {}); } else { describe('PersistedModel.prototype.replaceAttributes', function() { @@ -2223,7 +2223,7 @@ module.exports = function(dataSource, should, connectorCapabilities) { }); }); - if (!getSchema().connector.replaceById) { + if (!dataSource.connector.replaceById) { describe.skip('replaceById - not implemented', function() {}); } else { describe('PersistedModel.replaceOrCreate', function() { diff --git a/test/relations.test.js b/test/relations.test.js index ebdcd1d7..a8fd73fa 100644 --- a/test/relations.test.js +++ b/test/relations.test.js @@ -5,6 +5,8 @@ // This test written in mocha+should.js 'use strict'; + +/* global getSchema:false */ var should = require('./init.js'); var assert = require('assert'); var jdb = require('../'); @@ -2945,7 +2947,7 @@ describe('relations', function() { should.not.exist(e); should.exist(supplier); supplier.account.update({supplierName: 'Supplier A', - supplierId: sid}, + supplierId: sid}, function(err, act) { should.not.exist(e); act.supplierName.should.equal('Supplier A'); diff --git a/test/schema.test.js b/test/schema.test.js index 92982176..6177d91f 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -5,6 +5,8 @@ // This test written in mocha+should.js 'use strict'; + +/* global getSchema:false */ var should = require('./init.js'); var db = getSchema(), slave = getSchema(), Model, SlaveModel; diff --git a/test/scope.test.js b/test/scope.test.js index cfafacbb..9eb5d501 100644 --- a/test/scope.test.js +++ b/test/scope.test.js @@ -5,6 +5,8 @@ // This test written in mocha+should.js 'use strict'; + +/* global getSchema:false */ var should = require('./init.js'); var db, Railway, Station; diff --git a/test/validations.test.js b/test/validations.test.js index 38776fcc..90d362e2 100644 --- a/test/validations.test.js +++ b/test/validations.test.js @@ -5,6 +5,8 @@ // This test written in mocha+should.js 'use strict'; + +/* global getSchema:false */ var should = require('./init.js'); var async = require('async');