Skip to content
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

Update dependency prettier to v2 #1330

Merged
merged 2 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/db-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if (process.env.NODE_ENV === 'production') {
// Use mongoose configuration
const mongooseService = require('../config/lib/mongoose.js');

mongooseService.connect(function(db) {
mongooseService.dropDatabase(db, function() {
mongooseService.connect(function (db) {
mongooseService.dropDatabase(db, function () {
mongooseService.disconnect();
});
});
48 changes: 24 additions & 24 deletions bin/db-maintenance/archive-done-agenda-jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ function countTotals(done) {
.find()
.count()
.then(
function(sourceCount) {
function (sourceCount) {
console.log('\nSource count: ' + sourceCount);
targetCollection
.find()
.count()
.then(
function(targetCount) {
function (targetCount) {
console.log('Target count: ' + targetCount);
console.log('Total: ' + (sourceCount + targetCount) + '\n');
done();
},
function(err) {
function (err) {
console.log(
'Could not get count of documents in target collection: ' +
targetCollectionName,
Expand All @@ -64,7 +64,7 @@ function countTotals(done) {
},
);
},
function(err) {
function (err) {
console.log(
'Could not get count of documents in source collection: ' +
sourceCollectionName,
Expand All @@ -77,11 +77,11 @@ function countTotals(done) {
function moveDoc(doc, callback) {
if (doc) {
// Process doc
insertDocument(doc, function(err) {
insertDocument(doc, function (err) {
if (err) {
return callback(err);
}
removeDocument(doc, function(err) {
removeDocument(doc, function (err) {
if (err) {
return callback(err);
}
Expand All @@ -102,9 +102,9 @@ function removeDocument(doc, callback) {
async.waterfall(
[
// Connect
function(done) {
function (done) {
// Use connect method to connect to the server
MongoClient.connect(config.db.uri, function(err, db) {
MongoClient.connect(config.db.uri, function (err, db) {
if (err) {
console.log(chalk.red('Could not connect to MongoDB!'));
return done(err);
Expand All @@ -122,12 +122,12 @@ async.waterfall(
},

// Count total
function(done) {
function (done) {
console.log('Counting docs...');
sourceCollection
.find(filter)
.count()
.then(function(count) {
.then(function (count) {
total = count;
if (total <= 0) {
console.log('No documents to transfer.');
Expand All @@ -149,28 +149,28 @@ async.waterfall(
},

// Show how many docs each collection has currently
function(done) {
function (done) {
if (total <= 0) {
return done();
}
countTotals(done);
},

// Fetch docs and get the cursor
function(done) {
function (done) {
if (total <= 0) {
return done(null, null);
}

console.log('Fetching docs for transfer...\n');
// cursor for streaming from mongoDB
sourceCollection.find(filter, function(err, cursor) {
sourceCollection.find(filter, function (err, cursor) {
done(null, cursor);
});
},

// process docs
function(cursor, done) {
function (cursor, done) {
// preparation for async.doWhilst function
//
// settings how often the progress will be printed to console
Expand All @@ -180,14 +180,14 @@ async.waterfall(
let progress = 1; // progress counter

// this is the test for async.doWhilst
const testKeepGoing = function() {
const testKeepGoing = function () {
return keepGoing;
};

// here we process the doc and print progress sometimes
function saveMessageAndRunCounter(doc, callback) {
// updating the message stat
moveDoc(doc, function(err) {
moveDoc(doc, function (err) {
if (err) {
return callback(err);
}
Expand All @@ -211,7 +211,7 @@ async.waterfall(
// the iteratee (function to run in each step) of async.doWhilst
function processNext(callback) {
// getting the next message from mongodb
cursor.next(function(err, msg) {
cursor.next(function (err, msg) {
// We've passed the end of the cursor
if (!msg) {
console.log('\nDone with the queue');
Expand All @@ -236,11 +236,11 @@ async.waterfall(
}

cursor.close().then(
function() {
function () {
console.log('\nCursor closed.');
done(null, progress);
},
function(err) {
function (err) {
console.log('\nFailed to close cursor at the end of the script:');
console.error(err);
done(null, progress);
Expand All @@ -261,16 +261,16 @@ async.waterfall(
},

// Show how many docs each collection has currently
function(progress, done) {
function (progress, done) {
if (total <= 0) {
return done();
}
countTotals(function() {
countTotals(function () {
done(null, progress);
});
},
],
function(err, totalProcessed) {
function (err, totalProcessed) {
if (err) {
console.log('\nFinal error:');
console.error(err);
Expand All @@ -288,11 +288,11 @@ async.waterfall(
if (dbConnection) {
console.log('Closing db...');
dbConnection.close().then(
function() {
function () {
console.log('\nDisconnected from MongoDB');
process.exit(0);
},
function(err) {
function (err) {
console.log('\nFailed to disconnect DB:');
console.error(err);
process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion bin/fillTestData/Tribes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const argv = yargs.usage(
'node $0 100 --limit',
'Adds up to 100 randomly seeded tribes to the database (eg. If 20 tribes already exist, 80 tribes will be added)',
)
.check(function(argv) {
.check(function (argv) {
if (argv.numberOfTribes < 1) {
throw new Error('Error: Number of tribes should be greater than 0');
}
Expand Down
8 changes: 4 additions & 4 deletions bin/fillTestData/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require(path.resolve('./modules/offers/server/models/offer.server.model'));
const argv = yargs.usage(
'$0 <numberOfUsers>',
'Seed database with number of tribes',
function(yargs) {
function (yargs) {
return yargs
.positional('numberOfUsers', {
describe: 'Number of users to add',
Expand Down Expand Up @@ -51,7 +51,7 @@ const argv = yargs.usage(
'node $0 100 --limit',
'Adds up to 100 randomly seeded users to the database (eg. If 20 users already exist, 80 users will be added)',
)
.check(function(argv) {
.check(function (argv) {
if (argv.numberOfUsers < 1) {
throw new Error('Error: Number of users should be greater than 0');
}
Expand Down Expand Up @@ -212,7 +212,7 @@ function addUsers() {
.then(results => {
[userCount, tribes] = results;
})
.catch(function(err) {
.catch(function (err) {
console.log(err);
});
} // getUsersAndTribes()
Expand Down Expand Up @@ -308,7 +308,7 @@ function addUsers() {
}

// Save the user
user.save(function(err) {
user.save(function (err) {
savedUsers++;
process.stdout.write('.');

Expand Down
14 changes: 7 additions & 7 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const path = require('path');
/**
* Get files by glob patterns
*/
const getGlobbedPaths = function(globPatterns, excludes) {
const getGlobbedPaths = function (globPatterns, excludes) {
// URL paths regex
const urlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');

Expand All @@ -19,7 +19,7 @@ const getGlobbedPaths = function(globPatterns, excludes) {

// If glob pattern is array so we use each pattern in a recursive way, otherwise we use glob
if (_.isArray(globPatterns)) {
globPatterns.forEach(function(globPattern) {
globPatterns.forEach(function (globPattern) {
output = _.union(output, getGlobbedPaths(globPattern, excludes));
});
} else if (_.isString(globPatterns)) {
Expand All @@ -28,7 +28,7 @@ const getGlobbedPaths = function(globPatterns, excludes) {
} else {
let files = glob.sync(globPatterns);
if (excludes) {
files = files.map(function(file) {
files = files.map(function (file) {
if (_.isArray(excludes)) {
for (const i in excludes) {
if (_.has(excludes, i)) {
Expand All @@ -51,7 +51,7 @@ const getGlobbedPaths = function(globPatterns, excludes) {
/**
* Validate NODE_ENV existance
*/
const validateEnvironmentVariable = function() {
const validateEnvironmentVariable = function () {
const environmentFiles = glob.sync(`./config/env/${process.env.NODE_ENV}.js`);

console.log();
Expand Down Expand Up @@ -82,7 +82,7 @@ const validateEnvironmentVariable = function() {
/**
* Initialize global configuration files
*/
const initGlobalConfigFolders = function(config) {
const initGlobalConfigFolders = function (config) {
// Appending files
config.folders = {
server: {},
Expand All @@ -92,7 +92,7 @@ const initGlobalConfigFolders = function(config) {
/**
* Initialize global configuration files
*/
const initGlobalConfigFiles = function(config, assets) {
const initGlobalConfigFiles = function (config, assets) {
// Appending files
config.files = {
server: {},
Expand All @@ -114,7 +114,7 @@ const initGlobalConfigFiles = function(config, assets) {
/**
* Initialize global configuration
*/
const initGlobalConfig = function() {
const initGlobalConfig = function () {
// Validate NDOE_ENV existance
validateEnvironmentVariable();

Expand Down
4 changes: 2 additions & 2 deletions config/languages/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function collectLanguages() {
const languagesOrig = require('./languages_orig.json');
const languagesNew = {};

_.forEach(languagesOrig, function(language) {
_.forEach(languagesOrig, function (language) {
// Pick a key
// Most of the time `iso_639_2b` is what we need but it's not always available
const key = getKey(language);
Expand Down Expand Up @@ -168,7 +168,7 @@ function generate(targetFile) {
const languages = collectLanguages();
const languagesString = JSON.stringify(languages);

fs.writeFile(targetFile, languagesString, function(err) {
fs.writeFile(targetFile, languagesString, function (err) {
if (err) {
console.error('Failed saving languages to file `' + targetFile + '`');
console.error(err);
Expand Down
6 changes: 3 additions & 3 deletions config/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (config.sentry.enabled) {
mongoose.loadModels();

module.exports.init = function init(callback) {
mongoose.connect(function(connection) {
mongoose.connect(function (connection) {
// Initialize express
const app = express.init(connection);
if (callback) callback(app, connection, config);
Expand All @@ -25,7 +25,7 @@ module.exports.init = function init(callback) {
module.exports.start = function start(callback) {
const _this = this;

_this.init(function(app, db, config) {
_this.init(function (app, db, config) {
const listenArgs = [];
if (config.fd) {
// Start the app by listening on a file descriptor (useful for systemd socket activation)
Expand All @@ -34,7 +34,7 @@ module.exports.start = function start(callback) {
// Start the app by listening on <port> at <host>
listenArgs.push(config.port, config.host);
}
app.listen(...listenArgs, function() {
app.listen(...listenArgs, function () {
// Check in case mailer config is still set to default values (a common problem)
if (
config.mailer.service &&
Expand Down
4 changes: 2 additions & 2 deletions config/lib/exponent-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports.sendToDevice = function sendToDevice(tokens, notification) {
const notifications = [];

// iterate over tokens
tokens.forEach(function(token) {
tokens.forEach(function (token) {
if (!token || !Expo.isExpoPushToken(token)) {
log('error', 'Invalid or missing Expo push notification token #mg9hwf', {
token: token,
Expand Down Expand Up @@ -93,7 +93,7 @@ exports.sendToDevice = function sendToDevice(tokens, notification) {

const promises = [];

chunks.forEach(function(chunk) {
chunks.forEach(function (chunk) {
promises.push(expo.sendPushNotificationsAsync(chunk));
});

Expand Down
Loading