Merge pull request #4283 from strongloop/fix-comma-dangle

chore: fix eslint violations
This commit is contained in:
Nora 2019-11-18 23:44:59 -05:00 committed by GitHub
commit b848bd9d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 217 additions and 217 deletions

View File

@ -233,7 +233,7 @@ module.exports = function(AccessToken) {
try {
assert(
this.created && typeof this.created.getTime === 'function',
'token.created must be a valid Date'
'token.created must be a valid Date',
);
assert(this.ttl !== 0, 'token.ttl must be not be 0');
assert(this.ttl, 'token.ttl must exist');

View File

@ -607,12 +607,12 @@ module.exports = function(ACL) {
break;
case ACL.USER:
this.userModel.findOne(
{where: {or: [{username: id}, {email: id}, {id: id}]}}, cb
{where: {or: [{username: id}, {email: id}, {id: id}]}}, cb,
);
break;
case ACL.APP:
this.applicationModel.findOne(
{where: {or: [{name: id}, {email: id}, {id: id}]}}, cb
{where: {or: [{name: id}, {email: id}, {id: id}]}}, cb,
);
break;
default:
@ -621,7 +621,7 @@ module.exports = function(ACL) {
if (userModel) {
userModel.findOne(
{where: {or: [{username: id}, {email: id}, {id: id}]}},
cb
cb,
);
} else {
process.nextTick(function() {

View File

@ -216,7 +216,7 @@ module.exports = function(Change) {
function(err, checkpoint) {
if (err) return cb(err);
doRectify(checkpoint, rev);
}
},
);
}
@ -502,7 +502,7 @@ module.exports = function(Change) {
async.each(
changes,
function(c, next) { c.rectify(next); },
cb
cb,
);
});
};
@ -692,9 +692,9 @@ module.exports = function(Change) {
conflict.SourceModel.updateLastChange(
conflict.modelId,
{prev: targetChange.rev},
cb
cb,
);
}
},
);
};
@ -727,7 +727,7 @@ module.exports = function(Change) {
}
const inst = new conflict.SourceModel(
target.toObject(),
{persisted: true}
{persisted: true},
);
inst.save(done);
});

View File

@ -226,7 +226,7 @@ function throwNotAttached(modelName, methodName) {
'The %s method has not been setup. ' +
'The {{KeyValueModel}} has not been correctly attached ' +
'to a {{DataSource}}!',
modelName, methodName, methodName
modelName, methodName, methodName,
));
}

View File

@ -487,7 +487,7 @@ module.exports = function(Role) {
if (promise && typeof promise.then === 'function') {
promise.then(
function(result) { callback(null, result); },
callback
callback,
);
}
return callback.promise;

View File

@ -47,7 +47,7 @@ module.exports = function(Scope) {
if (callback) callback(err);
} else {
aclModel.checkPermission(
aclModel.SCOPE, scope.id, model, property, accessType, callback
aclModel.SCOPE, scope.id, model, property, accessType, callback,
);
}
});

View File

@ -766,14 +766,14 @@ module.exports = function(User) {
throw new Error(
'Cannot build user verification URL, ' +
'the default confirm method is not public. ' +
'Please provide the URL in verifyOptions.verifyHref.'
'Please provide the URL in verifyOptions.verifyHref.',
);
}
const urlPath = joinUrlPath(
verifyOptions.restApiRoot,
userModel.http.path,
confirmMethod.http.path
confirmMethod.http.path,
);
verifyOptions.verifyHref =
@ -1148,7 +1148,7 @@ module.exports = function(User) {
'{{(`include=user`)}}\n\n'),
},
http: {verb: 'post'},
}
},
);
UserModel.remoteMethod(
@ -1167,7 +1167,7 @@ module.exports = function(User) {
},
],
http: {verb: 'all'},
}
},
);
UserModel.remoteMethod(
@ -1179,7 +1179,7 @@ module.exports = function(User) {
{arg: 'options', type: 'object', http: 'optionsFromRequest'},
],
http: {verb: 'post'},
}
},
);
UserModel.remoteMethod(
@ -1192,7 +1192,7 @@ module.exports = function(User) {
{arg: 'redirect', type: 'string'},
],
http: {verb: 'get', path: '/confirm'},
}
},
);
UserModel.remoteMethod(
@ -1203,7 +1203,7 @@ module.exports = function(User) {
{arg: 'options', type: 'object', required: true, http: {source: 'body'}},
],
http: {verb: 'post', path: '/reset'},
}
},
);
UserModel.remoteMethod(
@ -1217,7 +1217,7 @@ module.exports = function(User) {
{arg: 'options', type: 'object', http: 'optionsFromRequest'},
],
http: {verb: 'POST', path: '/change-password'},
}
},
);
const setPasswordScopes = UserModel.settings.restrictResetPasswordTokenScope ?
@ -1234,7 +1234,7 @@ module.exports = function(User) {
],
accessScopes: setPasswordScopes,
http: {verb: 'POST', path: '/reset-password'},
}
},
);
function getUserIdFromRequestContext(ctx) {
@ -1337,7 +1337,7 @@ module.exports = function(User) {
// This is a programmer's error, use the default status code 500
return next(new Error(
'Invalid use of "options.setPassword". Only "password" can be ' +
'changed when using this option.'
'changed when using this option.',
));
}
@ -1350,7 +1350,7 @@ module.exports = function(User) {
const err = new Error(
'Changing user password via patch/replace API is not allowed. ' +
'Use changePassword() or setPassword() instead.'
'Use changePassword() or setPassword() instead.',
);
err.statusCode = 401;
err.code = 'PASSWORD_CHANGE_NOT_ALLOWED';

View File

@ -359,7 +359,7 @@ app.enableAuth = function(options) {
const Model = app.registry.findModel(m);
if (!Model) {
throw new Error(
g.f('Authentication requires model %s to be defined.', m)
g.f('Authentication requires model %s to be defined.', m),
);
}
@ -435,7 +435,7 @@ app.enableAuth = function(options) {
e.code = messages[errStatusCode].code || messages[403].code;
next(e);
}
}
},
);
} else {
next();
@ -486,7 +486,7 @@ app._verifyAuthModelRelations = function() {
'custom User subclass, but does not fix AccessToken relations ' +
'to use this new model.\n' +
'Learn more at http://ibm.biz/setup-loopback-auth',
Model.modelName, userName, userName
Model.modelName, userName, userName,
);
return;
}
@ -495,7 +495,7 @@ app._verifyAuthModelRelations = function() {
'The model %j does not have "belongsTo User-like model" relation ' +
'configured.\n' +
'Learn more at http://ibm.biz/setup-loopback-auth',
Model.modelName
Model.modelName,
);
}
@ -509,7 +509,7 @@ app._verifyAuthModelRelations = function() {
'The app configuration follows the multiple user models setup ' +
'as described in http://ibm.biz/setup-loopback-auth',
'The built-in role resolver $owner is not currently compatible ' +
'with this configuration and should not be used in production.'
'with this configuration and should not be used in production.',
);
}
return;
@ -526,7 +526,7 @@ app._verifyAuthModelRelations = function() {
'AccessToken subclass, but does not fix User relations to use this ' +
'new model.\n' +
'Learn more at http://ibm.biz/setup-loopback-auth',
Model.modelName, accessTokenName, accessTokenName
Model.modelName, accessTokenName, accessTokenName,
);
return;
}
@ -535,14 +535,14 @@ app._verifyAuthModelRelations = function() {
'The model %j does not have "hasMany AccessToken-like models" relation ' +
'configured.\n' +
'Learn more at http://ibm.biz/setup-loopback-auth',
Model.modelName
Model.modelName,
);
}
};
app.boot = function(options) {
throw new Error(
g.f('{{`app.boot`}} was removed, use the new module {{loopback-boot}} instead')
g.f('{{`app.boot`}} was removed, use the new module {{loopback-boot}} instead'),
);
};
@ -584,7 +584,7 @@ function configureModel(ModelCtor, config, app) {
assert(
dataSource instanceof DataSource,
ModelCtor.modelName + ' is referencing a dataSource that does not exist: "' +
config.dataSource + '"'
config.dataSource + '"',
);
}

