Skip to content

Commit c3ab932

Browse files
authored
Merge pull request #2632 from strongloop/eslint2
Update eslint infrastructure
2 parents ef0478c + 06cb481 commit c3ab932

File tree

113 files changed

+1275
-1151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1275
-1151
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ignoreComments": true,
66
"ignoreUrls": true,
77
"ignorePattern": "^\\s*var\\s.+=\\s*(require\\s*\\()|(/)"
8-
}]
8+
}],
9+
"no-unused-expressions": "off",
910
}
1011
}

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// License text available at https://opensource.org/licenses/MIT
55

66
/*global module:false*/
7+
'use strict';
78
module.exports = function(grunt) {
89
// Do not report warnings from unit-tests exercising deprecated paths
910
process.env.NO_DEPRECATION = 'loopback';
@@ -201,7 +202,7 @@ module.exports = function(grunt) {
201202
},
202203

203204
// Add browserify to preprocessors
204-
preprocessors: { 'test/e2e/*': ['browserify'] },
205+
preprocessors: {'test/e2e/*': ['browserify']},
205206
},
206207
},
207208
},

common/models/access-token.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Module Dependencies.
88
*/
99

10+
'use strict';
1011
var g = require('../../lib/globalize');
1112
var loopback = require('../../lib/loopback');
1213
var assert = require('assert');
@@ -47,7 +48,7 @@ module.exports = function(AccessToken) {
4748
* ```
4849
*/
4950

50-
AccessToken.ANONYMOUS = new AccessToken({ id: '$anonymous' });
51+
AccessToken.ANONYMOUS = new AccessToken({id: '$anonymous'});
5152

5253
/**
5354
* Create a cryptographically random access token id.

common/models/acl.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6+
'use strict';
67
/*!
78
Schema ACL options
8-
99
Object level permissions, for example, an album owned by a user
10-
1110
Factors to be authorized against:
12-
1311
* model name: Album
1412
* model instance properties: userId of the album, friends, shared
1513
* methods
@@ -21,19 +19,15 @@
2119
** none
2220
** everyone
2321
** relations: owner/friend/granted
24-
2522
Class level permissions, for example, Album
2623
* model name: Album
2724
* methods
28-
2925
URL/Route level permissions
3026
* url pattern
3127
* application id
3228
* ip addresses
3329
* http headers
34-
3530
Map to oAuth 2.0 scopes
36-
3731
*/
3832

3933
var g = require('../../lib/globalize');
@@ -331,10 +325,10 @@ module.exports = function(ACL) {
331325
principalId = principalId.toString();
332326
}
333327
property = property || ACL.ALL;
334-
var propertyQuery = (property === ACL.ALL) ? undefined : { inq: [property, ACL.ALL] };
328+
var propertyQuery = (property === ACL.ALL) ? undefined : {inq: [property, ACL.ALL]};
335329
accessType = accessType || ACL.ALL;
336330
var accessTypeQuery = (accessType === ACL.ALL) ? undefined :
337-
{ inq: [accessType, ACL.ALL, ACL.EXECUTE] };
331+
{inq: [accessType, ACL.ALL, ACL.EXECUTE]};
338332

339333
var req = new AccessRequest(model, property, accessType);
340334

@@ -352,8 +346,8 @@ module.exports = function(ACL) {
352346
}
353347

354348
var self = this;
355-
this.find({ where: { principalType: principalType, principalId: principalId,
356-
model: model, property: propertyQuery, accessType: accessTypeQuery }},
349+
this.find({where: {principalType: principalType, principalId: principalId,
350+
model: model, property: propertyQuery, accessType: accessTypeQuery}},
357351
function(err, dynACLs) {
358352
if (err) {
359353
if (callback) callback(err);
@@ -408,21 +402,21 @@ module.exports = function(ACL) {
408402
var modelName = context.modelName;
409403

410404
var methodNames = context.methodNames;
411-
var propertyQuery = (property === ACL.ALL) ? undefined : { inq: methodNames.concat([ACL.ALL]) };
405+
var propertyQuery = (property === ACL.ALL) ? undefined : {inq: methodNames.concat([ACL.ALL])};
412406

413407
var accessTypeQuery = (accessType === ACL.ALL) ?
414408
undefined :
415409
(accessType === ACL.REPLICATE) ?
416-
{ inq: [ACL.REPLICATE, ACL.WRITE, ACL.ALL] } :
417-
{ inq: [accessType, ACL.ALL] };
410+
{inq: [ACL.REPLICATE, ACL.WRITE, ACL.ALL]} :
411+
{inq: [accessType, ACL.ALL]};
418412

419413
var req = new AccessRequest(modelName, property, accessType, ACL.DEFAULT, methodNames);
420414

421415
var effectiveACLs = [];
422416
var staticACLs = self.getStaticACLs(model.modelName, property);
423417

424-
this.find({ where: { model: model.modelName, property: propertyQuery,
425-
accessType: accessTypeQuery }}, function(err, acls) {
418+
this.find({where: {model: model.modelName, property: propertyQuery,
419+
accessType: accessTypeQuery}}, function(err, acls) {
426420
if (err) {
427421
if (callback) callback(err);
428422
return;
@@ -525,15 +519,15 @@ module.exports = function(ACL) {
525519
this.resolveRelatedModels();
526520
switch (type) {
527521
case ACL.ROLE:
528-
this.roleModel.findOne({ where: { or: [{ name: id }, { id: id }] }}, cb);
522+
this.roleModel.findOne({where: {or: [{name: id}, {id: id}]}}, cb);
529523
break;
530524
case ACL.USER:
531525
this.userModel.findOne(
532-
{ where: { or: [{ username: id }, { email: id }, { id: id }] }}, cb);
526+
{where: {or: [{username: id}, {email: id}, {id: id}]}}, cb);
533527
break;
534528
case ACL.APP:
535529
this.applicationModel.findOne(
536-
{ where: { or: [{ name: id }, { email: id }, { id: id }] }}, cb);
530+
{where: {or: [{name: id}, {email: id}, {id: id}]}}, cb);
537531
break;
538532
default:
539533
process.nextTick(function() {

common/models/application.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6+
'use strict';
67
var assert = require('assert');
78
var utils = require('../../lib/utils');
89

@@ -70,18 +71,6 @@ function generateKey(hmacKey, algorithm, encoding) {
7071
*/
7172

7273
module.exports = function(Application) {
73-
// Workaround for https://github.com/strongloop/loopback/issues/292
74-
Application.definition.rawProperties.created.default =
75-
Application.definition.properties.created.default = function() {
76-
return new Date();
77-
};
78-
79-
// Workaround for https://github.com/strongloop/loopback/issues/292
80-
Application.definition.rawProperties.modified.default =
81-
Application.definition.properties.modified.default = function() {
82-
return new Date();
83-
};
84-
8574
/*!
8675
* A hook to generate keys before creation
8776
* @param next
@@ -126,7 +115,7 @@ module.exports = function(Application) {
126115
}
127116
cb = cb || utils.createPromiseCallback();
128117

129-
var props = { owner: owner, name: name };
118+
var props = {owner: owner, name: name};
130119
for (var p in options) {
131120
if (!(p in props)) {
132121
props[p] = options[p];

common/models/application.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@
118118
"description": "Status of the application, production/sandbox/disabled"
119119
},
120120

121-
"created": "date",
122-
"modified": "date"
121+
"created": {
122+
"type": "date",
123+
"defaultFn": "now"
124+
},
125+
"modified": {
126+
"type": "date",
127+
"defaultFn": "now"
128+
}
123129
}
124130
}

common/models/change.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
* Module Dependencies.
88
*/
99

10+
'use strict';
1011
var g = require('../../lib/globalize');
1112
var PersistedModel = require('../../lib/loopback').PersistedModel;
1213
var loopback = require('../../lib/loopback');
1314
var utils = require('../../lib/utils');
1415
var crypto = require('crypto');
15-
var CJSON = { stringify: require('canonical-json') };
16+
var CJSON = {stringify: require('canonical-json')};
1617
var async = require('async');
1718
var assert = require('assert');
1819
var debug = require('debug')('loopback:change');
@@ -113,7 +114,7 @@ module.exports = function(Change) {
113114

114115
var msg = g.f('Cannot rectify %s changes:\n%s', modelName, desc);
115116
err = new Error(msg);
116-
err.details = { errors: errors };
117+
err.details = {errors: errors};
117118
return callback(err);
118119
}
119120
callback();
@@ -404,7 +405,7 @@ module.exports = function(Change) {
404405
callback = callback || utils.createPromiseCallback();
405406

406407
if (!Array.isArray(remoteChanges) || remoteChanges.length === 0) {
407-
callback(null, { deltas: [], conflicts: [] });
408+
callback(null, {deltas: [], conflicts: []});
408409
return callback.promise;
409410
}
410411
var remoteChangeIndex = {};
@@ -419,7 +420,7 @@ module.exports = function(Change) {
419420
this.find({
420421
where: {
421422
modelName: modelName,
422-
modelId: { inq: modelIds },
423+
modelId: {inq: modelIds},
423424
},
424425
}, function(err, allLocalChanges) {
425426
if (err) return callback(err);
@@ -674,7 +675,7 @@ module.exports = function(Change) {
674675
if (err) return cb(err);
675676
conflict.SourceModel.updateLastChange(
676677
conflict.modelId,
677-
{ prev: targetChange.rev },
678+
{prev: targetChange.rev},
678679
cb);
679680
});
680681
};
@@ -708,7 +709,7 @@ module.exports = function(Change) {
708709
}
709710
var inst = new conflict.SourceModel(
710711
target.toObject(),
711-
{ persisted: true });
712+
{persisted: true});
712713
inst.save(done);
713714
});
714715

common/models/checkpoint.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Module Dependencies.
88
*/
99

10+
'use strict';
1011
var assert = require('assert');
1112

1213
/**
@@ -41,8 +42,8 @@ module.exports = function(Checkpoint) {
4142
};
4243

4344
Checkpoint._getSingleton = function(cb) {
44-
var query = { limit: 1 }; // match all instances, return only one
45-
var initialData = { seq: 1 };
45+
var query = {limit: 1}; // match all instances, return only one
46+
var initialData = {seq: 1};
4647
this.findOrCreate(query, initialData, cb);
4748
};
4849

@@ -59,7 +60,7 @@ module.exports = function(Checkpoint) {
5960
var originalSeq = cp.seq;
6061
cp.seq++;
6162
// Update the checkpoint but only if it was not changed under our hands
62-
Checkpoint.updateAll({ id: cp.id, seq: originalSeq }, { seq: cp.seq }, function(err, info) {
63+
Checkpoint.updateAll({id: cp.id, seq: originalSeq}, {seq: cp.seq}, function(err, info) {
6364
if (err) return cb(err);
6465
// possible outcomes
6566
// 1) seq was updated to seq+1 - exactly what we wanted!

common/models/email.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6-
/**
7-
* Email model. Extends LoopBack base [Model](#model-new-model).
8-
* @property {String} to Email addressee. Required.
9-
* @property {String} from Email sender address. Required.
10-
* @property {String} subject Email subject string. Required.
11-
* @property {String} text Text body of email.
12-
* @property {String} html HTML body of email.
13-
*
14-
* @class Email
15-
* @inherits {Model}
16-
*/
17-
6+
'use strict';
187
var g = require('../../lib/globalize');
198

9+
/**
10+
* Email model. Extends LoopBack base [Model](#model-new-model).
11+
* @property {String} to Email addressee. Required.
12+
* @property {String} from Email sender address. Required.
13+
* @property {String} subject Email subject string. Required.
14+
* @property {String} text Text body of email.
15+
* @property {String} html HTML body of email.
16+
*
17+
* @class Email
18+
* @inherits {Model}
19+
*/
20+
2021
module.exports = function(Email) {
2122
/**
2223
* Send an email with the given `options`.

0 commit comments

Comments
 (0)