Merge pull request #16346 from overleaf/msm-remove-underscore

Remove `underscore` in monorepo

GitOrigin-RevId: fd3b92e3e8a940a7a086669232102320c34a89e2
This commit is contained in:
Miguel Serrano 2024-01-08 14:55:30 +01:00 committed by Copybot
parent a04b5c0418
commit 51de84664d
43 changed files with 77 additions and 98 deletions

32
package-lock.json generated
View file

@ -45918,8 +45918,7 @@
"proxy-addr": "^2.0.7", "proxy-addr": "^2.0.7",
"request": "^2.88.2", "request": "^2.88.2",
"socket.io": "github:overleaf/socket.io#0.9.19-overleaf-10", "socket.io": "github:overleaf/socket.io#0.9.19-overleaf-10",
"socket.io-client": "github:overleaf/socket.io-client#0.9.17-overleaf-5", "socket.io-client": "github:overleaf/socket.io-client#0.9.17-overleaf-5"
"underscore": "1.13.1"
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.3.6", "chai": "^4.3.6",
@ -45957,11 +45956,6 @@
"integrity": "sha1-kNt58X2Ni1NiFUOJSSuXJ2LP0nY=", "integrity": "sha1-kNt58X2Ni1NiFUOJSSuXJ2LP0nY=",
"dev": true "dev": true
}, },
"services/real-time/node_modules/underscore": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz",
"integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g=="
},
"services/references": { "services/references": {
"name": "@overleaf/references", "name": "@overleaf/references",
"dependencies": { "dependencies": {
@ -45976,8 +45970,7 @@
"express": "^4.18.2", "express": "^4.18.2",
"ioredis": "^4.16.1", "ioredis": "^4.16.1",
"lodash": "^4.17.19", "lodash": "^4.17.19",
"request": "^2.88.2", "request": "^2.88.2"
"underscore": "^1.10.2"
}, },
"devDependencies": { "devDependencies": {
"bson": "^1.1.5", "bson": "^1.1.5",
@ -46029,11 +46022,11 @@
"bunyan": "^1.8.15", "bunyan": "^1.8.15",
"express": "^4.18.2", "express": "^4.18.2",
"install": "^0.13.0", "install": "^0.13.0",
"lodash": "^4.17.21",
"marked": "^4.1.0", "marked": "^4.1.0",
"method-override": "^3.0.0", "method-override": "^3.0.0",
"mongoose": "^5.13.20", "mongoose": "^5.13.20",
"request": "^2.88.2", "request": "^2.88.2"
"underscore": "^1.13.6"
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.3.6", "chai": "^4.3.6",
@ -46466,7 +46459,6 @@
"sanitize-html": "^2.8.1", "sanitize-html": "^2.8.1",
"tough-cookie": "^4.0.0", "tough-cookie": "^4.0.0",
"tsscmp": "^1.0.6", "tsscmp": "^1.0.6",
"underscore": "^1.13.1",
"utf-8-validate": "^5.0.2", "utf-8-validate": "^5.0.2",
"uuid": "^3.0.1", "uuid": "^3.0.1",
"valid-data-url": "^2.0.0", "valid-data-url": "^2.0.0",
@ -54814,8 +54806,7 @@
"socket.io": "github:overleaf/socket.io#0.9.19-overleaf-10", "socket.io": "github:overleaf/socket.io#0.9.19-overleaf-10",
"socket.io-client": "github:overleaf/socket.io-client#0.9.17-overleaf-5", "socket.io-client": "github:overleaf/socket.io-client#0.9.17-overleaf-5",
"timekeeper": "0.0.4", "timekeeper": "0.0.4",
"uid-safe": "^2.1.5", "uid-safe": "^2.1.5"
"underscore": "1.13.1"
}, },
"dependencies": { "dependencies": {
"sandboxed-module": { "sandboxed-module": {
@ -54839,11 +54830,6 @@
"resolved": "https://registry.npmjs.org/timekeeper/-/timekeeper-0.0.4.tgz", "resolved": "https://registry.npmjs.org/timekeeper/-/timekeeper-0.0.4.tgz",
"integrity": "sha1-kNt58X2Ni1NiFUOJSSuXJ2LP0nY=", "integrity": "sha1-kNt58X2Ni1NiFUOJSSuXJ2LP0nY=",
"dev": true "dev": true
},
"underscore": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz",
"integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g=="
} }
} }
}, },
@ -54880,8 +54866,7 @@
"mocha": "^10.2.0", "mocha": "^10.2.0",
"request": "^2.88.2", "request": "^2.88.2",
"sandboxed-module": "^2.0.4", "sandboxed-module": "^2.0.4",
"sinon": "^9.2.4", "sinon": "^9.2.4"
"underscore": "^1.10.2"
} }
}, },
"@overleaf/settings": { "@overleaf/settings": {
@ -54937,14 +54922,14 @@
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"express": "^4.18.2", "express": "^4.18.2",
"install": "^0.13.0", "install": "^0.13.0",
"lodash": "^4.17.21",
"marked": "^4.1.0", "marked": "^4.1.0",
"method-override": "^3.0.0", "method-override": "^3.0.0",
"mocha": "^10.2.0", "mocha": "^10.2.0",
"mongoose": "^5.13.20", "mongoose": "^5.13.20",
"request": "^2.88.2", "request": "^2.88.2",
"sandboxed-module": "^2.0.4", "sandboxed-module": "^2.0.4",
"sinon": "^9.2.4", "sinon": "^9.2.4"
"underscore": "^1.13.6"
} }
}, },
"@overleaf/third-party-datastore": { "@overleaf/third-party-datastore": {
@ -55431,7 +55416,6 @@
"tough-cookie": "^4.0.0", "tough-cookie": "^4.0.0",
"tsscmp": "^1.0.6", "tsscmp": "^1.0.6",
"typescript": "^5.0.4", "typescript": "^5.0.4",
"underscore": "^1.13.1",
"utf-8-validate": "^5.0.2", "utf-8-validate": "^5.0.2",
"uuid": "^3.0.1", "uuid": "^3.0.1",
"valid-data-url": "^2.0.0", "valid-data-url": "^2.0.0",

View file

@ -1,5 +1,5 @@
const request = require('request') const request = require('request')
const _ = require('underscore') const _ = require('lodash')
const OError = require('@overleaf/o-error') const OError = require('@overleaf/o-error')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const settings = require('@overleaf/settings') const settings = require('@overleaf/settings')

View file

@ -33,8 +33,7 @@
"proxy-addr": "^2.0.7", "proxy-addr": "^2.0.7",
"request": "^2.88.2", "request": "^2.88.2",
"socket.io": "github:overleaf/socket.io#0.9.19-overleaf-10", "socket.io": "github:overleaf/socket.io#0.9.19-overleaf-10",
"socket.io-client": "github:overleaf/socket.io-client#0.9.17-overleaf-5", "socket.io-client": "github:overleaf/socket.io-client#0.9.17-overleaf-5"
"underscore": "1.13.1"
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.3.6", "chai": "^4.3.6",

View file

@ -13,7 +13,7 @@ const sinon = require('sinon')
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const path = require('path') const path = require('path')
const modulePath = '../../../app/js/DocumentUpdaterManager' const modulePath = '../../../app/js/DocumentUpdaterManager'
const _ = require('underscore') const _ = require('lodash')
describe('DocumentUpdaterManager', function () { describe('DocumentUpdaterManager', function () {
beforeEach(function () { beforeEach(function () {
@ -400,24 +400,24 @@ describe('DocumentUpdaterManager', function () {
10000, 10000,
this.DocumentUpdaterManager._getPendingUpdateListKey this.DocumentUpdaterManager._getPendingUpdateListKey
) )
this.keys = _.unique(keys) this.keys = _.uniq(keys)
}) })
it('should return normal pending updates key', function () { it('should return normal pending updates key', function () {
_.contains(this.keys, 'pending-updates-list').should.equal(true) _.includes(this.keys, 'pending-updates-list').should.equal(true)
}) })
it('should return pending-updates-list-n keys', function () { it('should return pending-updates-list-n keys', function () {
_.contains(this.keys, 'pending-updates-list-1').should.equal(true) _.includes(this.keys, 'pending-updates-list-1').should.equal(true)
_.contains(this.keys, 'pending-updates-list-3').should.equal(true) _.includes(this.keys, 'pending-updates-list-3').should.equal(true)
_.contains(this.keys, 'pending-updates-list-9').should.equal(true) _.includes(this.keys, 'pending-updates-list-9').should.equal(true)
}) })
it('should not include pending-updates-list-0 key', function () { it('should not include pending-updates-list-0 key', function () {
_.contains(this.keys, 'pending-updates-list-0').should.equal(false) _.includes(this.keys, 'pending-updates-list-0').should.equal(false)
}) })
it('should not include maximum as pendingUpdateListShardCount value', function () { it('should not include maximum as pendingUpdateListShardCount value', function () {
_.contains(this.keys, 'pending-updates-list-10').should.equal(false) _.includes(this.keys, 'pending-updates-list-10').should.equal(false)
}) })
}) })
}) })

