Merge pull request #4799 from overleaf/hb-eslint-rules

Re-enable some eslint rules

GitOrigin-RevId: 16153adb839bb61784bb40fbc8e43da281fe090d
This commit is contained in:
Hugh O'Brien
2021-09-15 08:03:43 +00:00
committed by Copybot
parent 49b1356976
commit f7900b474b
26 changed files with 136 additions and 82 deletions
@@ -3,11 +3,14 @@ const SessionManager = require('../Authentication/SessionManager')
const _ = require('underscore')
module.exports = {
getAllUnreadNotifications(req, res) {
getAllUnreadNotifications(req, res, next) {
const userId = SessionManager.getLoggedInUserId(req.session)
NotificationsHandler.getUserNotifications(
userId,
function (err, unreadNotifications) {
if (err) {
return next(err)
}
unreadNotifications = _.map(
unreadNotifications,
function (notification) {
@@ -428,6 +428,10 @@ const ProjectController = {
'allInReconfirmNotificationPeriodsForUser',
fullEmails,
(error, results) => {
if (error != null) {
return cb(error)
}
// Module.hooks.fire accepts multiple methods
// and does async.series
const allInReconfirmNotificationPeriods =
@@ -103,8 +103,9 @@ async function _addExampleProjectFiles(ownerId, projectName, project) {
ownerId
)
const frogPath = path.resolve(
__dirname + '/../../../templates/project_files/example-project/frog.jpg'
const frogPath = path.join(
__dirname,
'/../../../templates/project_files/example-project/frog.jpg'
)
await ProjectEntityUpdateHandler.promises.addFile(
project._id,
@@ -175,8 +176,9 @@ async function _createRootDoc(project, ownerId, docLines) {
async function _buildTemplate(templateName, userId, projectName) {
const user = await User.findById(userId, 'first_name last_name')
const templatePath = path.resolve(
__dirname + `/../../../templates/project_files/${templateName}`
const templatePath = path.join(
__dirname,
`/../../../templates/project_files/${templateName}`
)
const template = fs.readFileSync(templatePath)
const data = {
@@ -11,9 +11,6 @@ const OneTimeTokenHandler = {
if (!options) {
options = {}
}
if (!callback) {
callback = function (error, data) {}
}
if (typeof options === 'function') {
callback = options
options = {}
@@ -40,9 +37,6 @@ const OneTimeTokenHandler = {
},
getValueFromTokenAndExpire(use, token, callback) {
if (!callback) {
callback = function (error, data) {}
}
const now = new Date()
db.tokens.findOneAndUpdate(
{
@@ -1,7 +1,6 @@
/* eslint-disable
node/handle-callback-err,
max-len,
no-path-concat,
no-unused-vars,
node/no-deprecated-api,
*/
@@ -23,7 +22,7 @@ const ErrorController = require('../Errors/ErrorController')
const SessionManager = require('../Authentication/SessionManager')
const homepageExists = fs.existsSync(
Path.resolve(__dirname + '/../../../views/external/home/v2.pug')
Path.join(__dirname, '/../../../views/external/home/v2.pug')
)
module.exports = HomeController = {
@@ -52,9 +51,7 @@ module.exports = HomeController = {
if (next == null) {
next = function (error) {}
}
const path = Path.resolve(
__dirname + `/../../../views/external/${page}.pug`
)
const path = Path.join(__dirname, `/../../../views/external/${page}.pug`)
return fs.exists(path, function (exists) {
// No error in this callback - old method in Node.js!
if (exists) {
@@ -38,9 +38,6 @@ const LimitationsManager = {
},
canAddXCollaborators(projectId, numberOfNewCollaborators, callback) {
if (!callback) {
callback = function (error, allowed) {}
}
this.allowedNumberOfCollaboratorsInProject(
projectId,
(error, allowedNumber) => {
@@ -77,9 +74,6 @@ const LimitationsManager = {
},
hasPaidSubscription(user, callback) {
if (!callback) {
callback = function (err, hasSubscriptionOrIsMember) {}
}
this.userHasV2Subscription(user, (err, hasSubscription, subscription) => {
if (err) {
return callback(err)
@@ -112,9 +106,6 @@ const LimitationsManager = {
},
userHasV2Subscription(user, callback) {
if (!callback) {
callback = function (err, hasSubscription, subscription) {}
}
SubscriptionLocator.getUsersSubscription(
user._id,
function (err, subscription) {
@@ -136,9 +127,6 @@ const LimitationsManager = {
},
userHasV1OrV2Subscription(user, callback) {
if (!callback) {
callback = function (err, hasSubscription) {}
}
this.userHasV2Subscription(user, (err, hasV2Subscription) => {
if (err) {
return callback(err)
@@ -159,9 +147,6 @@ const LimitationsManager = {
},
userIsMemberOfGroupSubscription(user, callback) {
if (!callback) {
callback = function (error, isMember, subscriptions) {}
}
SubscriptionLocator.getMemberSubscriptions(
user._id,
function (err, subscriptions) {
@@ -177,9 +162,6 @@ const LimitationsManager = {
},
userHasV1Subscription(user, callback) {
if (!callback) {
callback = function (error, hasV1Subscription) {}
}
V1SubscriptionManager.getSubscriptionsFromV1(
user._id,
function (err, v1Subscription) {
@@ -201,9 +183,6 @@ const LimitationsManager = {
},
hasGroupMembersLimitReached(subscriptionId, callback) {
if (!callback) {
callback = function (err, limitReached, subscription) {}
}
SubscriptionLocator.getSubscription(
subscriptionId,
function (err, subscription) {
@@ -33,6 +33,9 @@ function newUpdate(userId, projectName, path, updateRequest, source, callback) {
)
}
FileTypeManager.shouldIgnore(path, (err, shouldIgnore) => {
if (err) {
return callback(err)
}
if (shouldIgnore) {
return callback()
}
@@ -1,6 +1,5 @@
/* eslint-disable
camelcase,
node/handle-callback-err,
max-len,
no-unused-vars,
*/
@@ -21,9 +20,6 @@ const logger = require('logger-sharelatex')
module.exports = V1Handler = {
authWithV1(email, password, callback) {
if (callback == null) {
callback = function (err, isValid, v1Profile) {}
}
return V1Api.request(
{
method: 'POST',
@@ -64,10 +60,6 @@ module.exports = V1Handler = {
},
doPasswordReset(v1_user_id, password, callback) {
if (callback == null) {
callback = function (err, created) {}
}
return V1Api.request(
{
method: 'POST',
@@ -5,7 +5,7 @@ const async = require('async')
const { promisify } = require('util')
const Settings = require('@overleaf/settings')
const MODULE_BASE_PATH = Path.resolve(__dirname + '/../../../modules')
const MODULE_BASE_PATH = Path.join(__dirname, '/../../../modules')
const _modules = []
const _hooks = {}