View File

@ -12,57 +12,57 @@ module.exports = function(registry) {
registry.KeyValueModel = createModel(
require('../common/models/key-value-model.json'),
require('../common/models/key-value-model.js')
require('../common/models/key-value-model.js'),
);
registry.Email = createModel(
require('../common/models/email.json'),
require('../common/models/email.js')
require('../common/models/email.js'),
);
registry.Application = createModel(
require('../common/models/application.json'),
require('../common/models/application.js')
require('../common/models/application.js'),
);
registry.AccessToken = createModel(
require('../common/models/access-token.json'),
require('../common/models/access-token.js')
require('../common/models/access-token.js'),
);
registry.User = createModel(
require('../common/models/user.json'),
require('../common/models/user.js')
require('../common/models/user.js'),
);
registry.RoleMapping = createModel(
require('../common/models/role-mapping.json'),
require('../common/models/role-mapping.js')
require('../common/models/role-mapping.js'),
);
registry.Role = createModel(
require('../common/models/role.json'),
require('../common/models/role.js')
require('../common/models/role.js'),
);
registry.ACL = createModel(
require('../common/models/acl.json'),
require('../common/models/acl.js')
require('../common/models/acl.js'),
);
registry.Scope = createModel(
require('../common/models/scope.json'),
require('../common/models/scope.js')
require('../common/models/scope.js'),
);
registry.Change = createModel(
require('../common/models/change.json'),
require('../common/models/change.js')
require('../common/models/change.js'),
);
registry.Checkpoint = createModel(
require('../common/models/checkpoint.json'),
require('../common/models/checkpoint.js')
require('../common/models/checkpoint.js'),
);
function createModel(definitionJson, customizeFn) {

View File

@ -15,7 +15,7 @@ module.exports = function(loopback) {
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'loopback.getCurrentContext()',
'http://loopback.io/doc/en/lb2/Using-current-context.html'
'http://loopback.io/doc/en/lb2/Using-current-context.html',
));
};
@ -23,7 +23,7 @@ module.exports = function(loopback) {
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'loopback.runInContext()',
'http://loopback.io/doc/en/lb2/Using-current-context.html'
'http://loopback.io/doc/en/lb2/Using-current-context.html',
));
};
@ -31,7 +31,7 @@ module.exports = function(loopback) {
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'loopback.createContext()',
'http://loopback.io/doc/en/lb2/Using-current-context.html'
'http://loopback.io/doc/en/lb2/Using-current-context.html',
));
};
};

View File