View file

@ -19,7 +19,7 @@ const NewBackendCloudClsiCookieManager = require('./ClsiCookieManager')(
Settings.apis.clsi_new?.backendGroupName Settings.apis.clsi_new?.backendGroupName
) )
const ClsiStateManager = require('./ClsiStateManager') const ClsiStateManager = require('./ClsiStateManager')
const _ = require('underscore') const _ = require('lodash')
const ClsiFormatChecker = require('./ClsiFormatChecker') const ClsiFormatChecker = require('./ClsiFormatChecker')
const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler') const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
const Metrics = require('@overleaf/metrics') const Metrics = require('@overleaf/metrics')

View file

@ -1,7 +1,7 @@
const request = require('request').defaults({ timeout: 30 * 1000 }) const request = require('request').defaults({ timeout: 30 * 1000 })
const OError = require('@overleaf/o-error') const OError = require('@overleaf/o-error')
const settings = require('@overleaf/settings') const settings = require('@overleaf/settings')
const _ = require('underscore') const _ = require('lodash')
const async = require('async') const async = require('async')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const metrics = require('@overleaf/metrics') const metrics = require('@overleaf/metrics')
@ -348,10 +348,10 @@ function _getUpdates(entityType, oldEntities, newEntities) {
const adds = [] const adds = []
const renames = [] const renames = []
const oldEntitiesHash = _.indexBy(oldEntities, entity => const oldEntitiesHash = _.keyBy(oldEntities, entity =>
entity[entityType]._id.toString() entity[entityType]._id.toString()
) )
const newEntitiesHash = _.indexBy(newEntities, entity => const newEntitiesHash = _.keyBy(newEntities, entity =>
entity[entityType]._id.toString() entity[entityType]._id.toString()
) )

View file

@ -15,7 +15,7 @@ let FileHashManager
const crypto = require('crypto') const crypto = require('crypto')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const fs = require('fs') const fs = require('fs')
const _ = require('underscore') const _ = require('lodash')
module.exports = FileHashManager = { module.exports = FileHashManager = {
computeHash(filePath, callback) { computeHash(filePath, callback) {

View file

@ -1,4 +1,4 @@
const _ = require('underscore') const _ = require('lodash')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const fs = require('fs') const fs = require('fs')
const request = require('request') const request = require('request')

View file

@ -11,7 +11,7 @@
let InactiveProjectManager let InactiveProjectManager
const OError = require('@overleaf/o-error') const OError = require('@overleaf/o-error')
const async = require('async') const async = require('async')
const _ = require('underscore') const _ = require('lodash')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const DocstoreManager = require('../Docstore/DocstoreManager') const DocstoreManager = require('../Docstore/DocstoreManager')
const ProjectGetter = require('../Project/ProjectGetter') const ProjectGetter = require('../Project/ProjectGetter')

View file

@ -17,7 +17,7 @@ const EditorController = require('../Editor/EditorController')
const ProjectLocator = require('../Project/ProjectLocator') const ProjectLocator = require('../Project/ProjectLocator')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const _ = require('underscore') const _ = require('lodash')
const LinkedFilesHandler = require('./LinkedFilesHandler') const LinkedFilesHandler = require('./LinkedFilesHandler')
const { const {
CompileFailedError, CompileFailedError,

View file

@ -15,7 +15,7 @@ const EditorController = require('../Editor/EditorController')
const ProjectLocator = require('../Project/ProjectLocator') const ProjectLocator = require('../Project/ProjectLocator')
const { Project } = require('../../models/Project') const { Project } = require('../../models/Project')
const ProjectGetter = require('../Project/ProjectGetter') const ProjectGetter = require('../Project/ProjectGetter')
const _ = require('underscore') const _ = require('lodash')
const { const {
ProjectNotFoundError, ProjectNotFoundError,
V1ProjectNotFoundError, V1ProjectNotFoundError,

View file

@ -18,7 +18,7 @@ const ProjectGetter = require('../Project/ProjectGetter')
const DocstoreManager = require('../Docstore/DocstoreManager') const DocstoreManager = require('../Docstore/DocstoreManager')
const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler') const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
const FileStoreHandler = require('../FileStore/FileStoreHandler') const FileStoreHandler = require('../FileStore/FileStoreHandler')
const _ = require('underscore') const _ = require('lodash')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')
const LinkedFilesHandler = require('./LinkedFilesHandler') const LinkedFilesHandler = require('./LinkedFilesHandler')
const { const {

View file

@ -2,7 +2,7 @@ const AuthorizationManager = require('../Authorization/AuthorizationManager')
const CompileManager = require('../Compile/CompileManager') const CompileManager = require('../Compile/CompileManager')
const ClsiManager = require('../Compile/ClsiManager') const ClsiManager = require('../Compile/ClsiManager')
const ProjectFileAgent = require('./ProjectFileAgent') const ProjectFileAgent = require('./ProjectFileAgent')
const _ = require('underscore') const _ = require('lodash')
const { const {
CompileFailedError, CompileFailedError,
BadDataError, BadDataError,

View file

@ -1,6 +1,6 @@
const NotificationsHandler = require('./NotificationsHandler') const NotificationsHandler = require('./NotificationsHandler')
const SessionManager = require('../Authentication/SessionManager') const SessionManager = require('../Authentication/SessionManager')
const _ = require('underscore') const _ = require('lodash')
module.exports = { module.exports = {
getAllUnreadNotifications(req, res, next) { getAllUnreadNotifications(req, res, next) {

View file

@ -1,6 +1,6 @@
// TODO: This file was created by bulk-decaffeinate. // TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment. // Sanity-check the conversion and remove this comment.
const _ = require('underscore') const _ = require('lodash')
module.exports = { module.exports = {
areSame(lines1, lines2) { areSame(lines1, lines2) {

View file

@ -13,7 +13,7 @@ const { User } = require('../../models/User')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const { callbackify } = require('util') const { callbackify } = require('util')
const _ = require('underscore') const _ = require('lodash')
const AnalyticsManager = require('../Analytics/AnalyticsManager') const AnalyticsManager = require('../Analytics/AnalyticsManager')
const TpdsUpdateSender = require('../ThirdPartyDataStore/TpdsUpdateSender') const TpdsUpdateSender = require('../ThirdPartyDataStore/TpdsUpdateSender')

View file

@ -1,4 +1,4 @@
const _ = require('underscore') const _ = require('lodash')
const ProjectGetter = require('./ProjectGetter') const ProjectGetter = require('./ProjectGetter')
const UserGetter = require('../User/UserGetter') const UserGetter = require('../User/UserGetter')
const { Project } = require('../../models/Project') const { Project } = require('../../models/Project')
@ -154,8 +154,8 @@ async function generateUniqueName(userId, name, suffixes = []) {
await ProjectGetter.promises.findAllUsersProjects(userId, { name: 1 }) await ProjectGetter.promises.findAllUsersProjects(userId, { name: 1 })
// allUsersProjectNames is returned as a hash {owned: [name1, name2, ...], readOnly: [....]} // allUsersProjectNames is returned as a hash {owned: [name1, name2, ...], readOnly: [....]}
// collect all of the names and flatten them into a single array // collect all of the names and flatten them into a single array
const projectNameList = _.pluck( const projectNameList = _.map(
_.flatten(_.values(allUsersProjectNames)), _.flattenDeep(_.values(allUsersProjectNames)),
'name' 'name'
) )
const uniqueName = await ProjectHelper.promises.ensureNameIsUnique( const uniqueName = await ProjectHelper.promises.ensureNameIsUnique(
@ -194,7 +194,7 @@ async function setPublicAccessLevel(projectId, newAccessLevel) {
if ( if (
projectId != null && projectId != null &&
newAccessLevel != null && newAccessLevel != null &&
_.include( _.includes(
[PublicAccessLevels.PRIVATE, PublicAccessLevels.TOKEN_BASED], [PublicAccessLevels.PRIVATE, PublicAccessLevels.TOKEN_BASED],
newAccessLevel newAccessLevel
) )

View file

@ -1,5 +1,5 @@
let ProjectEditorHandler let ProjectEditorHandler
const _ = require('underscore') const _ = require('lodash')
const Path = require('path') const Path = require('path')
function mergeDeletedDocs(a, b) { function mergeDeletedDocs(a, b) {

View file

@ -1,6 +1,5 @@
const { callbackify } = require('util') const { callbackify } = require('util')
const { callbackifyMultiResult } = require('@overleaf/promise-utils') const { callbackifyMultiResult } = require('@overleaf/promise-utils')
const _ = require('underscore')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const path = require('path') const path = require('path')
const { ObjectId } = require('mongodb') const { ObjectId } = require('mongodb')
@ -264,8 +263,7 @@ async function replaceFileWithDoc(projectId, fileId, newDoc) {
async function mkdirp(projectId, path, options = {}) { async function mkdirp(projectId, path, options = {}) {
// defaults to case insensitive paths, use options {exactCaseMatch:true} // defaults to case insensitive paths, use options {exactCaseMatch:true}
// to make matching case-sensitive // to make matching case-sensitive
let folders = path.split('/') const folders = path.split('/').filter(folder => folder.length !== 0)
folders = _.select(folders, folder => folder.length !== 0)
const project = await ProjectGetter.promises.getProjectWithOnlyFolders( const project = await ProjectGetter.promises.getProjectWithOnlyFolders(
projectId projectId

View file

@ -1,4 +1,4 @@
const _ = require('underscore') const _ = require('lodash')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const OError = require('@overleaf/o-error') const OError = require('@overleaf/o-error')
const async = require('async') const async = require('async')
@ -43,7 +43,7 @@ function findElement(options, _callback) {
searchFolder.folders != null && searchFolder.folders != null &&
searchFolder.folders.length !== 0 searchFolder.folders.length !== 0
) { ) {
_.each(searchFolder.folders, (folder, index) => { _.forEach(searchFolder.folders, (folder, index) => {
if (folder == null) { if (folder == null) {
return return
} }

View file

@ -22,7 +22,7 @@ const fs = require('fs')
const { promisify } = require('util') const { promisify } = require('util')
const async = require('async') const async = require('async')
const globby = require('globby') const globby = require('globby')
const _ = require('underscore') const _ = require('lodash')
const { promisifyAll } = require('@overleaf/promise-utils') const { promisifyAll } = require('@overleaf/promise-utils')
module.exports = ProjectRootDocManager = { module.exports = ProjectRootDocManager = {

View file

@ -1,4 +1,4 @@
const _ = require('underscore') const _ = require('lodash')
const { promisify } = require('util') const { promisify } = require('util')
const { User } = require('../../models/User') const { User } = require('../../models/User')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')
@ -38,7 +38,7 @@ module.exports = ReferalFeatures = {
_getBonusLevel(user) { _getBonusLevel(user) {
let highestBonusLevel = 0 let highestBonusLevel = 0
_.each(_.keys(Settings.bonus_features), function (level) { _.forEach(_.keys(Settings.bonus_features), function (level) {
const levelIsLessThanUser = level <= user.refered_user_count const levelIsLessThanUser = level <= user.refered_user_count
const levelIsMoreThanCurrentHighest = level >= highestBonusLevel const levelIsMoreThanCurrentHighest = level >= highestBonusLevel
if (levelIsLessThanUser && levelIsMoreThanCurrentHighest) { if (levelIsLessThanUser && levelIsMoreThanCurrentHighest) {

View file

@ -21,7 +21,7 @@ const Features = require('../../infrastructure/Features')
const ProjectGetter = require('../Project/ProjectGetter') const ProjectGetter = require('../Project/ProjectGetter')
const UserGetter = require('../User/UserGetter') const UserGetter = require('../User/UserGetter')
const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler') const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
const _ = require('underscore') const _ = require('lodash')
const Async = require('async') const Async = require('async')
const Errors = require('../Errors/Errors') const Errors = require('../Errors/Errors')
@ -41,7 +41,7 @@ module.exports = ReferencesHandler = {
_findBibFileIds(project) { _findBibFileIds(project) {
const ids = [] const ids = []
function _process(folder) { function _process(folder) {
_.each(folder.fileRefs || [], function (file) { _.forEach(folder.fileRefs || [], function (file) {
if ( if (
__guard__(file != null ? file.name : undefined, x1 => __guard__(file != null ? file.name : undefined, x1 =>
x1.match(/^.*\.bib$/) x1.match(/^.*\.bib$/)
@ -50,16 +50,16 @@ module.exports = ReferencesHandler = {
return ids.push(file._id) return ids.push(file._id)
} }
}) })
return _.each(folder.folders || [], folder => _process(folder)) return _.forEach(folder.folders || [], folder => _process(folder))
} }
_.each(project.rootFolder || [], rootFolder => _process(rootFolder)) _.forEach(project.rootFolder || [], rootFolder => _process(rootFolder))
return ids return ids
}, },
_findBibDocIds(project) { _findBibDocIds(project) {
const ids = [] const ids = []
function _process(folder) { function _process(folder) {
_.each(folder.docs || [], function (doc) { _.forEach(folder.docs || [], function (doc) {
if ( if (
__guard__(doc != null ? doc.name : undefined, x1 => __guard__(doc != null ? doc.name : undefined, x1 =>
x1.match(/^.*\.bib$/) x1.match(/^.*\.bib$/)
@ -68,9 +68,9 @@ module.exports = ReferencesHandler = {
return ids.push(doc._id) return ids.push(doc._id)
} }
}) })
return _.each(folder.folders || [], folder => _process(folder)) return _.forEach(folder.folders || [], folder => _process(folder))
} }
_.each(project.rootFolder || [], rootFolder => _process(rootFolder)) _.forEach(project.rootFolder || [], rootFolder => _process(rootFolder))
return ids return ids
}, },

View file

@ -16,7 +16,7 @@
const metrics = require('@overleaf/metrics') const metrics = require('@overleaf/metrics')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const _ = require('underscore') const _ = require('lodash')
const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler') const DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')
const TpdsUpdateSender = require('../ThirdPartyDataStore/TpdsUpdateSender') const TpdsUpdateSender = require('../ThirdPartyDataStore/TpdsUpdateSender')

View file

@ -18,7 +18,7 @@ const extensionsToProxy = [
'.gif', '.gif',
'.jpg', '.jpg',
] ]
const _ = require('underscore') const _ = require('lodash')
module.exports = { module.exports = {
shouldProxy(url) { shouldProxy(url) {

View file

@ -8,7 +8,7 @@ const InstitutionsGetter = require('../Institutions/InstitutionsGetter')
const InstitutionsManager = require('../Institutions/InstitutionsManager') const InstitutionsManager = require('../Institutions/InstitutionsManager')
const PublishersGetter = require('../Publishers/PublishersGetter') const PublishersGetter = require('../Publishers/PublishersGetter')
const sanitizeHtml = require('sanitize-html') const sanitizeHtml = require('sanitize-html')
const _ = require('underscore') const _ = require('lodash')
const async = require('async') const async = require('async')
const SubscriptionHelper = require('./SubscriptionHelper') const SubscriptionHelper = require('./SubscriptionHelper')
const { callbackify } = require('@overleaf/promise-utils') const { callbackify } = require('@overleaf/promise-utils')
@ -424,7 +424,7 @@ function buildPlansList(currentPlan) {
const result = { allPlans } const result = { allPlans }
if (currentPlan) { if (currentPlan) {
result.planCodesChangingAtTermEnd = _.pluck( result.planCodesChangingAtTermEnd = _.map(
_.filter(plans, plan => { _.filter(plans, plan => {
if (!plan.hideFromUsers) { if (!plan.hideFromUsers) {
return SubscriptionHelper.shouldPlanChangeAtTermEnd(currentPlan, plan) return SubscriptionHelper.shouldPlanChangeAtTermEnd(currentPlan, plan)

View file

@ -13,7 +13,7 @@ const request = require('request')
const settings = require('@overleaf/settings') const settings = require('@overleaf/settings')
const crypto = require('crypto') const crypto = require('crypto')
const Errors = require('../Errors/Errors') const Errors = require('../Errors/Errors')
const _ = require('underscore') const _ = require('lodash')
const TemplatesManager = { const TemplatesManager = {
createProjectFromV1Template( createProjectFromV1Template(

View file

@ -1,5 +1,5 @@
const { callbackify } = require('util') const { callbackify } = require('util')
const _ = require('underscore') const _ = require('lodash')
const fsPromises = require('fs/promises') const fsPromises = require('fs/promises')
const fs = require('fs') const fs = require('fs')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')

View file

@ -25,7 +25,7 @@ const {
EmptyZipFileError, EmptyZipFileError,
ZipContentsTooLargeError, ZipContentsTooLargeError,
} = require('./ArchiveErrors') } = require('./ArchiveErrors')
const _ = require('underscore') const _ = require('lodash')
const { promisifyAll } = require('@overleaf/promise-utils') const { promisifyAll } = require('@overleaf/promise-utils')
const ONE_MEG = 1024 * 1024 const ONE_MEG = 1024 * 1024

View file

@ -2,7 +2,7 @@ const OError = require('@overleaf/o-error')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const Async = require('async') const Async = require('async')
const _ = require('underscore') const _ = require('lodash')
const { promisify } = require('util') const { promisify } = require('util')
const UserSessionsRedis = require('./UserSessionsRedis') const UserSessionsRedis = require('./UserSessionsRedis')
const rclient = UserSessionsRedis.client() const rclient = UserSessionsRedis.client()
@ -86,7 +86,7 @@ const UserSessionsManager = {
}) })
return callback(err) return callback(err)
} }
sessionKeys = _.filter(sessionKeys, k => !_.contains(exclude, k)) sessionKeys = _.filter(sessionKeys, k => !_.includes(exclude, k))
if (sessionKeys.length === 0) { if (sessionKeys.length === 0) {
logger.debug({ userId: user._id }, 'no other sessions found, returning') logger.debug({ userId: user._id }, 'no other sessions found, returning')
return callback(null, []) return callback(null, [])

View file

@ -14,7 +14,7 @@ const fs = require('fs')
const OError = require('@overleaf/o-error') const OError = require('@overleaf/o-error')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const crypto = require('crypto') const crypto = require('crypto')
const _ = require('underscore') const _ = require('lodash')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')
const request = require('request') const request = require('request')
const { Transform, pipeline } = require('stream') const { Transform, pipeline } = require('stream')

View file

@ -1,6 +1,6 @@
const request = require('request') const request = require('request')
const settings = require('@overleaf/settings') const settings = require('@overleaf/settings')
const _ = require('underscore') const _ = require('lodash')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const { URL } = require('url') const { URL } = require('url')
const { promisify, promisifyMultiResult } = require('@overleaf/promise-utils') const { promisify, promisifyMultiResult } = require('@overleaf/promise-utils')
@ -65,7 +65,7 @@ const EuroCountries = [
'ES', 'ES',
] ]
_.each(EuroCountries, country => (currencyMappings[country] = 'EUR')) _.forEach(EuroCountries, country => (currencyMappings[country] = 'EUR'))
function isValidCurrencyParam(currency) { function isValidCurrencyParam(currency) {
if (!currency) { if (!currency) {

View file

@ -1,5 +1,5 @@
const mongoose = require('../infrastructure/Mongoose') const mongoose = require('../infrastructure/Mongoose')
const _ = require('underscore') const _ = require('lodash')
const { FolderSchema } = require('./Folder') const { FolderSchema } = require('./Folder')
const Errors = require('../Features/Errors/Errors') const Errors = require('../Features/Errors/Errors')
@ -129,8 +129,8 @@ ProjectSchema.statics.getProject = function (projectOrId, fields, callback) {
} }
function applyToAllFilesRecursivly(folder, fun) { function applyToAllFilesRecursivly(folder, fun) {
_.each(folder.fileRefs, file => fun(file)) _.forEach(folder.fileRefs, file => fun(file))
_.each(folder.folders, folder => applyToAllFilesRecursivly(folder, fun)) _.forEach(folder.folders, folder => applyToAllFilesRecursivly(folder, fun))
} }
ProjectSchema.statics.applyToAllFilesRecursivly = applyToAllFilesRecursivly ProjectSchema.statics.applyToAllFilesRecursivly = applyToAllFilesRecursivly

View file

@ -66,7 +66,7 @@ const {
} = require('./infrastructure/UnsupportedBrowserMiddleware') } = require('./infrastructure/UnsupportedBrowserMiddleware')
const logger = require('@overleaf/logger') const logger = require('@overleaf/logger')
const _ = require('underscore') const _ = require('lodash')
const { plainTextResponse } = require('./infrastructure/Response') const { plainTextResponse } = require('./infrastructure/Response')
const PublicAccessLevels = require('./Features/Authorization/PublicAccessLevels') const PublicAccessLevels = require('./Features/Authorization/PublicAccessLevels')

View file

@ -10,7 +10,7 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const _ = require('underscore') const _ = require('lodash')
const { expect } = require('chai') const { expect } = require('chai')
const { ObjectId } = require('mongodb') const { ObjectId } = require('mongodb')

View file

@ -3,7 +3,7 @@ const { ObjectId } = require('mongodb')
const Path = require('path') const Path = require('path')
const fs = require('fs') const fs = require('fs')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')
const _ = require('underscore') const _ = require('lodash')
const ProjectGetter = require('../../../../../app/src/Features/Project/ProjectGetter') const ProjectGetter = require('../../../../../app/src/Features/Project/ProjectGetter')
@ -201,8 +201,8 @@ describe('ProjectStructureChanges', function () {
expect(update.userId).to.equal(owner._id) expect(update.userId).to.equal(owner._id)
expect(update.docLines).to.be.a('string') expect(update.docLines).to.be.a('string')
} }
expect(_.where(updates, { pathname: '/main.tex' }).length).to.equal(1) expect(_.filter(updates, { pathname: '/main.tex' }).length).to.equal(1)
expect(_.where(updates, { pathname: '/sample.bib' }).length).to.equal(1) expect(_.filter(updates, { pathname: '/sample.bib' }).length).to.equal(1)
expect(updates[2].type).to.equal('add-file') expect(updates[2].type).to.equal('add-file')
expect(updates[2].userId).to.equal(owner._id) expect(updates[2].userId).to.equal(owner._id)
expect(updates[2].pathname).to.equal('/frog.jpg') expect(updates[2].pathname).to.equal('/frog.jpg')
@ -249,8 +249,8 @@ describe('ProjectStructureChanges', function () {
expect(update.userId).to.equal(owner._id) expect(update.userId).to.equal(owner._id)
expect(update.docLines).to.be.a('string') expect(update.docLines).to.be.a('string')
} }
expect(_.where(updates, { pathname: '/main.tex' }).length).to.equal(1) expect(_.filter(updates, { pathname: '/main.tex' }).length).to.equal(1)
expect(_.where(updates, { pathname: '/sample.bib' }).length).to.equal(1) expect(_.filter(updates, { pathname: '/sample.bib' }).length).to.equal(1)
expect(updates[2].type).to.equal('add-file') expect(updates[2].type).to.equal('add-file')
expect(updates[2].userId).to.equal(owner._id) expect(updates[2].userId).to.equal(owner._id)
expect(updates[2].pathname).to.equal('/frog.jpg') expect(updates[2].pathname).to.equal('/frog.jpg')

View file

@ -11,7 +11,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const { expect } = require('chai') const { expect } = require('chai')
const _ = require('underscore') const _ = require('lodash')
const fs = require('fs') const fs = require('fs')
const Path = require('path') const Path = require('path')

View file

@ -19,7 +19,7 @@ const logger = require('@overleaf/logger')
const metrics = require('@overleaf/metrics') const metrics = require('@overleaf/metrics')
const UserRegistrationHandler = require('../../../../app/src/Features/User/UserRegistrationHandler') const UserRegistrationHandler = require('../../../../app/src/Features/User/UserRegistrationHandler')
const EmailHandler = require('../../../../app/src/Features/Email/EmailHandler') const EmailHandler = require('../../../../app/src/Features/Email/EmailHandler')
const _ = require('underscore') const _ = require('lodash')
const UserGetter = require('../../../../app/src/Features/User/UserGetter') const UserGetter = require('../../../../app/src/Features/User/UserGetter')
const { User } = require('../../../../app/src/models/User') const { User } = require('../../../../app/src/models/User')
const AuthenticationManager = require('../../../../app/src/Features/Authentication/AuthenticationManager') const AuthenticationManager = require('../../../../app/src/Features/Authentication/AuthenticationManager')

View file

@ -158,7 +158,6 @@
"sanitize-html": "^2.8.1", "sanitize-html": "^2.8.1",
"tough-cookie": "^4.0.0", "tough-cookie": "^4.0.0",
"tsscmp": "^1.0.6", "tsscmp": "^1.0.6",
"underscore": "^1.13.1",
"utf-8-validate": "^5.0.2", "utf-8-validate": "^5.0.2",
"uuid": "^3.0.1", "uuid": "^3.0.1",
"valid-data-url": "^2.0.0", "valid-data-url": "^2.0.0",

View file

@ -1,5 +1,5 @@
const { expect } = require('chai') const { expect } = require('chai')
const _ = require('underscore') const _ = require('lodash')
const fs = require('fs') const fs = require('fs')
const Settings = require('@overleaf/settings') const Settings = require('@overleaf/settings')

View file

@ -2,7 +2,7 @@ const { expect } = require('chai')
const sinon = require('sinon') const sinon = require('sinon')
const Path = require('path') const Path = require('path')
const fs = require('fs') const fs = require('fs')
const _ = require('underscore') const _ = require('lodash')
const User = require('./helpers/User') const User = require('./helpers/User')
const UserHelper = require('./helpers/UserHelper') const UserHelper = require('./helpers/UserHelper')

View file

@ -77,7 +77,6 @@ function getSandboxedModuleRequires() {
'@overleaf/o-error', '@overleaf/o-error',
'sanitize-html', 'sanitize-html',
'sshpk', 'sshpk',
'underscore',
'xml2js', 'xml2js',
] ]
for (const modulePath of internalModules) { for (const modulePath of internalModules) {

View file

@ -18,7 +18,7 @@ const modulePath = require('path').join(
__dirname, __dirname,
'../../../../app/src/Features/Notifications/NotificationsHandler.js' '../../../../app/src/Features/Notifications/NotificationsHandler.js'
) )
const _ = require('underscore') const _ = require('lodash')
describe('NotificationsHandler', function () { describe('NotificationsHandler', function () {
const userId = '123nd3ijdks' const userId = '123nd3ijdks'