Skip to content

Commit

Permalink
fix(eslint): Inconsistent spacing before function parentheses
Browse files Browse the repository at this point in the history
Defines `space-before-function-paren` eslint rule and changes files accordingly.
  • Loading branch information
simison committed Aug 25, 2017
1 parent 83ff29d commit 6acb7d7
Show file tree
Hide file tree
Showing 220 changed files with 2,697 additions and 2,693 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ module.exports = {
'one-var': [0, 'never'],
'one-var-declaration-per-line': [2, 'always'],
'padded-blocks': 0,
'space-before-function-paren': 0,
'space-before-function-paren': ['error', {
'anonymous': 'always',
'named': 'never',
'asyncArrow': 'always'
}],
'space-in-parens': [2, 'never'],
'spaced-comment': [2, 'always'],
strict: 0,
Expand Down
14 changes: 7 additions & 7 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var _ = require('lodash'),
/**
* Get files by glob patterns
*/
var getGlobbedPaths = function(globPatterns, excludes) {
var getGlobbedPaths = function (globPatterns, excludes) {
// URL paths regex
var urlRegex = new RegExp('^(?:[a-z]+:)?\/\/', 'i');

Expand All @@ -21,7 +21,7 @@ var 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 @@ -30,7 +30,7 @@ var getGlobbedPaths = function(globPatterns, excludes) {
} else {
var files = glob.sync(globPatterns);
if (excludes) {
files = files.map(function(file) {
files = files.map(function (file) {
if (_.isArray(excludes)) {
for (var i in excludes) {
if (excludes.hasOwnProperty(i)) {
Expand All @@ -53,7 +53,7 @@ var getGlobbedPaths = function(globPatterns, excludes) {
/**
* Validate NODE_ENV existance
*/
var validateEnvironmentVariable = function() {
var validateEnvironmentVariable = function () {
var environmentFiles = glob.sync('./config/env/' + process.env.NODE_ENV + '.js');

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

Expand Down
8 changes: 4 additions & 4 deletions config/env/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ module.exports = {
profileMinimumLength: 140, // Require User.profile.description to be >=140 chars to send messages
// Strings not allowed as usernames and tag/tribe labels
illegalStrings: ['trustroots', 'trust', 'roots', 're', 're:', 'fwd', 'fwd:', 'reply', 'admin', 'administrator', 'password',
'username', 'unknown', 'anonymous', 'null', 'undefined', 'home', 'signup', 'signin', 'login', 'user',
'edit', 'settings', 'username', 'user', 'demo', 'test', 'support', 'networks', 'profile', 'avatar', 'mini',
'photo', 'account', 'api', 'modify', 'feedback', 'security', 'accounts', 'tribe', 'tag', 'community', 'remove'
],
'username', 'unknown', 'anonymous', 'null', 'undefined', 'home', 'signup', 'signin', 'login', 'user',
'edit', 'settings', 'username', 'user', 'demo', 'test', 'support', 'networks', 'profile', 'avatar', 'mini',
'photo', 'account', 'api', 'modify', 'feedback', 'security', 'accounts', 'tribe', 'tag', 'community', 'remove'
],
// SparkPost webhook API endpoint configuration (`/api/sparkpost/webhook`)
sparkpostWebhook: {
enabled: process.env.SPARKPOST_WEBHOOK_ENABLED || true,
Expand Down
4 changes: 2 additions & 2 deletions config/languages/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function collectLanguages() {
var languagesOrig = require('./languages_orig.json'),
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
Expand Down Expand Up @@ -164,7 +164,7 @@ function generate(targetFile) {
var languages = collectLanguages(),
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
2 changes: 1 addition & 1 deletion config/lib/exponent-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports.sendToDevice = function sendToDevice(tokens, notification) {
var pushPromises = [];

// iterate over tokens
tokens.forEach(function(token) {
tokens.forEach(function (token) {
// dispatch push notification and save returned Promise
pushPromises.push(expo.sendPushNotificationsAsync([{
// Exponent target device token
Expand Down
2 changes: 1 addition & 1 deletion config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports.initLocalVariables = function (app) {
// Assets
if (process.env.NODE_ENV !== 'production') {
app.locals.jsFiles = _.concat(config.files.client.js, 'dist/uib-templates.js');
app.locals.cssFiles = _.map(config.files.client.css, function(file) { return file.replace('/client', ''); });
app.locals.cssFiles = _.map(config.files.client.css, function (file) { return file.replace('/client', ''); });
}

// Get 'git rev-parse --short HEAD' (the latest git commit hash) to use as a cache buster
Expand Down
2 changes: 1 addition & 1 deletion config/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require('winston-papertrail').Papertrail;
var papertrailConfig = _.get(config, 'log.papertrail');

// Add the `logFormat()` function to the papertrail config
papertrailConfig.logFormat = function(level, message) {
papertrailConfig.logFormat = function (level, message) {
return level + ': ' + message;
};

Expand Down
10 changes: 5 additions & 5 deletions config/lib/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ var config = require('../config'),
mongoose = require('mongoose');

// Load the mongoose models
module.exports.loadModels = function(callback) {
module.exports.loadModels = function (callback) {
// Globbing model files
config.files.server.models.forEach(function(modelPath) {
config.files.server.models.forEach(function (modelPath) {
require(path.resolve(modelPath));
});

if (callback) callback();
};

// Initialize Mongoose
module.exports.connect = function(callback) {
module.exports.connect = function (callback) {
var _this = this;

// Use native promises
Expand All @@ -44,8 +44,8 @@ module.exports.connect = function(callback) {
});
};

module.exports.disconnect = function(callback) {
mongoose.disconnect(function(err) {
module.exports.disconnect = function (callback) {
mongoose.disconnect(function (err) {
console.info(chalk.yellow('Disconnected from MongoDB.'));
callback(err);
});
Expand Down
22 changes: 11 additions & 11 deletions config/lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ var path = require('path'),

var agenda;

exports.start = function(options, callback) {
exports.start = function (options, callback) {

// Don't initialise Agenda outisde `start()`, because we might miss `ready` event otherwise.
agenda = require(path.resolve('./config/lib/agenda'));

agenda.on('ready', function() {
agenda.on('ready', function () {

// Define jobs

Expand Down Expand Up @@ -100,7 +100,7 @@ exports.start = function(options, callback) {
});

// Log finished jobs
agenda.on('success', function(job) {
agenda.on('success', function (job) {
if (process.env.NODE_ENV !== 'test') {

var statsObject = {
Expand All @@ -116,7 +116,7 @@ exports.start = function(options, callback) {
};

// Send job failure to stats servers
statService.stat(statsObject, function() {
statService.stat(statsObject, function () {
// Log also to console
if (process.env.NODE_ENV !== 'test') {
console.log('[Worker] Agenda job [%s] %s finished.',
Expand All @@ -127,7 +127,7 @@ exports.start = function(options, callback) {
});

// Error reporting and retry logic
agenda.on('fail', function(err, job) {
agenda.on('fail', function (err, job) {

var extraMessage = '';

Expand Down Expand Up @@ -158,7 +158,7 @@ exports.start = function(options, callback) {
};

// Send job failure to stats servers
statService.stat(statsObject, function() {
statService.stat(statsObject, function () {
// Log also to console

if (process.env.NODE_ENV !== 'test') {
Expand All @@ -176,20 +176,20 @@ exports.start = function(options, callback) {
* Attempt to unlock Agenda jobs that were stuck due server restart
* See https://github.com/agenda/agenda/issues/410
*/
exports.unlockAgendaJobs = function(callback) {
exports.unlockAgendaJobs = function (callback) {

if (process.env.NODE_ENV !== 'test') {
console.log('[Worker] Attempting to unlock locked Agenda jobs...');
}

// 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.error(err);
return callback(err);
}

// agenda.on('ready', function() {
// agenda.on('ready', function() {

// Re-use Agenda's MongoDB connection
// var agendaJobs = agenda._mdb.collection('agendaJobs');
Expand Down Expand Up @@ -230,7 +230,7 @@ exports.unlockAgendaJobs = function(callback) {
/**
* Used for testing
*/
exports.removeExitListeners = function() {
exports.removeExitListeners = function () {
process.removeListener('SIGTERM', gracefulExit);
process.removeListener('SIGINT', gracefulExit);
};
Expand All @@ -248,7 +248,7 @@ function addExitListeners() {
*/
function gracefulExit() {
console.log('[Worker] Stopping Agenda...');
agenda.stop(function() {
agenda.stop(function () {
console.log('[Worker] Agenda stopped.');
process.exit(0);
});
Expand Down
Loading

0 comments on commit 6acb7d7

Please sign in to comment.