Update eslint + config to latest

This commit is contained in:
Miroslav Bajtoš 2018-06-12 09:13:32 +02:00
parent e2d75e70d1
commit d2ee73b9d3
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
28 changed files with 2586 additions and 2564 deletions

View File

@ -38,8 +38,8 @@
"async-iterators": "^0.2.2",
"bson": "^1.0.4",
"coveralls": "^2.13.1",
"eslint": "^3.12.2",
"eslint-config-loopback": "^8.0.0",
"eslint": "^4.19.1",
"eslint-config-loopback": "^10.0.0",
"loopback-connector-throwing": "file:./test/fixtures/loopback-connector-throwing",
"mocha": "^3.2.0",
"nyc": "^11.1.0",

View File

@ -90,6 +90,7 @@ function clearAndCreate(model, data, callback) {
}
}
/* eslint-disable mocha/handle-done-callback */
function testOrm(dataSource) {
var requestsAreCounted = dataSource.name !== 'mongodb';

View File

@ -124,7 +124,7 @@ describe('DataSource', function() {
/**
* new DataSource(dsName, connectorInstance)
*/
it('should accept resolved connector', function() {
it('should accept dsName and resolved connector', function() {
var mockConnector = {
name: 'loopback-connector-mock',
initialize: function(ds, cb) {

View File

@ -667,6 +667,7 @@ describe('default scope', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find a scoped instance - thing', function(done) {
Product.find({where: {name: 'Product'}}, function(err, products) {
products.should.have.length(2);

View File

@ -659,6 +659,7 @@ describe('include', function() {
bdd.describeIf(connectorCapabilities.adhocSort === false,
'findWithForeignKeysByPage', function() {
// eslint-disable-next-line mocha/no-identical-title
context('filter', function() {
it('works when using a `where` with a foreign key', function(done) {
User.findOne({
@ -829,6 +830,7 @@ describe('include', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
context('pagination', function() {
it('works with the default page size (0) and `inqlimit` is exceeded',
function(done) {
@ -865,6 +867,7 @@ describe('include', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
context('relations', function() {
// WARNING
// The code paths for in this suite of tests were verified manually due to

View File

@ -36,19 +36,17 @@ describe('include_util', function() {
result.get(11)['letter'].should.equal('HA!');
result.get(33)['letter'].should.equal('C');
});
});
describe('#buildOneToOneIdentityMapWithOrigKeys', function() {
it('should return an object with keys', function() {
it('should return an object with no additional keys', function() {
var objs = [
{id: 11, letter: 'A'},
{id: 22, letter: 'B'},
];
var result = includeUtils.buildOneToOneIdentityMapWithOrigKeys(objs, 'id');
result.get(11).should.be.ok;
result.get(22).should.be.ok;
result.getKeys().should.have.lengthOf(2); // no additional properties
result.getKeys().should.eql([11, 22]); // no additional properties
});
});
describe('#buildOneToManyIdentityMap', function() {
it('should return an object with keys', function() {
var objs = [

View File

@ -15,7 +15,7 @@ function givenCacheItem(dataSourceFactory) {
};
function givenModel(dataSourceFactory, modelName,
modelProperties, options) {
modelProperties, options) {
const dataSource = dataSourceFactory();
const Model = dataSource.createModel(modelName, modelProperties);
const p = 'deleteAll' in dataSource.connector ?

View File

@ -339,7 +339,7 @@ describe('DataSource define model', function() {
it('supports plain model definitions', function() {
var ds = new DataSource('memory');
// define models
// define models
var Post = ds.define('Post', {
title: {type: String, length: 255},
content: {type: ModelBuilder.Text},
@ -350,7 +350,7 @@ describe('DataSource define model', function() {
published: {type: Boolean, default: false, index: true},
});
// simpler way to describe model
// simpler way to describe model
var User = ds.define('User', {
name: String,
bio: ModelBuilder.Text,
@ -362,7 +362,7 @@ describe('DataSource define model', function() {
var Group = ds.define('Group', {group: String});
User.mixin(Group);
// define any custom method
// define any custom method
User.prototype.getNameAndAge = function() {
return this.name + ', ' + this.age;
};
@ -418,7 +418,7 @@ describe('DataSource define model', function() {
});
});
// should be able to attach a data source to an existing model
// should be able to attach a data source to an existing model
var modelBuilder = new ModelBuilder();
var Color = modelBuilder.define('Color', {
@ -427,7 +427,7 @@ describe('DataSource define model', function() {
Color.should.not.have.property('create');
// attach
// attach
ds.attach(Color);
Color.should.have.property('create');
@ -971,7 +971,7 @@ describe('DataSource connector types', function() {
});
});
describe('DataSource constructor', function() {
describe('DataSource._resolveConnector', function() {
// Mocked require
var loader = function(name) {
if (name.indexOf('./connectors/') !== -1) {

View File

@ -1279,6 +1279,7 @@ describe('manipulation', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('works on create if the request does not include an id', function(done) {
var post = {title: 'a', content: 'AAA'};
Post.replaceOrCreate(post, function(err, p) {
@ -1289,6 +1290,7 @@ describe('manipulation', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('works on update if the request includes an existing id in db', function(done) {
Post.create({title: 'a', content: 'AAA'},
function(err, post) {
@ -1757,11 +1759,13 @@ describe('manipulation', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should be defined as function', function() {
Person.deleteAll.should.be.a.Function;
Person.destroyAll.should.be.a.Function;
});
// eslint-disable-next-line mocha/no-identical-title
it('should only delete instances that satisfy the where condition',
function(done) {
Person.deleteAll({id: idJohn}, function(err, info) {
@ -1780,6 +1784,7 @@ describe('manipulation', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should report zero deleted instances when no matches are found',
function(done) {
var unknownId = uid.fromConnector(db) || 1234567890;
@ -1794,6 +1799,7 @@ describe('manipulation', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should delete all instances when the where condition is not provided',
function(done) {
Person.deleteAll(function(err, info) {
@ -1933,7 +1939,7 @@ describe('manipulation', function() {
person.isNewRecord().should.be.true;
});
describe('Date $now function', function() {
describe('Date $now function (type: Date)', function() {
var CustomModel;
before(function(done) {
@ -1957,7 +1963,7 @@ describe('manipulation', function() {
});
});
describe('Date $now function', function() {
describe('Date $now function (type: String)', function() {
var CustomModel;
before(function(done) {

View File

@ -962,14 +962,6 @@ describe('Memory connector with options', function() {
});
});
it('should receive options from the find method', function(done) {
var opts = {transaction: 'tx2'};
Post.find({}, opts, function(err, p) {
savedOptions.find.should.be.eql(opts);
done(err);
});
});
it('should treat first object arg as filter for find', function(done) {
var filter = {title: 't1'};
Post.find(filter, function(err, p) {

View File

@ -2258,7 +2258,7 @@ module.exports = function(dataSource, should, connectorCapabilities) {
});
if (!dataSource.connector.replaceById) {
describe.skip('replaceById - not implemented', function() {});
describe.skip('replaceOrCreate - not implemented', function() {});
} else {
describe('PersistedModel.replaceOrCreate', function() {
it('triggers hooks in the correct order on create', function(done) {

View File

@ -1777,6 +1777,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find records on scope', function(done) {
Category.findOne(function(err, c) {
should.not.exists(err);
@ -1801,6 +1802,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find record on scope - scoped', function(done) {
Category.findOne(function(err, c) {
should.not.exists(err);
@ -2647,6 +2649,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find polymorphic items - article', function(done) {
Article.findOne({where: {name: 'Article 2'}}, function(err, article) {
should.not.exists(err);
@ -2659,6 +2662,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find the inverse of polymorphic relation - article', function(done) {
Picture.findOne({where: {name: 'Sample'}}, function(err, p) {
if (err) return done(err);
@ -2902,6 +2906,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should create polymorphic through model', function(done) {
if (!anotherPicture) return done();
PictureLink.findOne({where: {pictureId: anotherPicture.id, imageableType: 'Article'}},
@ -2915,6 +2920,7 @@ describe('relations', function() {
});
var anotherArticle, anotherEmployee;
// eslint-disable-next-line mocha/no-identical-title
it('should add to a polymorphic relation - article', function(done) {
Article.create({name: 'Article 2'}, function(err, article) {
if (err) return done(err);
@ -2927,6 +2933,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should add to a polymorphic relation - article', function(done) {
Employee.create({name: 'Employee 2'}, function(err, reader) {
if (err) return done(err);
@ -3032,6 +3039,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should check if polymorphic relation exists - article', function(done) {
if (!article) return done();
Article.findById(article.id, function(err, article) {
@ -4519,6 +4527,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should get an embedded item on scope - verify', function(done) {
Person.findById(personId, function(err, p) {
if (err) return done(err);
@ -4632,6 +4641,7 @@ describe('relations', function() {
}).catch(done);
});
// eslint-disable-next-line mocha/no-identical-title
it('should get an embedded item on scope with promises - verify', function(done) {
Person.findById(personId)
.then(function(p) {
@ -4828,6 +4838,7 @@ describe('relations', function() {
Person.definition.properties.addresses.postgresql.should.eql({dataType: 'json'});
});
// eslint-disable-next-line mocha/no-identical-title
it('should create embedded items on scope', function(done) {
Person.findOne(function(err, p) {
p.addressList.create({street: 'Street 2'}, function(err, address) {
@ -4970,6 +4981,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should create embedded items on scope', function(done) {
Person.findOne(function(err, p) {
p.addressList.create({street: 'Street 3'}, function(err, address) {
@ -5224,6 +5236,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should have embedded items - verify', function(done) {
Person.findOne({where: {name: 'Wilma'}}, function(err, p) {
p.name.should.equal('Wilma');
@ -5549,6 +5562,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find items on scope', function(done) {
Category.findOne(function(err, cat) {
if (err) return done(err);
@ -5604,6 +5618,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find items on scope', function(done) {
Category.findById(category.id, function(err, cat) {
if (err) return done(err);
@ -5952,6 +5967,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should add a record to scope - object', function(done) {
Category.findOne(function(err, cat) {
cat.jobs.add(job3.id, function(err, prod) {
@ -5967,6 +5983,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find items on scope - findById', function(done) {
Category.findOne(function(err, cat) {
cat.jobs.findById(job3.id, function(err, p) {
@ -6090,6 +6107,7 @@ describe('relations', function() {
});
});
// eslint-disable-next-line mocha/no-identical-title
it('should find items on scope - verify', function(done) {
Category.findOne(function(err, cat) {
cat.jobIds.should.have.lengthOf(1);
@ -6252,6 +6270,7 @@ describe('relations', function() {
.catch(done);
});
// eslint-disable-next-line mocha/no-identical-title
it('should add a record to scope with promises - object', function(done) {
Category.findOne()
.then(function(cat) {
@ -6268,6 +6287,7 @@ describe('relations', function() {
.catch(done);
});
// eslint-disable-next-line mocha/no-identical-title
it('should find items on scope with promises - findById', function(done) {
Category.findOne()
.then(function(cat) {
@ -6397,6 +6417,7 @@ describe('relations', function() {
.catch(done);
});
// eslint-disable-next-line mocha/no-identical-title
it('should find items on scope with promises - verify', function(done) {
Category.findOne()
.then(function(cat) {

View File

@ -127,7 +127,7 @@ describe('util.parseSettings', function() {
should.equal(settings.url, 'mysql://127.0.0.1:3306/mydb?x[a]=1&x[b]=2&engine=InnoDB');
});
it('Parse a url without auth into a settings object', function() {
it('Parse a Memory url without auth into a settings object', function() {
var url = 'memory://?x=1';
var settings = utils.parseSettings(url);
should.equal(settings.hostname, '');