[web] Add prefer-node-protocol ESLint rule (#21523)

* Add `unicorn/prefer-node-protocol`

* Revert non-web changes

* Run `npm run lint:fix` (prefer-node-protocol)

GitOrigin-RevId: c3cdd88ff9e6b3de6a4397d45935c4d026c1c1ed
This commit is contained in:
Antoine Clausse 2024-11-04 10:09:11 +01:00 committed by Copybot
parent 053831b48c
commit eea27a36a4
59 changed files with 92 additions and 91 deletions

View file

@ -107,7 +107,6 @@ module.exports = {
}, },
plugins: ['unicorn'], plugins: ['unicorn'],
rules: { rules: {
'unicorn/prefer-module': 'error',
'import/no-unresolved': 'error', 'import/no-unresolved': 'error',
'import/extensions': [ 'import/extensions': [
'error', 'error',
@ -117,6 +116,8 @@ module.exports = {
mjs: 'always', mjs: 'always',
}, },
], ],
'unicorn/prefer-module': 'error',
'unicorn/prefer-node-protocol': 'error',
}, },
}, },
{ {

View file

@ -16,7 +16,7 @@ import mongodb from './app/src/infrastructure/mongodb.js'
import mongoose from './app/src/infrastructure/Mongoose.js' import mongoose from './app/src/infrastructure/Mongoose.js'
import { triggerGracefulShutdown } from './app/src/infrastructure/GracefulShutdown.js' import { triggerGracefulShutdown } from './app/src/infrastructure/GracefulShutdown.js'
import FileWriter from './app/src/infrastructure/FileWriter.js' import FileWriter from './app/src/infrastructure/FileWriter.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
logger.initialize(process.env.METRICS_APP_NAME || 'web') logger.initialize(process.env.METRICS_APP_NAME || 'web')
logger.logger.serializers.user = Serializers.user logger.logger.serializers.user = Serializers.user

View file

@ -1,8 +1,8 @@
import _ from 'lodash' import _ from 'lodash'
import RequestHelper from './RequestHelper.js' import RequestHelper from './RequestHelper.js'
import AnalyticsManager from './AnalyticsManager.js' import AnalyticsManager from './AnalyticsManager.js'
import querystring from 'querystring' import querystring from 'node:querystring'
import { URL } from 'url' import { URL } from 'node:url'
import Settings from '@overleaf/settings' import Settings from '@overleaf/settings'
import OError from '@overleaf/o-error' import OError from '@overleaf/o-error'
import logger from '@overleaf/logger' import logger from '@overleaf/logger'

View file

@ -1,4 +1,4 @@
import { callbackify } from 'util' import { callbackify } from 'node:util'
import metrics from '@overleaf/metrics' import metrics from '@overleaf/metrics'
import UserUpdater from '../User/UserUpdater.js' import UserUpdater from '../User/UserUpdater.js'
import AnalyticsManager from '../Analytics/AnalyticsManager.js' import AnalyticsManager from '../Analytics/AnalyticsManager.js'

View file

@ -1,4 +1,4 @@
import { callbackify } from 'util' import { callbackify } from 'node:util'
import { Project } from '../../models/Project.js' import { Project } from '../../models/Project.js'
import EmailHandler from '../Email/EmailHandler.js' import EmailHandler from '../Email/EmailHandler.js'
import Settings from '@overleaf/settings' import Settings from '@overleaf/settings'

View file

@ -1,4 +1,4 @@
import { callbackify } from 'util' import { callbackify } from 'node:util'
import ProjectGetter from '../Project/ProjectGetter.js' import ProjectGetter from '../Project/ProjectGetter.js'
import LimitationsManager from '../Subscription/LimitationsManager.js' import LimitationsManager from '../Subscription/LimitationsManager.js'
import UserGetter from '../User/UserGetter.js' import UserGetter from '../User/UserGetter.js'

View file

@ -1,4 +1,4 @@
import { callbackify } from 'util' import { callbackify } from 'node:util'
import { ProjectInvite } from '../../models/ProjectInvite.js' import { ProjectInvite } from '../../models/ProjectInvite.js'
import logger from '@overleaf/logger' import logger from '@overleaf/logger'
import CollaboratorsEmailHandler from './CollaboratorsEmailHandler.mjs' import CollaboratorsEmailHandler from './CollaboratorsEmailHandler.mjs'

View file

@ -1,6 +1,6 @@
// @ts-check // @ts-check
import { callbackify } from 'util' import { callbackify } from 'node:util'
import OError from '@overleaf/o-error' import OError from '@overleaf/o-error'
import logger from '@overleaf/logger' import logger from '@overleaf/logger'
import HistoryManager from '../History/HistoryManager.js' import HistoryManager from '../History/HistoryManager.js'

View file

@ -4,7 +4,7 @@ import UserGetter from '../User/UserGetter.js'
import OneTimeTokenHandler from '../Security/OneTimeTokenHandler.js' import OneTimeTokenHandler from '../Security/OneTimeTokenHandler.js'
import EmailHandler from '../Email/EmailHandler.js' import EmailHandler from '../Email/EmailHandler.js'
import AuthenticationManager from '../Authentication/AuthenticationManager.js' import AuthenticationManager from '../Authentication/AuthenticationManager.js'
import { callbackify, promisify } from 'util' import { callbackify, promisify } from 'node:util'
import PermissionsManager from '../Authorization/PermissionsManager.js' import PermissionsManager from '../Authorization/PermissionsManager.js'
const assertUserPermissions = PermissionsManager.promises.assertUserPermissions const assertUserPermissions = PermissionsManager.promises.assertUserPermissions

View file

@ -1,7 +1,7 @@
import Features from '../../infrastructure/Features.js' import Features from '../../infrastructure/Features.js'
import AnalyticsManager from '../Analytics/AnalyticsManager.js' import AnalyticsManager from '../Analytics/AnalyticsManager.js'
import Path from 'path' import Path from 'node:path'
import fs from 'fs' import fs from 'node:fs'
import ErrorController from '../Errors/ErrorController.js' import ErrorController from '../Errors/ErrorController.js'
import SessionManager from '../Authentication/SessionManager.js' import SessionManager from '../Authentication/SessionManager.js'
import { expressify } from '@overleaf/promise-utils' import { expressify } from '@overleaf/promise-utils'

View file

@ -1,5 +1,5 @@
// ts-check // ts-check
import crypto from 'crypto' import crypto from 'node:crypto'
import SurveyCache from './SurveyCache.mjs' import SurveyCache from './SurveyCache.mjs'
import SubscriptionLocator from '../Subscription/SubscriptionLocator.js' import SubscriptionLocator from '../Subscription/SubscriptionLocator.js'

View file

@ -3,7 +3,7 @@ import TpdsUpdateHandler from './TpdsUpdateHandler.mjs'
import UpdateMerger from './UpdateMerger.js' import UpdateMerger from './UpdateMerger.js'
import Errors from '../Errors/Errors.js' import Errors from '../Errors/Errors.js'
import logger from '@overleaf/logger' import logger from '@overleaf/logger'
import Path from 'path' import Path from 'node:path'
import metrics from '@overleaf/metrics' import metrics from '@overleaf/metrics'
import NotificationsBuilder from '../Notifications/NotificationsBuilder.js' import NotificationsBuilder from '../Notifications/NotificationsBuilder.js'
import SessionManager from '../Authentication/SessionManager.js' import SessionManager from '../Authentication/SessionManager.js'

View file

@ -1,4 +1,4 @@
import { callbackify } from 'util' import { callbackify } from 'node:util'
import UpdateMerger from './UpdateMerger.js' import UpdateMerger from './UpdateMerger.js'
import logger from '@overleaf/logger' import logger from '@overleaf/logger'
import NotificationsBuilder from '../Notifications/NotificationsBuilder.js' import NotificationsBuilder from '../Notifications/NotificationsBuilder.js'

View file

@ -1,7 +1,7 @@
import logger from '@overleaf/logger' import logger from '@overleaf/logger'
import metrics from '@overleaf/metrics' import metrics from '@overleaf/metrics'
import fs from 'fs' import fs from 'node:fs'
import Path from 'path' import Path from 'node:path'
import FileSystemImportManager from './FileSystemImportManager.js' import FileSystemImportManager from './FileSystemImportManager.js'
import ProjectUploadManager from './ProjectUploadManager.js' import ProjectUploadManager from './ProjectUploadManager.js'
import SessionManager from '../Authentication/SessionManager.js' import SessionManager from '../Authentication/SessionManager.js'

View file

@ -34,9 +34,9 @@ import { hasAdminAccess } from '../Features/Helpers/AdminAuthorizationHelper.js'
import Modules from './Modules.js' import Modules from './Modules.js'
import expressLocals from './ExpressLocals.js' import expressLocals from './ExpressLocals.js'
import noCache from 'nocache' import noCache from 'nocache'
import os from 'os' import os from 'node:os'
import http from 'http' import http from 'node:http'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
import serveStaticWrapper from './ServeStaticWrapper.mjs' import serveStaticWrapper from './ServeStaticWrapper.mjs'
const sessionsRedisClient = UserSessionsRedis.client() const sessionsRedisClient = UserSessionsRedis.client()

View file

@ -1,4 +1,4 @@
import util from 'util' import util from 'node:util'
const { promisify } = util const { promisify } = util
const sleep = promisify(setTimeout) const sleep = promisify(setTimeout)

View file

@ -1,6 +1,6 @@
import Path from 'path' import Path from 'node:path'
import { db } from '../../app/src/infrastructure/mongodb.js' import { db } from '../../app/src/infrastructure/mongodb.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url) const __filename = fileURLToPath(import.meta.url)
const __dirname = Path.dirname(__filename) const __dirname = Path.dirname(__filename)

View file

@ -25,7 +25,7 @@
import minimist from 'minimist' import minimist from 'minimist'
import fs from 'fs' import fs from 'node:fs'
import { ObjectId } from '../app/src/infrastructure/mongodb.js' import { ObjectId } from '../app/src/infrastructure/mongodb.js'
import pLimit from 'p-limit' import pLimit from 'p-limit'
import FeaturesUpdater from '../app/src/Features/Subscription/FeaturesUpdater.js' import FeaturesUpdater from '../app/src/Features/Subscription/FeaturesUpdater.js'

View file

@ -1,7 +1,7 @@
import fs from 'node:fs' import fs from 'node:fs'
import minimist from 'minimist' import minimist from 'minimist'
import { parse } from 'csv' import { parse } from 'csv'
import Stream from 'stream/promises' import Stream from 'node:stream/promises'
import { ObjectId } from '../app/src/infrastructure/mongodb.js' import { ObjectId } from '../app/src/infrastructure/mongodb.js'
import { Subscription } from '../app/src/models/Subscription.js' import { Subscription } from '../app/src/models/Subscription.js'

View file

@ -1,7 +1,7 @@
// Usage: node scripts/add_user_count_to_csv.mjs [OPTS] [INPUT-FILE] // Usage: node scripts/add_user_count_to_csv.mjs [OPTS] [INPUT-FILE]
// Looks up the number of users for each domain in the input csv file and adds // Looks up the number of users for each domain in the input csv file and adds
// columns for the number of users in the domain, subdomains, and total. // columns for the number of users in the domain, subdomains, and total.
import fs from 'fs' import fs from 'node:fs'
// https://github.com/import-js/eslint-plugin-import/issues/1810 // https://github.com/import-js/eslint-plugin-import/issues/1810
// eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-unresolved
import * as csv from 'csv/sync' import * as csv from 'csv/sync'

View file

@ -2,7 +2,7 @@ import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils' import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils'
import { db } from '../app/src/infrastructure/mongodb.js' import { db } from '../app/src/infrastructure/mongodb.js'
import _ from 'lodash' import _ from 'lodash'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { batchedUpdate } = BatchedUpdateModule const { batchedUpdate } = BatchedUpdateModule
const sleep = promisify(setTimeout) const sleep = promisify(setTimeout)

View file

@ -1,7 +1,7 @@
import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils' import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils'
import { db } from '../app/src/infrastructure/mongodb.js' import { db } from '../app/src/infrastructure/mongodb.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
import _ from 'lodash' import _ from 'lodash'
const sleep = promisify(setTimeout) const sleep = promisify(setTimeout)

View file

@ -1,6 +1,6 @@
import { db } from '../app/src/infrastructure/mongodb.js' import { db } from '../app/src/infrastructure/mongodb.js'
import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { batchedUpdate } = BatchedUpdateModule const { batchedUpdate } = BatchedUpdateModule

View file

@ -1,4 +1,4 @@
import { promisify } from 'util' import { promisify } from 'node:util'
import mongodb from 'mongodb-legacy' import mongodb from 'mongodb-legacy'
import { import {
db, db,
@ -6,7 +6,7 @@ import {
} from '../app/src/infrastructure/mongodb.js' } from '../app/src/infrastructure/mongodb.js'
import _ from 'lodash' import _ from 'lodash'
import LRUCache from 'lru-cache' import LRUCache from 'lru-cache'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { ObjectId } = mongodb const { ObjectId } = mongodb
const sleep = promisify(setTimeout) const sleep = promisify(setTimeout)

View file

@ -2,7 +2,7 @@ import { db } from '../app/src/infrastructure/mongodb.js'
import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import minimist from 'minimist' import minimist from 'minimist'
import CollaboratorsInviteHelper from '../app/src/Features/Collaborators/CollaboratorsInviteHelper.js' import CollaboratorsInviteHelper from '../app/src/Features/Collaborators/CollaboratorsInviteHelper.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { batchedUpdate } = BatchedUpdateModule const { batchedUpdate } = BatchedUpdateModule

View file

@ -1,5 +1,5 @@
import minimist from 'minimist' import minimist from 'minimist'
import { promisify } from 'util' import { promisify } from 'node:util'
import bcrypt from 'bcrypt' import bcrypt from 'bcrypt'
import { promiseMapWithLimit } from '@overleaf/promise-utils' import { promiseMapWithLimit } from '@overleaf/promise-utils'
// https://github.com/import-js/eslint-plugin-import/issues/1810 // https://github.com/import-js/eslint-plugin-import/issues/1810

View file

@ -6,7 +6,7 @@
*/ */
import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import { db, ObjectId } from '../app/src/infrastructure/mongodb.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const runScript = async (timestamp, dryRun) => { const runScript = async (timestamp, dryRun) => {
const t = new Date(timestamp) const t = new Date(timestamp)

View file

@ -1,6 +1,6 @@
import { promisify } from 'util' import { promisify } from 'node:util'
import InstitutionsManager from '../app/src/Features/Institutions/InstitutionsManager.js' import InstitutionsManager from '../app/src/Features/Institutions/InstitutionsManager.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const sleep = promisify(setTimeout) const sleep = promisify(setTimeout)
async function main() { async function main() {

View file

@ -1,4 +1,4 @@
import fs from 'fs' import fs from 'node:fs'
import { ObjectId } from '../app/src/infrastructure/mongodb.js' import { ObjectId } from '../app/src/infrastructure/mongodb.js'
import async from 'async' import async from 'async'
import UserUpdater from '../app/src/Features/User/UserUpdater.js' import UserUpdater from '../app/src/Features/User/UserUpdater.js'

View file

@ -1,5 +1,5 @@
import { db } from '../app/src/infrastructure/mongodb.js' import { db } from '../app/src/infrastructure/mongodb.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
async function updateStringDates() { async function updateStringDates() {
const users = await db.users.aggregate([ const users = await db.users.aggregate([

View file

@ -2,7 +2,7 @@ import _ from 'lodash'
import { db } from '../app/src/infrastructure/mongodb.js' import { db } from '../app/src/infrastructure/mongodb.js'
import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import { promiseMapWithLimit } from '@overleaf/promise-utils' import { promiseMapWithLimit } from '@overleaf/promise-utils'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { batchedUpdate } = BatchedUpdateModule const { batchedUpdate } = BatchedUpdateModule

View file

@ -1,4 +1,4 @@
import readline from 'readline' import readline from 'node:readline'
import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js' import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js'
import ProjectGetter from '../app/src/Features/Project/ProjectGetter.js' import ProjectGetter from '../app/src/Features/Project/ProjectGetter.js'
import Errors from '../app/src/Features/Errors/Errors.js' import Errors from '../app/src/Features/Errors/Errors.js'

View file

@ -1,4 +1,4 @@
import readline from 'readline' import readline from 'node:readline'
import { ObjectId, db } from '../app/src/infrastructure/mongodb.js' import { ObjectId, db } from '../app/src/infrastructure/mongodb.js'
import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js' import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js'
import ProjectGetter from '../app/src/Features/Project/ProjectGetter.js' import ProjectGetter from '../app/src/Features/Project/ProjectGetter.js'

View file

@ -2,9 +2,9 @@
// Example: // Example:
// node scripts/create_project.js --user-id=5dca84e11e71ae002ff73bd4 --name="My Test Project" --old-history // node scripts/create_project.js --user-id=5dca84e11e71ae002ff73bd4 --name="My Test Project" --old-history
import fs from 'fs' import fs from 'node:fs'
import path from 'path' import path from 'node:path'
import _ from 'lodash' import _ from 'lodash'
import parseArgs from 'minimist' import parseArgs from 'minimist'
import OError from '@overleaf/o-error' import OError from '@overleaf/o-error'
@ -13,7 +13,7 @@ import ProjectCreationHandler from '../app/src/Features/Project/ProjectCreationH
import ProjectEntityUpdateHandler from '../app/src/Features/Project/ProjectEntityUpdateHandler.js' import ProjectEntityUpdateHandler from '../app/src/Features/Project/ProjectEntityUpdateHandler.js'
import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js' import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js'
import EditorController from '../app/src/Features/Editor/EditorController.js' import EditorController from '../app/src/Features/Editor/EditorController.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const __dirname = path.dirname(fileURLToPath(import.meta.url)) const __dirname = path.dirname(fileURLToPath(import.meta.url))

View file

@ -1,6 +1,6 @@
import fs from 'fs' import fs from 'node:fs'
import minimist from 'minimist' import minimist from 'minimist'
import readline from 'readline' import readline from 'node:readline'
import { db, ObjectId } from '../../app/src/infrastructure/mongodb.js' import { db, ObjectId } from '../../app/src/infrastructure/mongodb.js'
import DocstoreManagerModule from '../../app/src/Features/Docstore/DocstoreManager.js' import DocstoreManagerModule from '../../app/src/Features/Docstore/DocstoreManager.js'

View file

@ -1,5 +1,5 @@
import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js'
import { promisify } from 'util' import { promisify } from 'node:util'
import mongodb from 'mongodb-legacy' import mongodb from 'mongodb-legacy'
import { import {
db, db,

View file

@ -1,8 +1,8 @@
import { promisify } from 'util' import { promisify } from 'node:util'
import Settings from '@overleaf/settings' import Settings from '@overleaf/settings'
import AdminController from '../app/src/Features/ServerAdmin/AdminController.js' import AdminController from '../app/src/Features/ServerAdmin/AdminController.js'
import minimist from 'minimist' import minimist from 'minimist'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const args = minimist(process.argv.slice(2), { const args = minimist(process.argv.slice(2), {
string: ['confirm-site-url', 'delay-in-seconds'], string: ['confirm-site-url', 'delay-in-seconds'],

View file

@ -1,5 +1,5 @@
import fs from 'fs' import fs from 'node:fs'
import path from 'path' import path from 'node:path'
import minimist from 'minimist' import minimist from 'minimist'
const APP_CODE_PATH = ['app', 'modules', 'migrations', 'scripts', 'test'] const APP_CODE_PATH = ['app', 'modules', 'migrations', 'scripts', 'test']

View file

@ -7,7 +7,7 @@
*/ */
import { User } from '../../app/src/models/User.js' import { User } from '../../app/src/models/User.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
// const somePackage = require('some-package') // const somePackage = require('some-package')

View file

@ -1,4 +1,4 @@
import fs from 'fs' import fs from 'node:fs'
import minimist from 'minimist' import minimist from 'minimist'
import { ObjectId } from '../app/src/infrastructure/mongodb.js' import { ObjectId } from '../app/src/infrastructure/mongodb.js'
import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js'

View file

@ -1,13 +1,13 @@
import crypto from 'crypto' import crypto from 'node:crypto'
import fs from 'fs' import fs from 'node:fs'
import Path from 'path' import Path from 'node:path'
import cheerio from 'cheerio' import cheerio from 'cheerio'
// checkSanitizeOptions is only used in dev env // checkSanitizeOptions is only used in dev env
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import prettier from 'prettier' import prettier from 'prettier'
import sanitizeHtml from 'sanitize-html' import sanitizeHtml from 'sanitize-html'
import { sanitizeOptions } from '../../../modules/learn/app/src/sanitizeOptions.js' import { sanitizeOptions } from '../../../modules/learn/app/src/sanitizeOptions.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const __dirname = Path.dirname(fileURLToPath(import.meta.url)) const __dirname = Path.dirname(fileURLToPath(import.meta.url))
const EXTRACT_STYLE = process.env.EXTRACT_STYLES === 'true' const EXTRACT_STYLE = process.env.EXTRACT_STYLES === 'true'

View file

@ -1,6 +1,6 @@
import checkSanitizeOptions from './checkSanitizeOptions.mjs' import checkSanitizeOptions from './checkSanitizeOptions.mjs'
import Scrape from './scrape.mjs' import Scrape from './scrape.mjs'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { getAllPagesAndCache, scrapeAndCachePage } = Scrape const { getAllPagesAndCache, scrapeAndCachePage } = Scrape

View file

@ -1,12 +1,12 @@
import Path from 'path' import Path from 'node:path'
import fs from 'fs' import fs from 'node:fs'
import { import {
fetchString, fetchString,
fetchJson, fetchJson,
RequestFailedError, RequestFailedError,
} from '@overleaf/fetch-utils' } from '@overleaf/fetch-utils'
import crypto from 'crypto' import crypto from 'node:crypto'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const __dirname = Path.dirname(fileURLToPath(import.meta.url)) const __dirname = Path.dirname(fileURLToPath(import.meta.url))
const CACHE_IN = Path.join( const CACHE_IN = Path.join(

View file

@ -1,8 +1,8 @@
import { parser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs' import { parser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs'
import * as fs from 'fs' import * as fs from 'node:fs'
import * as path from 'path' import * as path from 'node:path'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
import minimist from 'minimist' import minimist from 'minimist'
const argv = minimist(process.argv.slice(2)) const argv = minimist(process.argv.slice(2))

View file

@ -1,4 +1,4 @@
import { readFileSync } from 'fs' import { readFileSync } from 'node:fs'
import { logTree } from './print-tree.mjs' import { logTree } from './print-tree.mjs'
import { parser as LaTeXParser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs' import { parser as LaTeXParser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs'
import { parser as BibTeXParser } from '../../frontend/js/features/source-editor/lezer-bibtex/bibtex.mjs' import { parser as BibTeXParser } from '../../frontend/js/features/source-editor/lezer-bibtex/bibtex.mjs'

View file

@ -1,8 +1,8 @@
import { parser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs' import { parser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs'
import * as fs from 'fs' import * as fs from 'node:fs'
import * as path from 'path' import * as path from 'node:path'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
import { TreeFragment } from '@lezer/common' import { TreeFragment } from '@lezer/common'
import minimist from 'minimist' import minimist from 'minimist'
import { seed, random } from './random.mjs' import { seed, random } from './random.mjs'

View file

@ -1,7 +1,7 @@
import Adapter from '../migrations/lib/adapter.mjs' import Adapter from '../migrations/lib/adapter.mjs'
import { promises as fs } from 'fs' import { promises as fs } from 'node:fs'
import { join, dirname } from 'path' import { join, dirname } from 'node:path'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url)) const __dirname = dirname(fileURLToPath(import.meta.url))

View file

@ -2,7 +2,7 @@ import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils' import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils'
import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import { db, ObjectId } from '../app/src/infrastructure/mongodb.js'
import _ from 'lodash' import _ from 'lodash'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const sleep = promisify(setTimeout) const sleep = promisify(setTimeout)
const { batchedUpdate } = BatchedUpdateModule const { batchedUpdate } = BatchedUpdateModule

View file

@ -4,10 +4,10 @@
// https://github.com/import-js/eslint-plugin-import/issues/1810 // https://github.com/import-js/eslint-plugin-import/issues/1810
// eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-unresolved
import * as csv from 'csv/sync' import * as csv from 'csv/sync'
import fs from 'fs' import fs from 'node:fs'
import path from 'path' import path from 'node:path'
import minimist from 'minimist' import minimist from 'minimist'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const __dirname = path.dirname(fileURLToPath(import.meta.url)) const __dirname = path.dirname(fileURLToPath(import.meta.url))

View file

@ -1,5 +1,5 @@
import fs from 'fs' import fs from 'node:fs'
import { setTimeout } from 'timers/promises' import { setTimeout } from 'node:timers/promises'
import * as csv from 'csv' import * as csv from 'csv'
import minimist from 'minimist' import minimist from 'minimist'
import recurly from 'recurly' import recurly from 'recurly'

View file

@ -1,7 +1,7 @@
import RecurlyWrapper from '../../app/src/Features/Subscription/RecurlyWrapper.js' import RecurlyWrapper from '../../app/src/Features/Subscription/RecurlyWrapper.js'
import minimist from 'minimist' import minimist from 'minimist'
import logger from '@overleaf/logger' import logger from '@overleaf/logger'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const waitMs = const waitMs =
fileURLToPath(import.meta.url) === process.argv[1] fileURLToPath(import.meta.url) === process.argv[1]

View file

@ -22,7 +22,7 @@ import minimist from 'minimist'
// eslint-disable-next-line import/no-unresolved // eslint-disable-next-line import/no-unresolved
import * as csv from 'csv/sync' import * as csv from 'csv/sync'
import _ from 'lodash' import _ from 'lodash'
import fs from 'fs' import fs from 'node:fs'
const argv = minimist(process.argv.slice(2), { const argv = minimist(process.argv.slice(2), {
string: ['output', 'file'], string: ['output', 'file'],

View file

@ -19,7 +19,7 @@ import recurly from 'recurly'
import Settings from '@overleaf/settings' import Settings from '@overleaf/settings'
import minimist from 'minimist' import minimist from 'minimist'
import _ from 'lodash' import _ from 'lodash'
import fs from 'fs' import fs from 'node:fs'
const recurlySettings = Settings.apis.recurly const recurlySettings = Settings.apis.recurly
const recurlyApiKey = recurlySettings ? recurlySettings.apiKey : undefined const recurlyApiKey = recurlySettings ? recurlySettings.apiKey : undefined

View file

@ -4,7 +4,7 @@ import SubscriptionUpdater from '../../app/src/Features/Subscription/Subscriptio
import minimist from 'minimist' import minimist from 'minimist'
import { setTimeout } from 'node:timers/promises' import { setTimeout } from 'node:timers/promises'
import util from 'util' import util from 'node:util'
import pLimit from 'p-limit' import pLimit from 'p-limit'

View file

@ -6,7 +6,7 @@ import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import mongodb from 'mongodb-legacy' import mongodb from 'mongodb-legacy'
import minimist from 'minimist' import minimist from 'minimist'
import CollaboratorsHandler from '../app/src/Features/Collaborators/CollaboratorsHandler.js' import CollaboratorsHandler from '../app/src/Features/Collaborators/CollaboratorsHandler.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { ObjectId } = mongodb const { ObjectId } = mongodb

View file

@ -1,5 +1,5 @@
import { db } from '../app/src/infrastructure/mongodb.js' import { db } from '../app/src/infrastructure/mongodb.js'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
async function updateStringDates() { async function updateStringDates() {
const users = db.users.find({ const users = db.users.find({

View file

@ -1,8 +1,8 @@
import { db } from '../app/src/infrastructure/mongodb.js' import { db } from '../app/src/infrastructure/mongodb.js'
import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import BatchedUpdateModule from './helpers/batchedUpdate.mjs'
import mongodb from 'mongodb-legacy' import mongodb from 'mongodb-legacy'
import fs from 'fs' import fs from 'node:fs'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'node:url'
const { ObjectId } = mongodb const { ObjectId } = mongodb
const { batchedUpdate } = BatchedUpdateModule const { batchedUpdate } = BatchedUpdateModule

View file

@ -3,11 +3,11 @@ import settings from '@overleaf/settings'
import ProjectDetailsHandler from '../app/src/Features/Project/ProjectDetailsHandler.js' import ProjectDetailsHandler from '../app/src/Features/Project/ProjectDetailsHandler.js'
import mongodb from '../app/src/infrastructure/mongodb.js' import mongodb from '../app/src/infrastructure/mongodb.js'
import mongoose from '../app/src/infrastructure/Mongoose.js' import mongoose from '../app/src/infrastructure/Mongoose.js'
import fs from 'fs' import fs from 'node:fs'
import path from 'path' import path from 'node:path'
import crypto from 'crypto' import crypto from 'node:crypto'
import fetch from 'node-fetch' import fetch from 'node-fetch'
import http from 'http' import http from 'node:http'
import _ from 'lodash' import _ from 'lodash'
const { ObjectId } = mongodb const { ObjectId } = mongodb

View file

@ -1,4 +1,4 @@
import fs from 'fs' import fs from 'node:fs'
import minimist from 'minimist' import minimist from 'minimist'
import InstitutionsAPIModule from '../../app/src/Features/Institutions/InstitutionsAPI.js' import InstitutionsAPIModule from '../../app/src/Features/Institutions/InstitutionsAPI.js'