Skip to content

Commit

Permalink
fix(deps): Update ESLint and Prettier + plugins (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienjoly committed Aug 27, 2020
1 parent 4ec056d commit b8c7728
Show file tree
Hide file tree
Showing 258 changed files with 4,818 additions and 4,880 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@
"rules": {
"prettier/prettier": "error"
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
],
"env": {
"browser": true,
"node": true,
"es6": true
}
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
singleQuote: true
singleQuote: true,
};
32 changes: 16 additions & 16 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (process.env.NODE_ENV === "production") {
*/

function makeColorConsole(fct, color) {
return function() {
return function () {
for (var i in arguments)
if (arguments[i] instanceof Object || arguments[i] instanceof Array)
arguments[i] = util.inspect(arguments[i]);
Expand All @@ -30,7 +30,7 @@ function makeColorConsole(fct, color) {
}

function makeErrorLog(fct, type) {
return function() {
return function () {
fct(
type === 'Warning' ? '⚠' : '❌',
type,
Expand Down Expand Up @@ -87,23 +87,23 @@ var params = (process.appParams = {
uploadDirName: 'upload_data',
uAvatarImgDirName: 'uAvatarImg',
uCoverImgDirName: 'uCoverImg',
uPlaylistDirName: 'uPlaylistImg'
}
uPlaylistDirName: 'uPlaylistImg',
},
});

var FLAGS = {
'--no-color': function() {
'--no-color': function () {
process.appParams.color = false;
},
'--fakeEmail': function() {
'--fakeEmail': function () {
params.emailModule = '';
},
'--emailAdminsOnly': function() {
'--emailAdminsOnly': function () {
params.emailModule = 'emailAdminsOnly';
},
'--runner': function() {
'--runner': function () {
/* ignore this parameter from start-stop-daemon -- note: still required? */
}
},
};

// when db is read
Expand All @@ -124,20 +124,20 @@ function start() {
const sessionMiddleware = session({
secret: process.env.WHYD_SESSION_SECRET.substr(),
store: new MongoStore({
url: makeMongoUrl(params)
url: makeMongoUrl(params),
}),
cookie: {
maxAge: 365 * 24 * 60 * 60 * 1000 // cookies expire in 1 year (provided in milliseconds)
maxAge: 365 * 24 * 60 * 60 * 1000, // cookies expire in 1 year (provided in milliseconds)
},
name: 'whydSid',
resave: false, // required, cf https://www.npmjs.com/package/express-session#resave
saveUninitialized: false // required, cf https://www.npmjs.com/package/express-session#saveuninitialized
saveUninitialized: false, // required, cf https://www.npmjs.com/package/express-session#saveuninitialized
});
var serverOptions = {
port: params.port,
appDir: __dirname,
sessionMiddleware,
errorHandler: function(request, params, response, statusCode) {
errorHandler: function (request, params, response, statusCode) {
// to render 404 and 401 error pages from server/router
console.log('rendering server error page', statusCode);
require('./app/templates/error.js').renderErrorResponse(
Expand All @@ -149,8 +149,8 @@ function start() {
},
uploadSettings: {
uploadDir: params.paths.uploadDirName, // 'upload_data'
keepExtensions: true
}
keepExtensions: true,
},
};
require('./app/models/logging.js'); // init logging methods (IncomingMessage extensions)
new myHttp.Application(serverOptions).start();
Expand Down Expand Up @@ -192,7 +192,7 @@ async function main() {
start();
}

main().catch(err => {
main().catch((err) => {
// in order to prevent UnhandledPromiseRejections, let's catch errors and exit as we should
console.log('error from main():', err);
console.error('error from main():', err);
Expand Down
8 changes: 4 additions & 4 deletions app/MyController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exports.buildController = function(params) {
exports.buildController = function (params) {
var logPrefix = params.controllerName + '.controller';
if (process.appParams.color) logPrefix = logPrefix.yellow;
return function(request, reqParams, response) {
return function (request, reqParams, response) {
request.logToConsole(logPrefix, reqParams);
var reqParams = reqParams || {};

Expand Down Expand Up @@ -51,8 +51,8 @@ exports.buildController = function(params) {
'<h2>available actions:</h2>',
'<ul><li>',
Object.keys(params.actions).join('</li><li>'),
'</li></ul>'
].join('\n')
'</li></ul>',
].join('\n'),
});
};
};
4 changes: 2 additions & 2 deletions app/controllers/LibAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ function renderAllLibrary(lib) {
}

if (options.after || options.before)
renderFeed(function(feedHtml) {
renderFeed(function (feedHtml) {
lib.render({ html: feedHtml });
});
else
renderFeed(function(feedHtml) {
renderFeed(function (feedHtml) {
//lib.renderSidebar(/*uidList*/ null, null/*user*/, options, function(sidebarHtml){
lib.renderPage(
{
Expand Down
23 changes: 11 additions & 12 deletions app/controllers/LibFriends.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ var followModel = require('../models/follow.js');
var activityModel = require('../models/activity.js');
var contestModel = require('../models/plContest.js');
var feedTemplate = require('../templates/feed.js');
var snip = require('../snip.js');

var HISTORY_LIMIT = 3;
var RECOM_PEOPLE_LIMIT = 3;

function fetchSubscriptions(uid, callback) {
//console.time("LibFriends.fetchSubscriptions");
followModel.fetchSubscriptionArray(uid, function(subscriptions) {
followModel.fetchSubscriptionArray(uid, function (subscriptions) {
//console.timeEnd("LibFriends.fetchSubscriptions");
callback(subscriptions.concat([uid]));
});
Expand All @@ -32,7 +31,7 @@ function renderSuggestedPeople(allPosts) {
id: allPosts[i].uId,
name: allPosts[i].uNm,
track: allPosts[i].name,
trackUrl: '/c/' + allPosts[i]._id
trackUrl: '/c/' + allPosts[i]._id,
};
for (var i in userSet) userList.push(userSet[i]);
return userList.slice(0, RECOM_PEOPLE_LIMIT);
Expand All @@ -52,7 +51,7 @@ function fetchRecentActivity(uidList, loggedUid, cb) {
activityModel.fetchHistoryFromUidList(
/*uidList*/ subscribers,
{ limit: HISTORY_LIMIT },
function(activities) {
function (activities) {
cb(activities /*.slice(0, HISTORY_LIMIT)*/);
}
);
Expand All @@ -66,12 +65,12 @@ function prepareSidebar(uidList, options, cb) {
options.suggestedUsers = { items: userList };
*/
//console.time("fetchRecentActivity");
fetchRecentActivity(uidList, options.loggedUser.id, function(activities) {
fetchRecentActivity(uidList, options.loggedUser.id, function (activities) {
//console.timeEnd("fetchRecentActivity");
if (activities && activities.length)
options.recentActivity = { items: activities };
//console.time("fetchLast");
contestModel.fetchLast(function(contest) {
contestModel.fetchLast(function (contest) {
//console.timeEnd("fetchLast");
if (config.advertisePlaylistContestOnHome && contest && contest.title)
options.playlistContest = contest;
Expand All @@ -87,15 +86,15 @@ function prepareSidebar(uidList, options, cb) {
function renderFriendsFeed(options, callback) {
var params = {
after: options.after,
before: options.before
before: options.before,
//limit:limit
};
if (options.limit) params.limit = options.limit;

fetchSubscriptions(options.loggedUser.id, function(uidList, subscriptions) {
fetchSubscriptions(options.loggedUser.id, function (uidList, subscriptions) {
options.subscriptions = subscriptions;
postModel.fetchByAuthors(uidList, params, function(posts) {
prepareSidebar(uidList, options, function() {
postModel.fetchByAuthors(uidList, params, function (posts) {
prepareSidebar(uidList, options, function () {
// (if necessary), then:
feedTemplate.renderFeedAsync(posts, options, callback);
});
Expand All @@ -110,7 +109,7 @@ function renderFriendsLibrary(lib) {
options.homeFeed = true;
options.displayPlaylistName = true;

renderFriendsFeed(options, function(res) {
renderFriendsFeed(options, function (res) {
if (options.format == 'json') lib.renderJson(res);
else if (options.after || options.before) lib.render({ html: res });
else {
Expand All @@ -119,7 +118,7 @@ function renderFriendsLibrary(lib) {
'<script>',
' window.Whyd.tracking.log("Visit home");',
'</script>',
''
'',
].join('\n') + res;
lib.renderPage({ name: 'Dashboard' }, /*sidebarHtml*/ null, feedHtml);
}
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/LibStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var uidLists = {
'512ba8757e91c862b2ab1ae5', // Mauricio Estrada Munoz
'4fe0f8b57e91c862b2a7c274', // Masscut
'4e61ec47981d90d694c13657', // Kien - RAP SLAM HIPHOP
'51430f4e7e91c862b2ab552e' // Mika Mikaz
'51430f4e7e91c862b2ab552e', // Mika Mikaz
] /*,
indie: [
adrien/playlist/34
Expand All @@ -33,7 +33,7 @@ var uidLists = {
jazz: [
dontfearmistakes (paris jazz scene)
]
*/
*/,
};

/*
Expand All @@ -53,7 +53,7 @@ GET /style/funk -> controllers.userLibrary
function renderFriendsFeed(options, uidList, callback) {
var params = {
after: options.after,
before: options.before
before: options.before,
//limit:limit
};
postModel.fetchByAuthors(uidList, params, function process(posts) {
Expand Down Expand Up @@ -86,7 +86,7 @@ function renderFriendsLibrary(lib, style) {
options.streamTitle = 'Style: ' + style;
options.displayPlaylistName = true;

renderFriendsFeed(options, uidList, function(feedHtml) {
renderFriendsFeed(options, uidList, function (feedHtml) {
if (options.after || options.before) lib.render({ html: feedHtml });
else {
/*
Expand Down
Loading

0 comments on commit b8c7728

Please sign in to comment.