Skip to content

Resolve all Warnings and Deprecated Messages with Default Configuration. #2536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 10, 2017
Merged
2 changes: 1 addition & 1 deletion templates/app/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"no-octal-escape": 0, //disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
"no-octal": 0, //disallow use of octal literals
"no-param-reassign": 0, //disallow reassignment of function parameters
"no-process-env": 1, //disallow use of process.env
"no-process-env": 0, //disallow use of process.env
"no-proto": 2, //disallow usage of __proto__ property
"no-redeclare": 2, //disallow declaring the same variable more than once
"no-return-assign": 2, //disallow use of assignment in return statement
Expand Down
3 changes: 1 addition & 2 deletions templates/app/client/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ const ngRoute = require('angular-route');<% } %>
import uiRouter from 'angular-ui-router';<% } %>
<%_ if(filters.uibootstrap) { _%>
import uiBootstrap from 'angular-ui-bootstrap';<% } %>
// import ngMessages from 'angular-messages';
<%_ if(filters.auth) { _%>
import ngValidationMatch from 'angular-validation-match';
import 'angular-validation-match';
<% } %>


Expand Down
9 changes: 6 additions & 3 deletions templates/app/client/components/auth(auth)/auth.service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
'use strict';

import _ from 'lodash';

// @flow
class _User {
_id: string = '';
Expand Down Expand Up @@ -185,9 +188,8 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
* @param {Function|*} callback - optional, function(is)
* @return {Bool|Promise}
*/
isAdmin() {
return Auth.hasRole
.apply(Auth, [].concat.apply(['admin'], arguments));
isAdmin(...args) {
return Auth.hasRole(...Reflect.apply([].concat, ['admin'], args));
},

/**
Expand All @@ -196,6 +198,7 @@ export function AuthService($location, $http, $cookies, $q, appConfig, Util, Use
* @return {Bool}
*/
isAdminSync() {
// eslint-disable-next-line no-sync
return Auth.hasRoleSync('admin');
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export function Modal($rootScope, $uibModal) {
* @param {String} name - name or info to show on modal
* @param {All} - any additional args are passed straight to del callback
*/
return function() {
var args = Array.prototype.slice.call(arguments);
var name = args.shift();
return function(...args) {
var slicedArgs = Reflect.apply(Array.prototype.slice, args);
var name = slicedArgs.shift();
var deleteModal;

deleteModal = openModal({
Expand All @@ -64,7 +64,7 @@ export function Modal($rootScope, $uibModal) {
}, 'modal-danger');

deleteModal.result.then(function(event) {
del.apply(event, args);
Reflect.apply(del, event, slicedArgs);
});
};
}
Expand Down
43 changes: 24 additions & 19 deletions templates/app/server/api/user(auth)/user.model(mongooseModels).js
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@ UserSchema
// Validate email is not taken
UserSchema
.path('email')
.validate(function(value, respond) {
.validate(function(value) {
<%_ if(filters.oauth) { -%>
if(authTypes.indexOf(this.provider) !== -1) {
return respond(true);
return true;
}

<%_ } -%>
return this.constructor.findOne({ email: value }).exec()
.then(user => {
if(user) {
if(this.id === user.id) {
return respond(true);
return true;
}
return respond(false);
return false;
}
return respond(true);
return true;
})
.catch(function(err) {
throw err;
Expand Down Expand Up @@ -197,14 +197,16 @@ UserSchema.methods = {
* @return {String}
* @api public
*/
makeSalt(byteSize, callback) {
var defaultByteSize = 16;
makeSalt(...args) {
let byteSize;
let callback;
let defaultByteSize = 16;

if(typeof arguments[0] === 'function') {
callback = arguments[0];
if(typeof args[0] === 'function') {
callback = args[0];
byteSize = defaultByteSize;
} else if(typeof arguments[1] === 'function') {
callback = arguments[1];
} else if(typeof args[1] === 'function') {
callback = args[1];
} else {
throw new Error('Missing Callback');
}
Expand Down Expand Up @@ -244,17 +246,20 @@ UserSchema.methods = {
var salt = new Buffer(this.salt, 'base64');

if(!callback) {
return crypto.pbkdf2Sync(password, salt, defaultIterations, defaultKeyLength)
// eslint-disable-next-line no-sync
return crypto.pbkdf2Sync(password, salt, defaultIterations,
defaultKeyLength, 'sha1')
.toString('base64');
}

return crypto.pbkdf2(password, salt, defaultIterations, defaultKeyLength, (err, key) => {
if(err) {
return callback(err);
} else {
return callback(null, key.toString('base64'));
}
});
return crypto.pbkdf2(password, salt, defaultIterations, defaultKeyLength,
'sha1', (err, key) => {
if(err) {
return callback(err);
} else {
return callback(null, key.toString('base64'));
}
});
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ export default function(sequelize, DataTypes) {
* @return {String}
* @api public
*/
makeSalt(byteSize, callback) {
var defaultByteSize = 16;
makeSalt(...args) {
let byteSize;
let callback;
let defaultByteSize = 16;

if(typeof arguments[0] === 'function') {
callback = arguments[0];
Expand Down Expand Up @@ -177,6 +179,7 @@ export default function(sequelize, DataTypes) {
var salt = new Buffer(this.salt, 'base64');

if(!callback) {
// eslint-disable-next-line no-sync
return crypto.pbkdf2Sync(password, salt, defaultIterations, defaultKeyLength)
.toString('base64');
}
Expand Down
5 changes: 3 additions & 2 deletions templates/app/server/config/seed(models).js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default function seedDatabaseIfNeeded() {
<% if (filters.mongooseModels) { %>Thing.find({}).remove()<% }
if (filters.sequelizeModels) { %>return Thing.destroy({ where: {} })<% } %>
.then(() => {
<% if (filters.mongooseModels) { %>Thing.create({<% }
if (filters.sequelizeModels) { %>return Thing.bulkCreate([{<% } %>
<% if (filters.mongooseModels) { %>let thing = Thing.create({<% }
if (filters.sequelizeModels) { %>let thing = Thing.bulkCreate([{<% } %>
name: 'Development Tools',
info: 'Integration with popular tools such as Webpack, Gulp, Babel, TypeScript, Karma, '
+ 'Mocha, ESLint, Node Inspector, Livereload, Protractor, Pug, '
Expand Down Expand Up @@ -47,6 +47,7 @@ export default function seedDatabaseIfNeeded() {
+ 'and openshift subgenerators'
<% if (filters.mongooseModels) { %>});<% }
if (filters.sequelizeModels) { %>}]);<% } %>
return thing;
})
.then(() => console.log('finished populating things'))
.catch(err => console.log('error populating things', err));
Expand Down
5 changes: 3 additions & 2 deletions templates/endpoint/basename.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function respondWithResult(res, statusCode) {
function patchUpdates(patches) {
return function(entity) {
try {
// eslint-disable-next-line prefer-reflect
jsonpatch.apply(entity, patches, /*validate*/ true);
} catch(err) {
return Promise.reject(err);
Expand Down Expand Up @@ -98,7 +99,7 @@ export function create(req, res) {
// Upserts the given <%= classedName %> in the DB at the specified ID
export function upsert(req, res) {
if(req.body._id) {
delete req.body._id;
Reflect.deleteProperty(req.body, '_id');
}
<%_ if(filters.mongooseModels) { -%>
return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {new: true, upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %>
Expand All @@ -115,7 +116,7 @@ export function upsert(req, res) {
// Updates an existing <%= classedName %> in the DB
export function patch(req, res) {
if(req.body._id) {
delete req.body._id;
Reflect.deleteProperty(req.body, '_id');
}
<% if(filters.mongooseModels) { %>return <%= classedName %>.findById(req.params.id).exec()<% }
if(filters.sequelizeModels) { %>return <%= classedName %>.find({
Expand Down