@ -206,7 +206,7 @@ module.exports = function(registry) {
const sharedClass = ModelCtor.sharedClass = new SharedClass(
ModelCtor.modelName,
ModelCtor,
remotingOptions
remotingOptions,
);
// before remote hook
@ -250,12 +250,12 @@ module.exports = function(registry) {
if ('injectOptionsFromRemoteContext' in options) {
console.warn(g.f(
'%s is using model setting %s which is no longer available.',
typeName, 'injectOptionsFromRemoteContext'
typeName, 'injectOptionsFromRemoteContext',
));
console.warn(g.f(
'Please rework your app to use the offical solution for injecting ' +
'"options" argument from request context,\nsee %s',
'http://loopback.io/doc/en/lb3/Using-current-context.html'
'http://loopback.io/doc/en/lb3/Using-current-context.html',
));
}
@ -373,7 +373,7 @@ module.exports = function(registry) {
}
assert(
typeof method === 'object',
'method is a required argument and must be a RemoteMethod object'
'method is a required argument and must be a RemoteMethod object',
);
const ACL = Model._ACL();

View File

@ -72,7 +72,7 @@ module.exports = function(registry) {
g.f('Cannot call %s.%s().' +
' The %s method has not been setup.' +
' The {{PersistedModel}} has not been correctly attached to a {{DataSource}}!',
modelName, methodName, methodName)
modelName, methodName, methodName),
);
}
@ -1214,7 +1214,7 @@ module.exports = function(registry) {
assert(
changeTrackingEnabled,
'You must enable change tracking before replicating'
'You must enable change tracking before replicating',
);
let diff, updates, newSourceCp, newTargetCp;
@ -1236,7 +1236,7 @@ module.exports = function(registry) {
function(filter, pagingCallback) {
sourceModel.changes(since.source, filter, pagingCallback);
},
debug.enabled ? log : cb
debug.enabled ? log : cb,
);
function log(err, result) {
@ -1254,7 +1254,7 @@ module.exports = function(registry) {
function(smallArray, chunkCallback) {
return targetModel.diff(since.target, smallArray, chunkCallback);
},
debug.enabled ? log : cb
debug.enabled ? log : cb,
);
function log(err, result) {
@ -1283,7 +1283,7 @@ module.exports = function(registry) {
function(smallArray, chunkCallback) {
return sourceModel.createUpdates(smallArray, chunkCallback);
},
cb
cb,
);
} else {
// nothing to replicate
@ -1316,7 +1316,7 @@ module.exports = function(registry) {
return cb();
}
cb(err);
}
},
);
}
@ -1347,7 +1347,7 @@ module.exports = function(registry) {
const conflicts = diff.conflicts.map(function(change) {
return new Change.Conflict(
change.modelId, sourceModel, targetModel
change.modelId, sourceModel, targetModel,
);
});
@ -1535,7 +1535,7 @@ module.exports = function(registry) {
return cb(new Error(
g.f('Cannot apply bulk updates, ' +
'the connector does not correctly report ' +
'the number of updated records.')
'the number of updated records.'),
));
default:
@ -1543,7 +1543,7 @@ module.exports = function(registry) {
Model.modelName, count);
return cb(new Error(
g.f('Bulk update failed, the connector has modified unexpected ' +
'number of records: %s', JSON.stringify(count))
'number of records: %s', JSON.stringify(count)),
));
}
});
@ -1619,7 +1619,7 @@ module.exports = function(registry) {
return cb(new Error(
g.f('Cannot apply bulk updates, ' +
'the connector does not correctly report ' +
'the number of deleted records.')
'the number of deleted records.'),
));
default:
@ -1627,7 +1627,7 @@ module.exports = function(registry) {
Model.modelName, count);
return cb(new Error(
g.f('Bulk update failed, the connector has deleted unexpected ' +
'number of records: %s', JSON.stringify(count))
'number of records: %s', JSON.stringify(count)),
));
}
});
@ -1663,7 +1663,7 @@ module.exports = function(registry) {
}
assert(
dataSource.connector.name,
'Model.getSourceId: cannot get id without dataSource.connector.name'
'Model.getSourceId: cannot get id without dataSource.connector.name',
);
const id = [dataSource.connector.name, this.modelName].join('-');
cb(null, id);
@ -1786,7 +1786,7 @@ module.exports = function(registry) {
this.Change = BaseChangeModel.extend(
this.modelName + '-change',
additionalChangeModelProperties,
{trackModel: this}
{trackModel: this},
);
if (this.dataSource) {

View File

@ -244,7 +244,7 @@ Registry.prototype.configureModel = function(ModelCtor, config) {
g.warn(
'The configuration of `%s` is missing {{`dataSource`}} property.\n' +
'Use `null` or `false` to mark models not attached to any data source.',
modelName
modelName,
);
}
@ -254,7 +254,7 @@ Registry.prototype.configureModel = function(ModelCtor, config) {
if (hasNewMethods && hasDescendants) {
g.warn(
'Child models of `%s` will not inherit newly defined remote methods %s.',
modelName, newMethodNames
modelName, newMethodNames,
);
}

View File

@ -28,7 +28,7 @@ function createPromiseCallback() {
function throwPromiseNotDefined() {
throw new Error(
'Your Node runtime does support ES6 Promises. ' +
'Set "global.Promise" to your preferred implementation of promises.'
'Set "global.Promise" to your preferred implementation of promises.',
);
}

View File

@ -10,6 +10,6 @@ module.exports = function() {
throw new Error(g.f(
'%s middleware was removed in version 3.0. See %s for more details.',
'loopback#context',
'http://loopback.io/doc/en/lb2/Using-current-context.html'
'http://loopback.io/doc/en/lb2/Using-current-context.html',
));
};

View File

@ -45,7 +45,7 @@ function rest() {
throw new Error(g.f(
'%s was removed in version 3.0. See %s for more details.',
'remoting.context option',
'http://loopback.io/doc/en/lb2/Using-current-context.html'
'http://loopback.io/doc/en/lb2/Using-current-context.html',
));
}

View File

@ -40,7 +40,7 @@ function rewriteUserLiteral(req, currentUserLiteral, next) {
debug(
'URL %s matches current-user literal %s,' +
' but no (valid) access token was provided.',
req.url, currentUserLiteral
req.url, currentUserLiteral,
);
const e = new Error(g.f('Authorization Required'));

View File

@ -75,11 +75,11 @@ describe('access control - integration', function() {
lt.it.shouldBeDeniedWhenCalledByUser(CURRENT_USER, 'GET', urlForUser);
lt.it.shouldBeAllowedWhenCalledAnonymously(
'POST', '/api/users', newUserData()
'POST', '/api/users', newUserData(),
);
lt.it.shouldBeAllowedWhenCalledByUser(
CURRENT_USER, 'POST', '/api/users', newUserData()
CURRENT_USER, 'POST', '/api/users', newUserData(),
);
lt.it.shouldBeAllowedWhenCalledByUser(CURRENT_USER, 'POST', '/api/users/logout');

View File

@ -144,7 +144,7 @@ describe('loopback.token(options)', function() {
const app = createTestApp(
this.token,
{token: {searchDefaultTokenKeys: false}},
done
done,
);
const agent = request.agent(app);
@ -615,7 +615,7 @@ describe('AccessToken', function() {
param: function(name) { return this._params[name]; },
header: function(name) { return this.headers[name]; },
},
opts
opts,
);
}
});

View File

@ -573,7 +573,7 @@ describe('authorized roles propagation in RemotingContext', function() {
$everyone: true,
$authenticated: true,
myRole: true,
}
},
);
});
});
@ -591,7 +591,7 @@ describe('authorized roles propagation in RemotingContext', function() {
{
$everyone: true,
myRole: true,
}
},
);
});
});
@ -610,7 +610,7 @@ describe('authorized roles propagation in RemotingContext', function() {
const ctx = models.MyTestModel.lastRemotingContext;
expect(ctx.args.options.authorizedRoles).to.eql(
// '$everyone' is not expected as default permission is DENY
{myRole: true}
{myRole: true},
);
});
});

