Skip to content

Commit

Permalink
fix(global): fix lint 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Oct 1, 2019
1 parent 2d8a05f commit 79654a0
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 90 deletions.
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const initGlobalConfig = () => {
(_v, k) => k.split('_').slice(2).join('.'),
);
// convert string array from sys to real array
environmentVars = _.mapValues(environmentVars, v => ((v[0] === '[' && v[v.length - 1] === ']') ? v.replace(/'/g, '').slice(1, -1).split(',') : v));
environmentVars = _.mapValues(environmentVars, (v) => ((v[0] === '[' && v[v.length - 1] === ']') ? v.replace(/'/g, '').slice(1, -1).split(',') : v));
const environmentConfigVars = {};
_.forEach(environmentVars, (v, k) => objectPath.set(environmentConfigVars, k, v));
// Merge config files
Expand Down
8 changes: 4 additions & 4 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const startExpress = () => new Promise(((resolve, reject) => {
* Bootstrap the required services
* @return {Object} db, orm, and app instances
*/
const bootstrap = () => new Promise((async (resolve, reject) => {
const bootstrap = () => async (resolve, reject) => {
let orm;
let db;
let app;
Expand All @@ -85,7 +85,7 @@ const bootstrap = () => new Promise((async (resolve, reject) => {
orm,
app,
});
}));
};
// Expose the boostrap function publically
exports.bootstrap = bootstrap;

Expand All @@ -105,7 +105,7 @@ const logConfiguration = () => {
};

// Boot up the server
exports.start = () => new Promise((async (resolve, reject) => {
exports.start = () => async (resolve, reject) => {
let db;
let orm;
let app;
Expand All @@ -128,4 +128,4 @@ exports.start = () => new Promise((async (resolve, reject) => {
} catch (e) {
return reject(e);
}
}));
};
2 changes: 1 addition & 1 deletion lib/middlewares/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const getResultFromJoi = (body, schema, options) => Joi.validate(body, schema, o
/**
* Check model is Valid with Joi schema
*/
module.exports.isValid = schema => (req, res, next) => {
module.exports.isValid = (schema) => (req, res, next) => {
const method = req.method.toLowerCase();
const options = _.clone(config.joi.validationOptions);
if (_.includes(config.joi.supportedMethods, method)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/services/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module.exports.initMiddleware = (app) => {
}));
// Enable logger (morgan) if enabled in the configuration file
if (_.has(config, 'log.format') && process.env.NODE_ENV !== 'test') {
morgan.token('id', req => _.get(req, 'user.id') || 'Unknown id');
morgan.token('email', req => _.get(req, 'user.email') || 'Unknown email');
morgan.token('id', (req) => _.get(req, 'user.id') || 'Unknown id');
morgan.token('email', (req) => _.get(req, 'user.email') || 'Unknown email');
app.use(morgan(logger.getLogFormat(), logger.getMorganOptions()));
}
// Request body parsing middleware should be above methodOverride
Expand Down
6 changes: 3 additions & 3 deletions modules/tasks/repositories/tasks.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.list = () => Task.find().sort('-createdAt').exec();
* @param {Object} task
* @return {Object} task
*/
exports.create = task => new Task(task).save();
exports.create = (task) => new Task(task).save();

/**
* @desc Function to get a task from db
Expand All @@ -33,11 +33,11 @@ exports.get = (id) => {
* @param {Object} task
* @return {Object} task
*/
exports.update = task => new Task(task).save();
exports.update = (task) => new Task(task).save();

/**
* @desc Function to delete a task in db
* @param {Object} task
* @return {Object} confirmation of delete
*/
exports.delete = task => Task.deleteOne({ _id: task.id }).exec();
exports.delete = (task) => Task.deleteOne({ _id: task.id }).exec();
6 changes: 3 additions & 3 deletions modules/users/repositories/user.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.list = () => User.find({}, '-password -providerData').sort('-createdAt')
* @param {Object} user
* @return {Object} user
*/
exports.create = user => new User(user).save();
exports.create = (user) => new User(user).save();

/**
* @desc Function to get a user from db by id or email
Expand All @@ -34,14 +34,14 @@ exports.get = (user) => {
* @param {Object} mongoose input request
* @return {Array} users
*/
exports.search = input => User.find(input).exec();
exports.search = (input) => User.find(input).exec();

/**
* @desc Function to update a user in db
* @param {Object} task
* @return {Object} task
*/
exports.update = user => new User(user).save();
exports.update = (user) => new User(user).save();

/**
* @desc Function to delete a user from db by id or email
Expand Down
2 changes: 1 addition & 1 deletion modules/users/services/oAuth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const UserRepository = require('../repositories/user.repository');

const client = new OAuth2Client(config.google.clientId);
const microsoftValidator = rp.get(config.microsoft.discovery)
.then(res => JSON.parse(res))
.then((res) => JSON.parse(res))
.then(({ jwks_uri: jwksUri }) => new IdTokenVerifier({
issuer: config.microsoft.issuer,
jwksURI: jwksUri,
Expand Down
6 changes: 3 additions & 3 deletions modules/users/services/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ exports.uploadImage = async (req, res, config) => new Promise((resolve, reject)
* @param {String} path
* @return {Promise} result
*/
exports.deleteImage = async path => fs.unlink(path);
exports.deleteImage = async (path) => fs.unlink(path);

/**
* @desc Function to authenticate user)
Expand Down Expand Up @@ -159,7 +159,7 @@ exports.comparePassword = async (userPassword, storedPassword) => bcrypt.compare
* @param {String} password
* @return {String} password hashed
*/
exports.hashPassword = password => bcrypt.hash(String(password), saltRounds);
exports.hashPassword = (password) => bcrypt.hash(String(password), saltRounds);

/**
* @desc Function to hash passwords
Expand All @@ -171,7 +171,7 @@ exports.checkPassword = (password) => {
if (result.score < config.zxcvbn.minimumScore) {
throw new AppError('Password too weak.', {
code: 'SERVICE_ERROR',
details: result.feedback.suggestions.map(s => ({ message: s })),
details: result.feedback.suggestions.map((s) => ({ message: s })),
});
} else {
return password;
Expand Down
Loading

0 comments on commit 79654a0

Please sign in to comment.