Skip to content

Commit 560603d

Browse files
committed
chore(eslint): upgrade to eslint 4
1 parent 8690416 commit 560603d

File tree

9 files changed

+209
-220
lines changed

9 files changed

+209
-220
lines changed

Diff for: templates/app/.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224

225225
//ECMAScript 6
226226
"arrow-body-style": [2, "as-needed"], //require braces in arrow function body
227-
"arrow-parens": [2, "as-needed"], //require parens in arrow function arguments
227+
"arrow-parens": 0, //require parens in arrow function arguments
228228
"arrow-spacing": 2, //require space before/after arrow function's arrow
229229
"constructor-super": 2, //verify calls of super() in constructors
230230
"generator-star-spacing": 0, //enforce spacing around the * in generator functions

Diff for: templates/app/_package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"babel-plugin-istanbul": "^4.1.4",
117117
"babel-preset-env": "^1.6.1",
118118
"cross-env": "^5.1.1",
119-
"eslint": "^2.12.0",
119+
"eslint": "^4.19.1",
120120
"del": "^3.0.0",
121121
"gulp": "^3.9.1",
122122
"gulp-babel": "^7.0.0",<% if(filters.ts) { %>

Diff for: templates/app/client/tslint.json(ts)

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"forin": true,
77
"indent": [true, "spaces"],
88
"label-position": true,
9-
"label-undefined": true,
109
"max-line-length": [true, 140],
1110
"no-arg": true,
1211
"no-bitwise": true,
@@ -19,7 +18,6 @@
1918
],
2019
"no-construct": true,
2120
"no-debugger": true,
22-
"no-duplicate-key": true,
2321
"no-duplicate-variable": true,
2422
"no-eval": true,
2523
"no-inferrable-types": true,

Diff for: templates/app/server/api/user(auth)/user.model(mongooseModels).js

+19-20
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,27 @@ UserSchema
9898

9999
// Validate email is not taken
100100
UserSchema
101-
.path('email')
102-
.validate(function(value) {
103-
<%_ if(filters.oauth) { -%>
104-
if(authTypes.indexOf(this.provider) !== -1) {
105-
return true;
106-
}
107-
108-
<%_ } -%>
109-
return this.constructor.findOne({ email: value }).exec()
110-
.then(user => {
111-
if(user) {
112-
if(this.id === user.id) {
101+
.path('email')
102+
.validate(function(value) {<% if(filters.oauth) { %>
103+
if(authTypes.indexOf(this.provider) !== -1) {
113104
return true;
114-
}
115-
return false;
116105
}
117-
return true;
118-
})
119-
.catch(function(err) {
120-
throw err;
121-
});
122-
}, 'The specified email address is already in use.');
106+
107+
<%_ } -%>
108+
return this.constructor.findOne({ email: value }).exec()
109+
.then(user => {
110+
if(user) {
111+
if(this.id === user.id) {
112+
return true;
113+
}
114+
return false;
115+
}
116+
return true;
117+
})
118+
.catch(err => {
119+
throw err;
120+
});
121+
}, 'The specified email address is already in use.');
123122

124123
var validatePresenceOf = function(value) {
125124
return value && value.length;

Diff for: templates/app/server/api/user(auth)/user.model(sequelizeModels).js

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
import crypto from 'crypto';<% if(filters.oauth) { %>
42
var authTypes = ['github', 'twitter', 'facebook', 'google'];<% } %>
53

@@ -124,18 +122,18 @@ export default function(sequelize, DataTypes) {
124122
});
125123
},
126124