View File

@ -245,7 +245,7 @@ describe('app', function() {
expect(steps).to.eql(['/scope', '/scope/item']);
done();
}
},
);
});
@ -261,7 +261,7 @@ describe('app', function() {
expect(steps).to.eql(['/a', '/b']);
done();
}
},
);
});
@ -277,7 +277,7 @@ describe('app', function() {
expect(steps).to.eql(['/a', '/b', '/scope']);
done();
}
},
);
});
@ -562,7 +562,7 @@ describe('app', function() {
{
phase: 'initial',
paths: ['/scope', /^\/(a|b)/],
}
},
);
async.eachSeries(
@ -574,7 +574,7 @@ describe('app', function() {
expect(steps).to.eql(['/a', '/b', '/scope']);
done();
}
},
);
});
});
@ -719,14 +719,14 @@ describe('app', function() {
const Book = app.registry.createModel(
'Book',
{name: 'string'},
{plural: 'books'}
{plural: 'books'},
);
app.model(Book, {dataSource: 'db'});
const Page = app.registry.createModel(
'Page',
{name: 'string'},
{plural: 'pages'}
{plural: 'pages'},
);
app.model(Page, {dataSource: 'db'});
@ -1089,11 +1089,11 @@ describe('app', function() {
const UserAccount = app.registry.createModel(
'UserAccount',
{name: 'string'},
options
options,
);
const UserRole = app.registry.createModel(
'UserRole',
{name: 'string'}
{name: 'string'},
);
app.model(UserAccount, {dataSource: 'db'});
app.model(UserRole, {dataSource: 'db'});

View File

@ -222,7 +222,7 @@ describe('Change', function() {
change = ch;
done(err);
}
},
);
});

View File

@ -215,7 +215,7 @@ describe('OptionsFromRemotingContext', function() {
Category = app.registry.createModel(
'Category',
{name: String},
{forceId: false, replaceOnPUT: true}
{forceId: false, replaceOnPUT: true},
);
app.model(Category, {dataSource: 'db'});
@ -288,7 +288,7 @@ describe('OptionsFromRemotingContext', function() {
Category = app.registry.createModel(
'Category',
{name: String},
{forceId: false, replaceOnPUT: true}
{forceId: false, replaceOnPUT: true},
);
app.model(Category, {dataSource: 'db'});
@ -333,7 +333,7 @@ describe('OptionsFromRemotingContext', function() {
Category = app.registry.createModel(
'Category',
{name: String},
{forceId: false, replaceOnPUT: true}
{forceId: false, replaceOnPUT: true},
);
app.model(Category, {dataSource: 'db'});
@ -364,7 +364,7 @@ describe('OptionsFromRemotingContext', function() {
Product = app.registry.createModel(
'Product',
{name: String},
{forceId: false, replaceOnPUT: true}
{forceId: false, replaceOnPUT: true},
);
Product.createOptionsFromRemotingContext = function(ctx) {

View File

@ -76,7 +76,7 @@ _beforeEach.givenModel = function(modelName, attrs, optionalHandler) {
' without attached dataSource');
assert(
typeof model.create === 'function',
modelName + ' does not have a create method'
modelName + ' does not have a create method',
);
model.create(attrs, function(err, result) {

View File

@ -14,7 +14,7 @@ describe('hidden properties', function() {
const Product = this.Product = loopback.PersistedModel.extend(
'product',
{},
{hidden: ['secret']}
{hidden: ['secret']},
);
Product.attachTo(loopback.memory());

View File

@ -29,7 +29,7 @@ describe('loopback application', function() {
expect(res).to.match(/\nX$/);
done();
}
},
);
});

View File

@ -161,7 +161,7 @@ describe('loopback', function() {
{
returns: {arg: 'stats', type: 'array'},
http: {path: '/info', verb: 'get'},
}
},
);
assert.equal(Product.stats.returns.arg, 'stats');

View File

@ -613,7 +613,7 @@ describe.onServer('Remote Methods', function() {
// should match the given property
assert(
p.type.name === o.name ||
p.type.name === o
p.type.name === o,
);
}
});
@ -706,7 +706,7 @@ describe.onServer('Remote Methods', function() {
const remoteMethod = {name: methodName};
assert.equal(
User._getAccessTypeForMethod(remoteMethod),
expectedAccessType
expectedAccessType,
);
});
});

View File

@ -101,7 +101,7 @@ describe('Multiple users with custom principalType', function() {
},
function onError(err) {
expect(err).to.have.property('code', 'LOGIN_FAILED');
}
},
);
});
});
@ -285,7 +285,7 @@ describe('Multiple users with custom principalType', function() {
describe('role.users()', function() {
it('returns users when using custom user principalType', function() {
return userRole.principals.create(
{principalType: OneUser.modelName, principalId: userFromOneModel.id}
{principalType: OneUser.modelName, principalId: userFromOneModel.id},
)
.then(function() {
return userRole.users({where: {principalType: OneUser.modelName}});
@ -298,7 +298,7 @@ describe('Multiple users with custom principalType', function() {
it('returns empty array when using invalid principalType', function() {
return userRole.principals.create(
{principalType: 'invalidModelName', principalId: userFromOneModel.id}
{principalType: 'invalidModelName', principalId: userFromOneModel.id},
)
.then(function() {
return userRole.users({where: {principalType: 'invalidModelName'}});
@ -312,7 +312,7 @@ describe('Multiple users with custom principalType', function() {
describe('principal.user()', function() {
it('returns the correct user instance', function() {
return userRole.principals.create(
{principalType: OneUser.modelName, principalId: userFromOneModel.id}
{principalType: OneUser.modelName, principalId: userFromOneModel.id},
).then(function(principal) {
return principal.user();
}).then(function(user) {
@ -322,7 +322,7 @@ describe('Multiple users with custom principalType', function() {
it('returns null when created with invalid principalType', function() {
return userRole.principals.create(
{principalType: 'invalidModelName', principalId: userFromOneModel.id}
{principalType: 'invalidModelName', principalId: userFromOneModel.id},
).then(function(principal) {
return principal.user();
}).then(function(user) {
@ -346,7 +346,7 @@ describe('Multiple users with custom principalType', function() {
it('supports getRoles()', function() {
return Role.getRoles(
userOneBaseContext
userOneBaseContext,
).then(function(roles) {
expect(roles).to.eql([
Role.AUTHENTICATED,
@ -487,7 +487,7 @@ describe('Multiple users with custom principalType', function() {
// with any belongsTo relation allowing to resolve truthy
const Message = createModelWithOptions(
'ModelWithAllRelations',
{ownerRelations: true}
{ownerRelations: true},
);
const messages = [
@ -587,7 +587,7 @@ describe('Multiple users with custom principalType', function() {
const Model = app.registry.createModel(
name,
{content: String, senderType: String},
options
options,
);
app.model(Model, {dataSource: 'db'});
return Model;
@ -616,7 +616,7 @@ describe('Multiple users with custom principalType', function() {
function onError(err) {
expect(err).to.have.property('statusCode', 400);
expect(err).to.have.property('code', 'INVALID_PRINCIPAL_TYPE');
}
},
);
});

View File

@ -661,11 +661,11 @@ describe('relations - integration', function() {
const product = app.registry.createModel(
'product',
{id: 'string', name: 'string'}
{id: 'string', name: 'string'},
);
const category = app.registry.createModel(
'category',
{id: 'string', name: 'string'}
{id: 'string', name: 'string'},
);
app.model(product, {dataSource: 'db'});
app.model(category, {dataSource: 'db'});
@ -786,13 +786,13 @@ describe('relations - integration', function() {
const group = app.registry.createModel(
'group',
{name: 'string'},
{plural: 'groups'}
{plural: 'groups'},
);
app.model(group, {dataSource: 'db'});
const poster = app.registry.createModel(
'poster',
{url: 'string'}
{url: 'string'},
);
app.model(poster, {dataSource: 'db'});
@ -822,7 +822,7 @@ describe('relations - integration', function() {
.send({url: 'http://image.url'})
.expect(200, function(err, res) {
expect(res.body).to.be.eql(
{url: 'http://image.url'}
{url: 'http://image.url'},
);
done();
@ -838,7 +838,7 @@ describe('relations - integration', function() {
expect(res.body.name).to.be.equal('Group 1');
expect(res.body.poster).to.be.eql(
{url: 'http://image.url'}
{url: 'http://image.url'},
);
done();
@ -853,7 +853,7 @@ describe('relations - integration', function() {
if (err) return done(err);
expect(res.body).to.be.eql(
{url: 'http://image.url'}
{url: 'http://image.url'},
);
done();
@ -880,7 +880,7 @@ describe('relations - integration', function() {
if (err) return done(err);
expect(res.body).to.be.eql(
{url: 'http://changed.url'}
{url: 'http://changed.url'},
);
done();
@ -903,13 +903,13 @@ describe('relations - integration', function() {
const todoList = app.registry.createModel(
'todoList',
{name: 'string'},
{plural: 'todo-lists'}
{plural: 'todo-lists'},
);
app.model(todoList, {dataSource: 'db'});
const todoItem = app.registry.createModel(
'todoItem',
{content: 'string'}, {forceId: false}
{content: 'string'}, {forceId: false},
);
app.model(todoItem, {dataSource: 'db'});
@ -1021,7 +1021,7 @@ describe('relations - integration', function() {
if (err) return done(err);
expect(res.body).to.be.eql(
{content: 'Todo 3', id: 3}
{content: 'Todo 3', id: 3},
);
done();
@ -1090,19 +1090,19 @@ describe('relations - integration', function() {
before(function defineProductAndCategoryModels() {
const recipe = app.registry.createModel(
'recipe',
{name: 'string'}
{name: 'string'},
);
app.model(recipe, {dataSource: 'db'});
const ingredient = app.registry.createModel(
'ingredient',
{name: 'string'}
{name: 'string'},
);
app.model(ingredient, {dataSource: 'db'});
const photo = app.registry.createModel(
'photo',
{name: 'string'}
{name: 'string'},
);
app.model(photo, {dataSource: 'db'});
@ -1259,7 +1259,7 @@ describe('relations - integration', function() {
if (err) return done(err);
expect(res.body).to.be.eql(
{name: 'Butter', id: test.ingredient3}
{name: 'Butter', id: test.ingredient3},
);
done();
@ -1335,7 +1335,7 @@ describe('relations - integration', function() {
this.put(url)
.expect(200, function(err, res) {
expect(res.body).to.be.eql(
{name: 'Sugar', id: test.ingredient2}
{name: 'Sugar', id: test.ingredient2},
);
done();
@ -1445,35 +1445,35 @@ describe('relations - integration', function() {
const Book = app.registry.createModel(
'Book',
{name: 'string'},
{plural: 'books'}
{plural: 'books'},
);
app.model(Book, {dataSource: 'db'});
const Page = app.registry.createModel(
'Page',
{name: 'string'},
{plural: 'pages'}
{plural: 'pages'},
);
app.model(Page, {dataSource: 'db'});
const Image = app.registry.createModel(
'Image',
{name: 'string'},
{plural: 'images'}
{plural: 'images'},
);
app.model(Image, {dataSource: 'db'});
const Note = app.registry.createModel(
'Note',
{text: 'string'},
{plural: 'notes'}
{plural: 'notes'},
);
app.model(Note, {dataSource: 'db'});
const Chapter = app.registry.createModel(
'Chapter',
{name: 'string'},
{plural: 'chapters'}
{plural: 'chapters'},
);
app.model(Chapter, {dataSource: 'db'});

View File

@ -192,7 +192,7 @@ describe('Replication over REST', function() {
const conflict = new LocalConflict(
conflictedCarId,
LocalCar,
RemoteCar
RemoteCar,
);
conflict.resolveUsingSource(expectHttpError(401, done));
});
@ -202,7 +202,7 @@ describe('Replication over REST', function() {
const conflict = new RemoteConflict(
conflictedCarId,
RemoteCar,
LocalCar
LocalCar,
);
conflict.resolveUsingSource(expectHttpError(401, done));
});
@ -218,7 +218,7 @@ describe('Replication over REST', function() {
const conflict = new LocalConflict(
conflictedCarId,
LocalCar,
RemoteCar
RemoteCar,
);
conflict.resolveUsingSource(done);
});
@ -228,7 +228,7 @@ describe('Replication over REST', function() {
const conflict = new RemoteConflict(
conflictedCarId,
RemoteCar,
LocalCar
LocalCar,
);
conflict.resolveUsingSource(expectHttpError(401, done));
});
@ -407,7 +407,7 @@ describe('Replication over REST', function() {
LocalUser.updateAll(
{id: aliceId},
{fullname: 'Alice Smith'},
done
done,
);
});
}
@ -611,7 +611,7 @@ describe('Replication over REST', function() {
serverCars = cars.map(carToString);
next();
}
},
);
},
], done);
@ -631,7 +631,7 @@ describe('Replication over REST', function() {
clientCars = cars.map(carToString);
next();
}
},
);
},
], done);

View File

@ -30,7 +30,7 @@ describe('Replication / Change APIs', function() {
SourceModel = this.SourceModel = PersistedModel.extend(
'SourceModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true}
{trackChanges: true},
);
SourceModel.attachTo(dataSource);
@ -38,7 +38,7 @@ describe('Replication / Change APIs', function() {
TargetModel = this.TargetModel = PersistedModel.extend(
'TargetModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true}
{trackChanges: true},
);
// NOTE(bajtos) At the moment, all models share the same Checkpoint
@ -85,7 +85,7 @@ describe('Replication / Change APIs', function() {
Model = this.Model = PersistedModel.extend(
'Model-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true, changeCleanupInterval: -1}
{trackChanges: true, changeCleanupInterval: -1},
);
Model.attachTo(dataSource);
@ -105,7 +105,7 @@ describe('Replication / Change APIs', function() {
Model = this.Model = PersistedModel.extend(
'Model-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true, changeCleanupInterval: 10000}
{trackChanges: true, changeCleanupInterval: 10000},
);
Model.attachTo(dataSource);
@ -542,7 +542,7 @@ describe('Replication / Change APIs', function() {
});
cb();
}
},
);
},
], done);
@ -586,7 +586,7 @@ describe('Replication / Change APIs', function() {
expect(changes).to.have.length(0);
done();
}
},
);
});
},
@ -609,7 +609,7 @@ describe('Replication / Change APIs', function() {
TargetModel.modelName,
'1',
{name: '3rd-party'},
cb
cb,
);
} else {
// 2.x connectors require `options`
@ -618,7 +618,7 @@ describe('Replication / Change APIs', function() {
'1',
{name: '3rd-party'},
{}, // options
cb
cb,
);
}
});
@ -633,7 +633,7 @@ describe('Replication / Change APIs', function() {
// resolve the conflict using ours
conflicts[0].resolve(next);
}
},
);
},
@ -654,7 +654,7 @@ describe('Replication / Change APIs', function() {
connector.create(
TargetModel.modelName,
{id: '1', name: '3rd-party'},
cb
cb,
);
} else {
// 2.x connectors require `options`
@ -662,7 +662,7 @@ describe('Replication / Change APIs', function() {
TargetModel.modelName,
{id: '1', name: '3rd-party'},
{}, // options
cb
cb,
);
}
});
@ -677,7 +677,7 @@ describe('Replication / Change APIs', function() {
// resolve the conflict using ours
conflicts[0].resolve(next);
}
},
);
},
@ -701,7 +701,7 @@ describe('Replication / Change APIs', function() {
TargetModel.modelName,
'1',
{name: '3rd-party'},
cb
cb,
);
} else {
// 2.x connectors require `options`
@ -710,7 +710,7 @@ describe('Replication / Change APIs', function() {
'1',
{name: '3rd-party'},
{}, // options
cb
cb,
);
}
});
@ -725,7 +725,7 @@ describe('Replication / Change APIs', function() {
// resolve the conflict using ours
conflicts[0].resolve(next);
}
},
);
},
@ -748,7 +748,7 @@ describe('Replication / Change APIs', function() {
connector.destroy(
TargetModel.modelName,
'1',
cb
cb,
);
} else {
// 2.x connectors require `options`
@ -756,7 +756,7 @@ describe('Replication / Change APIs', function() {
TargetModel.modelName,
'1',
{}, // options
cb
cb,
);
}
});
@ -1078,7 +1078,7 @@ describe('Replication / Change APIs', function() {
function(err) {
if (err) return done(err);
assertChangeRecordedForId(inst.id, done);
}
},
);
});
});
@ -1116,7 +1116,7 @@ describe('Replication / Change APIs', function() {
if (err) return done(err);
assertChangeRecordedForId(inst.id, done);
}
},
);
});
@ -1153,7 +1153,7 @@ describe('Replication / Change APIs', function() {
if (err) return done(err);
assertChangeRecordedForId(inst.id, done);
}
},
);
});
});
@ -1249,7 +1249,7 @@ describe('Replication / Change APIs', function() {
AnotherModel = this.AnotherModel = PersistedModel.extend(
'AnotherModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true}
{trackChanges: true},
);
// NOTE(bajtos) At the moment, all models share the same Checkpoint
@ -1409,7 +1409,7 @@ describe('Replication / Change APIs', function() {
function resolveUsingOurs(conflict, cb) {
conflict.resolveUsingSource(cb);
},
done
done,
);
});
@ -1421,7 +1421,7 @@ describe('Replication / Change APIs', function() {
.to.equal(ClientB.modelName);
conflict.resolveUsingTarget(cb);
},
done
done,
);
});
@ -1430,7 +1430,7 @@ describe('Replication / Change APIs', function() {
function resolveManually(conflict, cb) {
conflict.resolveManually({name: 'manual'}, cb);
},
done
done,
);
});
@ -1439,7 +1439,7 @@ describe('Replication / Change APIs', function() {
function resolveUsingOurs(conflict, cb) {
conflict.resolveUsingSource(cb);
},
done
done,
);
});
@ -1451,7 +1451,7 @@ describe('Replication / Change APIs', function() {
.to.equal(ClientB.modelName);
conflict.resolveUsingTarget(cb);
},
done
done,
);
});
@ -1460,7 +1460,7 @@ describe('Replication / Change APIs', function() {
function resolveManually(conflict, cb) {
conflict.resolveManually(null, cb);
},
done
done,
);
});
@ -1469,7 +1469,7 @@ describe('Replication / Change APIs', function() {
function resolveManually(conflict, cb) {
conflict.resolveManually({name: 'manual'}, cb);
},
done
done,
);
});
});
@ -1613,7 +1613,7 @@ describe('Replication / Change APIs', function() {
OptionsSourceModel = PersistedModel.extend(
'OptionsSourceModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true}
{trackChanges: true},
);
OptionsSourceModel.attachTo(dataSource);
@ -1698,7 +1698,7 @@ describe('Replication / Change APIs', function() {
SourceModel = this.SourceModel = PersistedModel.extend(
'SourceModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true, replicationChunkSize: 1}
{trackChanges: true, replicationChunkSize: 1},
);
SourceModel.attachTo(dataSource);
@ -1706,7 +1706,7 @@ describe('Replication / Change APIs', function() {
TargetModel = this.TargetModel = PersistedModel.extend(
'TargetModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true, replicationChunkSize: 1}
{trackChanges: true, replicationChunkSize: 1},
);
const TargetChange = TargetModel.Change;
@ -1746,7 +1746,7 @@ describe('Replication / Change APIs', function() {
SourceModel = this.SourceModel = PersistedModel.extend(
'SourceModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true}
{trackChanges: true},
);
SourceModel.attachTo(dataSource);
@ -1754,7 +1754,7 @@ describe('Replication / Change APIs', function() {
TargetModel = this.TargetModel = PersistedModel.extend(
'TargetModel-' + tid,
{id: {id: true, type: String, defaultFn: 'guid'}},
{trackChanges: true}
{trackChanges: true},
);
const TargetChange = TargetModel.Change;
@ -1960,7 +1960,7 @@ describe('Replication / Change APIs with custom change properties', function() {
{
trackChanges: true,
additionalChangeModelProperties: {customProperty: {type: 'string'}},
}
},
);
SourceModel.createChangeFilter = function(since, modelFilter) {
@ -1991,7 +1991,7 @@ describe('Replication / Change APIs with custom change properties', function() {
{
trackChanges: true,
additionalChangeModelProperties: {customProperty: {type: 'string'}},
}
},
);
const ChangeModelForTarget = TargetModel.Change;
@ -2031,7 +2031,7 @@ describe('Replication / Change APIs with custom change properties', function() {
},
});
done();
}
},
);
});
@ -2043,7 +2043,7 @@ describe('Replication / Change APIs with custom change properties', function() {
expect(changes).to.have.length(1);
expect(changes[0]).to.have.property('customProperty', '123');
done();
}
},
);
});

View File

@ -55,7 +55,7 @@ describe('role-mapping model', function() {
expect(user.id).to.equal(oneUser.id);
done();
});
}
},
);
});
@ -79,7 +79,7 @@ describe('role-mapping model', function() {
expect(app.id).to.equal(anApp.id);
done();
});
}
},
);
});
@ -103,7 +103,7 @@ describe('role-mapping model', function() {
expect(role.id).to.equal(aRole.id);
done();
});
}
},
);
});

View File

@ -92,7 +92,7 @@ describe('role model', function() {
});
},
], done);
}
},
);
});
});
@ -224,7 +224,7 @@ describe('role model', function() {
// but the matchin role object instead
assert(!!inRole);
next();
}
},
);
},
function(next) {
@ -235,7 +235,7 @@ describe('role model', function() {
if (err) return next(err);
assert(!inRole);
next();
}
},
);
},
function(next) {
@ -246,7 +246,7 @@ describe('role model', function() {
if (err) return next(err);
assert(!inRole);
next();
}
},
);
},
function(next) {
@ -260,7 +260,7 @@ describe('role model', function() {
role.id,
]);
next();
}
},
);
},
function(next) {
@ -275,7 +275,7 @@ describe('role model', function() {
role.name,
]);
next();
}
},
);
},
function(next) {
@ -288,7 +288,7 @@ describe('role model', function() {
Role.EVERYONE,
]);
next();
}
},
);
},
function(next) {
@ -301,7 +301,7 @@ describe('role model', function() {
Role.EVERYONE,
]);
next();
}
},
);
},
function(next) {
@ -314,7 +314,7 @@ describe('role model', function() {
Role.EVERYONE,
]);
next();
}
},
);
},
], done);
@ -400,7 +400,7 @@ describe('role model', function() {
if (err) return next(err);
assert(!!inRole);
next();
}
},
);
},
function(next) {
@ -411,7 +411,7 @@ describe('role model', function() {
if (err) return next(err);
assert(!inRole);
next();
}
},
);
},
function(next) {
@ -425,7 +425,7 @@ describe('role model', function() {
role.id,
]);
next();
}
},
);
},
], done);
@ -469,7 +469,7 @@ describe('role model', function() {
if (err) return next(err);
assert(yes);
next();
}
},
);
},
function(next) {
@ -480,7 +480,7 @@ describe('role model', function() {
if (err) next(err);
assert(yes);
next();
}
},
);
},
function(next) {
@ -491,7 +491,7 @@ describe('role model', function() {
if (err) next(err);
assert(!yes);
next();
}
},
);
},
function(next) {
@ -502,7 +502,7 @@ describe('role model', function() {
if (err) return next(err);
assert(!yes);
next();
}
},
);
},
function(next) {
@ -513,7 +513,7 @@ describe('role model', function() {
if (err) return next(err);
assert(yes);
next();
}
},
);
},
function(next) {
@ -524,7 +524,7 @@ describe('role model', function() {
if (err) return next(err);
assert(yes);
next();
}
},
);
},
function(next) {
@ -535,7 +535,7 @@ describe('role model', function() {
if (err) return next(err);
assert(yes);
next();
}
},
);
},
function(next) {
@ -668,7 +668,7 @@ describe('role model', function() {
},
// passing {ownerRelations: true} will enable the new $owner role resolver
// and hence resolve false when no belongsTo relation is defined
{ownerRelations: true}
{ownerRelations: true},
);
app.model(Album, {dataSource: 'db'});
@ -693,7 +693,7 @@ describe('role model', function() {
// with any belongsTo relation allowing to resolve truthy
const Message = givenModelWithSenderReceiverRelations(
'ModelWithAllRelations',
{ownerRelations: true}
{ownerRelations: true},
);
return givenUsers()
@ -729,7 +729,7 @@ describe('role model', function() {
// with a specified list of belongsTo relations allowing to resolve truthy
const Message = givenModelWithSenderReceiverRelations(
'ModelWithCoercedRelations',
{ownerRelations: ['receiver']}
{ownerRelations: ['receiver']},
);
return givenUsers()
@ -806,7 +806,7 @@ describe('role model', function() {
const Model = app.registry.createModel(
name,
{content: String},
options
options,
);
app.model(Model, {dataSource: 'db'});
return Model;
@ -1091,7 +1091,7 @@ describe('role model', function() {
function(err, p) {
if (err) return callback(err);
callback(p);
}
},
);
},
function(callback) {
@ -1100,7 +1100,7 @@ describe('role model', function() {
function(err, p) {
if (err) return callback(err);
callback(p);
}
},
);
}],
function(err, principles) {

View File

@ -88,7 +88,7 @@ describe('User.password', () => {
},
function onError(err) {
expect(err.message).to.match(/Invalid use.*options.setPassword/);
}
},
);
});
@ -238,7 +238,7 @@ describe('User.password', () => {
function patchNameAndPasswordDirectly() {
return testUser.patchAttributes(
{password: 'new-pass', name: 'New Name'},
{setPassword: true}
{setPassword: true},
);
}
});

View File

@ -96,7 +96,7 @@ describe('User', function() {
// create 2 users: with and without verified email
return Promise.map(
[validCredentials, validCredentialsEmailVerified],
credentials => User.create(credentials)
credentials => User.create(credentials),
).then(users => {
validCredentialsUser = user = users[0];
validCredentialsEmailVerifiedUser = users[1];
@ -147,7 +147,7 @@ describe('User', function() {
expect(err.statusCode).to.equal(422);
expect(err.details.context).to.equal(User.modelName);
expect(err.details.codes.email).to.deep.equal(['presence']);
}
},
);
});
@ -161,7 +161,7 @@ describe('User', function() {
expect(err.statusCode).to.equal(422);
expect(err.details.context).to.equal(User.modelName);
expect(err.details.codes.email).to.deep.equal(['presence']);
}
},
);
});
@ -549,7 +549,7 @@ describe('User', function() {
code: 'PASSWORD_TOO_LONG',
statusCode: 422,
});
}
},
);
});
@ -569,7 +569,7 @@ describe('User', function() {
code: 'PASSWORD_TOO_LONG',
statusCode: 422,
});
}
},
);
});
});
@ -1014,7 +1014,7 @@ describe('User', function() {
userId: validCredentialsUser.pk,
},
});
}
},
);
});
@ -1498,7 +1498,7 @@ describe('User', function() {
code: 'INVALID_PASSWORD',
statusCode: 400,
});
}
},
);
});
@ -1514,7 +1514,7 @@ describe('User', function() {
code: 'USER_NOT_FOUND',
statusCode: 401,
});
}
},
);
});
@ -1602,7 +1602,7 @@ describe('User', function() {
code: 'USER_NOT_FOUND',
statusCode: 401,
});
}
},
);
});
@ -2639,7 +2639,7 @@ describe('User', function() {
function(err, userInstance) {
if (err) return done(err);
assertNoAccessTokens(done);
}
},
);
});
@ -2757,7 +2757,7 @@ describe('User', function() {
if (err) return next(err);
userPartial = partialInstance;
next();
}
},
);
},
function loginPartiallUser(next) {
@ -2773,7 +2773,7 @@ describe('User', function() {
function(err, info) {
if (err) return next(err);
next();
}
},
);
},
function verifyTokensOfPartialUser(next) {
@ -2793,7 +2793,7 @@ describe('User', function() {
function(err, userInstance) {
if (err) return done(err);
assertPreservedTokens(done);
}
},
);
});
@ -2829,9 +2829,9 @@ describe('User', function() {
if (err) return next(err);
next();
});
}
},
);
}
},
);
},
function(next) {
@ -2870,7 +2870,7 @@ describe('User', function() {
if (err) return next(err);
userSpecial = specialInstance;
next();
}
},
);
},
function loginSpecialUser(next) {
@ -2885,7 +2885,7 @@ describe('User', function() {
{email: 'superspecial@example.com'}, function(err, info) {
if (err) return next(err);
next();
}
},
);
},
function verifyTokensOfSpecialUser(next) {