Skip to content

Commit 0622df2

Browse files
committed
Merge pull request #482 from kingcody/fix/jshint
fix(app-jshint): improve jshint usage
2 parents c89364c + 35fcf49 commit 0622df2

File tree

14 files changed

+73
-44
lines changed

14 files changed

+73
-44
lines changed

app/templates/Gruntfile.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,16 @@ module.exports = function (grunt) {
167167
options: {
168168
jshintrc: 'server/.jshintrc'
169169
},
170-
src: [ 'server/{,*/}*.js']
170+
src: [
171+
'server/**/*.js',
172+
'!server/**/*.spec.js'
173+
]
174+
},
175+
serverTest: {
176+
options: {
177+
jshintrc: 'server/.jshintrc-spec'
178+
},
179+
src: ['server/**/*.spec.js']
171180
},
172181
all: [
173182
'<%%= yeoman.client %>/{app,components}/**/*.js',

app/templates/client/app/account(auth)/settings/settings.controller(coffee).coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ angular.module '<%= scriptAppName %>'
88
$scope.email = {}
99

1010
getEmail = (user) ->
11-
return [null, null] unless $scope.user.credentials.length
11+
return [null, null] unless user.credentials.length
1212

13-
for c in $scope.user.credentials when c.type is 'email'
13+
for c in user.credentials when c.type is 'email'
1414
return [c.value, c.confirmed]
1515

1616
[null, null]

app/templates/client/app/account(auth)/settings/settings.controller(js).js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ angular.module('<%= scriptAppName %>')
88
$scope.email = {};
99

1010
var getEmail = function(user) {
11-
if (!$scope.user.credentials.length) {
11+
if (!user.credentials.length) {
1212
return null;
1313
}
1414

15-
for(var i in $scope.user.credentials) {
16-
var c = $scope.user.credentials[i];
17-
if(c.type==='email') return [c.value, c.confirmed];
15+
for(var i in user.credentials) {
16+
var c = user.credentials[i];
17+
if (c.type === 'email') {
18+
return [c.value, c.confirmed];
19+
}
1820
}
1921
};
2022

@@ -36,7 +38,7 @@ angular.module('<%= scriptAppName %>')
3638
$scope.message = '';
3739
});
3840
}
39-
}
41+
};
4042

4143
$scope.changePassword = function() {
4244
$scope.pwd.submitted = true;

app/templates/client/app/admin(auth)/admin.controller(js).js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ angular.module('<%= scriptAppName %>')
88

99
$scope.delete = <% if(filters.uibootstrap) { %>Modal.confirm.delete(<% } %>function(user) {
1010
User.remove({ id: user._id });
11-
_.remove($scope.users, user)
11+
_.remove($scope.users, user);
1212
}<% if(filters.uibootstrap) { %>)<% } %>;
1313
});

app/templates/client/app/main/main.controller(coffee).coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
angular.module '<%= scriptAppName %>'
4-
.controller 'MainCtrl', ($scope, $http<% if(filters.socketio) { %>, socket<% } %><% if(filters.uibootstrap && filters.mongoose) { %>, Modal<% } %>) ->
4+
.controller 'MainCtrl', ($scope, $http<% if(filters.socketio) { %>, socket<% } %>) ->
55
$scope.awesomeThings = []
66

77
$http.get('/api/things').success (awesomeThings) ->
@@ -19,4 +19,4 @@ angular.module '<%= scriptAppName %>'
1919
$http.delete '/api/things/' + thing._id<% } %><% if(filters.socketio) { %>
2020

2121
$scope.$on '$destroy', ->
22-
socket.unsyncUpdates 'thing'<% } %>
22+
socket.unsyncUpdates 'thing'<% } %>