127-
/**
128-
* Make salt
129-
*
130-
* @param {Number} [byteSize] - Optional salt byte size, default to 16
131-
* @param {Function} callback
132-
* @return {String}
133-
* @api public
134-
*/
135-
makeSalt(...args) {
136-
let byteSize;
137-
let callback;
138-
let defaultByteSize = 16;
125+
/**
126+
* Make salt
127+
*
128+
* @param {Number} [byteSize] - Optional salt byte size, default to 16
129+
* @param {Function} callback
130+
* @return {String}
131+
* @api public
132+
*/
133+
makeSalt(...args) {
134+
let byteSize;
135+
let callback;
136+
let defaultByteSize = 16;
139137

140138
if(typeof args[0] === 'function') {
141139
callback = args[0];

Diff for: templates/app/server/app.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* Main application file
33
*/
44

5-
'use strict';
6-
75
import express from 'express';<% if (filters.mongoose) { %>
86
import mongoose from 'mongoose';
97
mongoose.Promise = require('bluebird');<% } %><% if (filters.sequelize) { %>
@@ -20,8 +18,8 @@ import seedDatabaseIfNeeded from './config/seed';<% } %>
2018
// Connect to MongoDB
2119
mongoose.connect(config.mongo.uri, config.mongo.options);
2220
mongoose.connection.on('error', function(err) {
23-
console.error('MongoDB connection error: ' + err);
24-
process.exit(-1); // eslint-disable-line no-process-exit
21+
console.error('MongoDB connection error: ' + err);
22+
process.exit(-1); // eslint-disable-line no-process-exit
2523
});
2624
<% } %>
2725
// Setup server
@@ -34,33 +32,32 @@ registerRoutes(app);
3432

3533
// Start server
3634
function startServer() {
37-
app.angularFullstack = server.listen(config.port, config.ip, function() {
38-
console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
39-
});
35+
app.angularFullstack = server.listen(config.port, config.ip, function() {
36+
console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
37+
});
4038
}
4139
<% if(filters.sequelize) { %>
42-
sqldb.sequelize.sync()
43-
<%_ if(filters.ws) { -%>
44-
.then(wsInitPromise)
45-
.then(primus => {
46-
app.primus = primus;
47-
})<% } %><% if(filters.models) { %>
48-
.then(seedDatabaseIfNeeded)<% } %>
49-
.then(startServer)
50-
.catch(err => {
51-
console.log('Server failed to start due to error: %s', err);
52-
});
40+
sqldb.sequelize.sync()<% if(filters.ws) { %>
41+
.then(wsInitPromise)
42+
.then(primus => {
43+
app.primus = primus;
44+
})<% } %><% if(filters.models) { %>
45+
.then(seedDatabaseIfNeeded)<% } %>
46+
.then(startServer)
47+
.catch(err => {
48+
console.log('Server failed to start due to error: %s', err);
49+
});
5350
<% } else { %>
5451
<%_ if(filters.ws) { -%>
5552
wsInitPromise
56-
.then(primus => {
57-
app.primus = primus;
58-
})<% if(filters.models) { %>
59-
.then(seedDatabaseIfNeeded)<% } %>
60-
.then(startServer)
61-
.catch(err => {
62-
console.log('Server failed to start due to error: %s', err);
63-
});<% } %>
53+
.then(primus => {
54+
app.primus = primus;
55+
})<% if(filters.models) { %>
56+
.then(seedDatabaseIfNeeded)<% } %>
57+
.then(startServer)
58+
.catch(err => {
59+
console.log('Server failed to start due to error: %s', err);
60+
});<% } %>
6461
<%_ if(!filters.ws) { -%>
6562
setImmediate(startServer);<% } %>
6663
<% } %>

Diff for: templates/app/server/config/seed(models).js

+58-59
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,73 @@
22
* Populate DB with sample data on server start
33
* to disable, edit config/environment/index.js, and set `seedDB: false`
44
*/
5-
6-
'use strict';<% if(filters.mongooseModels) { %>
5+
<% if(filters.mongooseModels) { %>
76
import Thing from '../api/thing/thing.model';<% if(filters.auth) { %>
87
import User from '../api/user/user.model';<% } %><% } %><% if(filters.sequelizeModels) { %>
98
import sqldb from '../sqldb';<% } %>
109
import config from './environment/';
1110

1211
export default function seedDatabaseIfNeeded() {
13-
if(!config.seedDB) {
14-
return Promise.resolve();
15-
}
12+
if(!config.seedDB) {
13+
return Promise.resolve();
14+
}
1615

17-
<% if(filters.sequelizeModels) { %>let Thing = sqldb.Thing;<% if(filters.auth) { %>
18-
let User = sqldb.User;<% } %><% } %>
16+
<% if(filters.sequelizeModels) { %>let Thing = sqldb.Thing;<% if(filters.auth) { %>
17+
let User = sqldb.User;<% } %><% } %>
1918

20-
let promises = [];
19+
let promises = [];
2120

22-
let thingPromise = <% if(filters.mongooseModels) { %>Thing.find({}).remove()<% } if(filters.sequelizeModels) { %>Thing.destroy({ where: {} })<% } %>
23-
.then(() => {
24-
<% if(filters.mongooseModels) { %>return Thing.create({<% }
25-
if(filters.sequelizeModels) { %>return Thing.bulkCreate([{<% } %>
26-
name: 'Development Tools',
27-
info: 'Integration with popular tools such as Webpack, Babel, TypeScript, Karma, Mocha, ESLint, Protractor, '
28-
+ 'Pug, Stylus, Sass, and Less.'
29-
}, {
30-
name: 'Server and Client integration',
31-
info: 'Built with a powerful and fun stack: MongoDB, Express, Angular, and Node.'
32-
}, {
33-
name: 'Smart Build System',
34-
info: 'Build system ignores `spec` files, allowing you to keep tests alongside code. Automatic injection of '
35-
+ 'scripts and styles into your app.html'
36-
}, {
37-
name: 'Modular Structure',
38-
info: 'Best practice client and server structures allow for more code reusability and maximum scalability'
39-
}, {
40-
name: 'Optimized Build',
41-
info: 'Build process packs up your templates as a single JavaScript payload, minifies your ' +
42-
'scripts/css/images, and rewrites asset names for caching.'
43-
}, {
44-
name: 'Deployment Ready',
45-
info: 'Easily deploy your app to Heroku or Openshift with the heroku and openshift subgenerators'
46-
<% if(filters.mongooseModels) { %>});<% }
47-
if(filters.sequelizeModels) { %>}]);<% } %>
48-
})
49-
.then(() => console.log('finished populating things'))
50-
.catch(err => console.log('error populating things', err));
51-
promises.push(thingPromise);
21+
let thingPromise = <% if(filters.mongooseModels) { %>Thing.find({}).remove()<% } if(filters.sequelizeModels) { %>Thing.destroy({ where: {} })<% } %>
22+
.then(() => {
23+
<% if(filters.mongooseModels) { %>return Thing.create({<% }
24+
if(filters.sequelizeModels) { %>return Thing.bulkCreate([{<% } %>
25+
name: 'Development Tools',
26+
info: 'Integration with popular tools such as Webpack, Babel, TypeScript, Karma, Mocha, ESLint, Protractor, '
27+
+ 'Pug, Stylus, Sass, and Less.'
28+
}, {
29+
name: 'Server and Client integration',
30+
info: 'Built with a powerful and fun stack: MongoDB, Express, Angular, and Node.'
31+
}, {
32+
name: 'Smart Build System',
33+
info: 'Build system ignores `spec` files, allowing you to keep tests alongside code. Automatic injection of '
34+
+ 'scripts and styles into your app.html'
35+
}, {
36+
name: 'Modular Structure',
37+
info: 'Best practice client and server structures allow for more code reusability and maximum scalability'
38+
}, {
39+
name: 'Optimized Build',
40+
info: 'Build process packs up your templates as a single JavaScript payload, minifies your ' +
41+
'scripts/css/images, and rewrites asset names for caching.'
42+
}, {
43+
name: 'Deployment Ready',
44+
info: 'Easily deploy your app to Heroku or Openshift with the heroku and openshift subgenerators'
45+
<% if(filters.mongooseModels) { %>});<% }
46+
if(filters.sequelizeModels) { %>}]);<% } %>
47+
})
48+
.then(() => console.log('finished populating things'))
49+
.catch(err => console.log('error populating things', err));
50+
promises.push(thingPromise);
5251
<% if(filters.auth) { %>
53-
let userPromise = <% if(filters.mongooseModels) { %>User.find({}).remove()<% } if(filters.sequelizeModels) { %>User.destroy({ where: {} })<% } %>
54-
.then(() => {
55-
<% if(filters.mongooseModels) { %>return User.create({<% }
56-
if(filters.sequelizeModels) { %>return User.bulkCreate([{<% } %>
57-
provider: 'local',
58-
name: 'Test User',
59-
60-
password: 'test'
61-
}, {
62-
provider: 'local',
63-
role: 'admin',
64-
name: 'Admin',
65-
66-
password: 'admin'
67-
<% if(filters.mongooseModels) { %>})<% }
68-
if(filters.sequelizeModels) { %>}])<% } %>
69-
.then(() => console.log('finished populating users'))
70-
.catch(err => console.log('error populating users', err));
71-
});
72-
promises.push(userPromise);<% } %>
52+
let userPromise = <% if(filters.mongooseModels) { %>User.find({}).remove()<% } if(filters.sequelizeModels) { %>User.destroy({ where: {} })<% } %>
53+
.then(() => {
54+
<% if(filters.mongooseModels) { %>return User.create({<% }
55+
if(filters.sequelizeModels) { %>return User.bulkCreate([{<% } %>
56+
provider: 'local',
57+
name: 'Test User',
58+
59+
password: 'test'
60+
}, {
61+
provider: 'local',
62+
role: 'admin',
63+
name: 'Admin',
64+
65+
password: 'admin'
66+
<% if(filters.mongooseModels) { %>})<% }
67+
if(filters.sequelizeModels) { %>}])<% } %>
68+
.then(() => console.log('finished populating users'))
69+
.catch(err => console.log('error populating users', err));
70+
});
71+
promises.push(userPromise);<% } %>
7372

74-
return Promise.all(promises);
73+
return Promise.all(promises);
7574
}

0 commit comments

Comments
 (0)