app/templates/client/app/main/main.controller(js).js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.controller('MainCtrl', function ($scope, $http<% if(filters.socketio) { %>, socket<% } %><% if(filters.uibootstrap && filters.mongoose) { %>, Modal<% } %>) {
4+
.controller('MainCtrl', function ($scope, $http<% if(filters.socketio) { %>, socket<% } %>) {
55
$scope.awesomeThings = [];
66

77
$http.get('/api/things').success(function(awesomeThings) {
@@ -24,4 +24,4 @@ angular.module('<%= scriptAppName %>')
2424
$scope.$on('$destroy', function () {
2525
socket.unsyncUpdates('thing');
2626
});<% } %>
27-
});
27+
});

app/templates/server/.jshintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"bitwise": true,
55
"eqeqeq": true,
66
"immed": true,
7-
"latedef": true,
7+
"latedef": "nofunc",
88
"newcap": true,
99
"noarg": true,
1010
"regexp": true,
1111
"undef": true,
1212
"smarttabs": true,
1313
"asi": true,
1414
"debug": true
15-
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": ".jshintrc",
3+
"globals": {
4+
"describe": true,
5+
"it": true,
6+
"before": true,
7+
"beforeEach": true,
8+
"after": true,
9+
"afterEach": true
10+
}
11+
}

app/templates/server/api/thing/thing.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ describe('GET /api/things', function() {
1717
done();
1818
});
1919
});
20-
});
20+
});

app/templates/server/api/user(auth)/user.model.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ UserSchema
8181
// returns only first found email
8282
// TODO: in case of multiple emails, should prioritize confirmed ones
8383
return this.credentials.filter(function(c) {
84-
return c.type==='email';
84+
return c.type === 'email';
8585

8686
})[0].value;
8787
});
@@ -90,21 +90,21 @@ UserSchema
9090
.virtual('emails')
9191
.get(function() {
9292
return this.credentials
93-
.filter(function(c) { return c.type==='email'; })
93+
.filter(function(c) { return c.type === 'email'; })
9494
.map(function(c) { return c.value; });
9595

9696
});
9797

9898
UserSchema
9999
.pre('save', function(next) {<% if (filters.oauth) { %>
100100
if(!this.localEnabled) {
101-
if (Object.keys(this.strategies).length===0) {
101+
if (Object.keys(this.strategies).length === 0) {
102102
return next(new Error('No connected accounts'));
103103
}
104104
return next();
105105
}<% } %>
106106

107-
mongoose.models['User']<% if (filters.oauth) { %>
107+
mongoose.models.User<% if (filters.oauth) { %>
108108
.find({ localEnabled:true })<% } %>
109109
.where('credentials.type').equals('email')
110110
.where('credentials.value').equals(this.email)
@@ -132,15 +132,15 @@ UserSchema.methods = {
132132
},
133133
confirm: function(emailOrPhone, cb) {
134134
this.credentials.forEach(function(c) {
135-
if (c.value===emailOrPhone) {
135+
if (c.value === emailOrPhone) {
136136
c.confirmed = true;
137137
}
138138
});
139139
this.save(cb);
140140
},
141141
changeEmail: function(oldEmail, newEmail, cb) {
142142
this.credentials.forEach(function(c) {
143-
if (c.value===oldEmail) {
143+
if (c.value === oldEmail) {
144144
c.value = newEmail;
145145
c.confirmed = false;
146146
}
@@ -177,14 +177,14 @@ UserSchema.statics = {
177177
var dataFormatted;
178178
dataFormatted = [];
179179

180-
if (data.email != null) {
180+
if (data.email !== null) {
181181
dataFormatted.push({
182182
'credentials.type': 'email',
183183
'credentials.value': data.email
184184
});
185185
}
186186

187-
if (data.phone != null) {
187+
if (data.phone !== null) {
188188
dataFormatted.push({
189189
'credentials.type': 'phone',
190190
'credentials.value': data.phone
@@ -195,11 +195,11 @@ UserSchema.statics = {
195195
.or(dataFormatted)
196196
.exec(function(err, users) {
197197
if (err) return cb(err);
198-
if (users.length===0) return cb(null, null);
198+
if (users.length === 0) return cb(null, null);
199199

200200
cb(null, users);
201201
});
202202
}<% } %>
203203
};
204204

205-
module.exports = mongoose.model('User', UserSchema);
205+
module.exports = mongoose.model('User', UserSchema);

0 commit comments

Comments
 (0)