diff --git a/services/web/.eslintrc.js b/services/web/.eslintrc.js index fa53bbd91e..193313152c 100644 --- a/services/web/.eslintrc.js +++ b/services/web/.eslintrc.js @@ -107,7 +107,6 @@ module.exports = { }, plugins: ['unicorn'], rules: { - 'unicorn/prefer-module': 'error', 'import/no-unresolved': 'error', 'import/extensions': [ 'error', @@ -117,6 +116,8 @@ module.exports = { mjs: 'always', }, ], + 'unicorn/prefer-module': 'error', + 'unicorn/prefer-node-protocol': 'error', }, }, { diff --git a/services/web/app.mjs b/services/web/app.mjs index 3f50184025..1c4c9de03f 100644 --- a/services/web/app.mjs +++ b/services/web/app.mjs @@ -16,7 +16,7 @@ import mongodb from './app/src/infrastructure/mongodb.js' import mongoose from './app/src/infrastructure/Mongoose.js' import { triggerGracefulShutdown } from './app/src/infrastructure/GracefulShutdown.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.logger.serializers.user = Serializers.user diff --git a/services/web/app/src/Features/Analytics/AnalyticsUTMTrackingMiddleware.mjs b/services/web/app/src/Features/Analytics/AnalyticsUTMTrackingMiddleware.mjs index c5b51001a1..d2f1f70b7c 100644 --- a/services/web/app/src/Features/Analytics/AnalyticsUTMTrackingMiddleware.mjs +++ b/services/web/app/src/Features/Analytics/AnalyticsUTMTrackingMiddleware.mjs @@ -1,8 +1,8 @@ import _ from 'lodash' import RequestHelper from './RequestHelper.js' import AnalyticsManager from './AnalyticsManager.js' -import querystring from 'querystring' -import { URL } from 'url' +import querystring from 'node:querystring' +import { URL } from 'node:url' import Settings from '@overleaf/settings' import OError from '@overleaf/o-error' import logger from '@overleaf/logger' diff --git a/services/web/app/src/Features/BetaProgram/BetaProgramHandler.mjs b/services/web/app/src/Features/BetaProgram/BetaProgramHandler.mjs index d9861f41fb..74270eafa1 100644 --- a/services/web/app/src/Features/BetaProgram/BetaProgramHandler.mjs +++ b/services/web/app/src/Features/BetaProgram/BetaProgramHandler.mjs @@ -1,4 +1,4 @@ -import { callbackify } from 'util' +import { callbackify } from 'node:util' import metrics from '@overleaf/metrics' import UserUpdater from '../User/UserUpdater.js' import AnalyticsManager from '../Analytics/AnalyticsManager.js' diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsEmailHandler.mjs b/services/web/app/src/Features/Collaborators/CollaboratorsEmailHandler.mjs index 4064acbee1..d63206d031 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsEmailHandler.mjs +++ b/services/web/app/src/Features/Collaborators/CollaboratorsEmailHandler.mjs @@ -1,4 +1,4 @@ -import { callbackify } from 'util' +import { callbackify } from 'node:util' import { Project } from '../../models/Project.js' import EmailHandler from '../Email/EmailHandler.js' import Settings from '@overleaf/settings' diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs b/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs index ad452b5e0b..241ed2cb75 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs +++ b/services/web/app/src/Features/Collaborators/CollaboratorsInviteController.mjs @@ -1,4 +1,4 @@ -import { callbackify } from 'util' +import { callbackify } from 'node:util' import ProjectGetter from '../Project/ProjectGetter.js' import LimitationsManager from '../Subscription/LimitationsManager.js' import UserGetter from '../User/UserGetter.js' diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.mjs b/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.mjs index 79b06ca223..61ac058788 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.mjs +++ b/services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.mjs @@ -1,4 +1,4 @@ -import { callbackify } from 'util' +import { callbackify } from 'node:util' import { ProjectInvite } from '../../models/ProjectInvite.js' import logger from '@overleaf/logger' import CollaboratorsEmailHandler from './CollaboratorsEmailHandler.mjs' diff --git a/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs b/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs index 54a123efe0..e76267a199 100644 --- a/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs +++ b/services/web/app/src/Features/History/HistoryRangesSupportMigration.mjs @@ -1,6 +1,6 @@ // @ts-check -import { callbackify } from 'util' +import { callbackify } from 'node:util' import OError from '@overleaf/o-error' import logger from '@overleaf/logger' import HistoryManager from '../History/HistoryManager.js' diff --git a/services/web/app/src/Features/PasswordReset/PasswordResetHandler.mjs b/services/web/app/src/Features/PasswordReset/PasswordResetHandler.mjs index 2d51eab156..b6d837ca23 100644 --- a/services/web/app/src/Features/PasswordReset/PasswordResetHandler.mjs +++ b/services/web/app/src/Features/PasswordReset/PasswordResetHandler.mjs @@ -4,7 +4,7 @@ import UserGetter from '../User/UserGetter.js' import OneTimeTokenHandler from '../Security/OneTimeTokenHandler.js' import EmailHandler from '../Email/EmailHandler.js' import AuthenticationManager from '../Authentication/AuthenticationManager.js' -import { callbackify, promisify } from 'util' +import { callbackify, promisify } from 'node:util' import PermissionsManager from '../Authorization/PermissionsManager.js' const assertUserPermissions = PermissionsManager.promises.assertUserPermissions diff --git a/services/web/app/src/Features/StaticPages/HomeController.mjs b/services/web/app/src/Features/StaticPages/HomeController.mjs index a7cd8e42c4..45e96b1fd8 100644 --- a/services/web/app/src/Features/StaticPages/HomeController.mjs +++ b/services/web/app/src/Features/StaticPages/HomeController.mjs @@ -1,7 +1,7 @@ import Features from '../../infrastructure/Features.js' import AnalyticsManager from '../Analytics/AnalyticsManager.js' -import Path from 'path' -import fs from 'fs' +import Path from 'node:path' +import fs from 'node:fs' import ErrorController from '../Errors/ErrorController.js' import SessionManager from '../Authentication/SessionManager.js' import { expressify } from '@overleaf/promise-utils' diff --git a/services/web/app/src/Features/Survey/SurveyHandler.mjs b/services/web/app/src/Features/Survey/SurveyHandler.mjs index 6ff2ce2384..009bc12a95 100644 --- a/services/web/app/src/Features/Survey/SurveyHandler.mjs +++ b/services/web/app/src/Features/Survey/SurveyHandler.mjs @@ -1,5 +1,5 @@ // ts-check -import crypto from 'crypto' +import crypto from 'node:crypto' import SurveyCache from './SurveyCache.mjs' import SubscriptionLocator from '../Subscription/SubscriptionLocator.js' diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.mjs b/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.mjs index a8cc4ef4b8..1db15aa932 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.mjs +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsController.mjs @@ -3,7 +3,7 @@ import TpdsUpdateHandler from './TpdsUpdateHandler.mjs' import UpdateMerger from './UpdateMerger.js' import Errors from '../Errors/Errors.js' import logger from '@overleaf/logger' -import Path from 'path' +import Path from 'node:path' import metrics from '@overleaf/metrics' import NotificationsBuilder from '../Notifications/NotificationsBuilder.js' import SessionManager from '../Authentication/SessionManager.js' diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs index d3de27d0ba..c17b54ff1e 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.mjs @@ -1,4 +1,4 @@ -import { callbackify } from 'util' +import { callbackify } from 'node:util' import UpdateMerger from './UpdateMerger.js' import logger from '@overleaf/logger' import NotificationsBuilder from '../Notifications/NotificationsBuilder.js' diff --git a/services/web/app/src/Features/Uploads/ProjectUploadController.mjs b/services/web/app/src/Features/Uploads/ProjectUploadController.mjs index 877d577da7..82ef4c9150 100644 --- a/services/web/app/src/Features/Uploads/ProjectUploadController.mjs +++ b/services/web/app/src/Features/Uploads/ProjectUploadController.mjs @@ -1,7 +1,7 @@ import logger from '@overleaf/logger' import metrics from '@overleaf/metrics' -import fs from 'fs' -import Path from 'path' +import fs from 'node:fs' +import Path from 'node:path' import FileSystemImportManager from './FileSystemImportManager.js' import ProjectUploadManager from './ProjectUploadManager.js' import SessionManager from '../Authentication/SessionManager.js' diff --git a/services/web/app/src/infrastructure/Server.mjs b/services/web/app/src/infrastructure/Server.mjs index 0455044ab6..3c7fd752d6 100644 --- a/services/web/app/src/infrastructure/Server.mjs +++ b/services/web/app/src/infrastructure/Server.mjs @@ -34,9 +34,9 @@ import { hasAdminAccess } from '../Features/Helpers/AdminAuthorizationHelper.js' import Modules from './Modules.js' import expressLocals from './ExpressLocals.js' import noCache from 'nocache' -import os from 'os' -import http from 'http' -import { fileURLToPath } from 'url' +import os from 'node:os' +import http from 'node:http' +import { fileURLToPath } from 'node:url' import serveStaticWrapper from './ServeStaticWrapper.mjs' const sessionsRedisClient = UserSessionsRedis.client() diff --git a/services/web/migrations/20230512100122_ensure_history_migration.mjs b/services/web/migrations/20230512100122_ensure_history_migration.mjs index 79d7892692..93164293c7 100644 --- a/services/web/migrations/20230512100122_ensure_history_migration.mjs +++ b/services/web/migrations/20230512100122_ensure_history_migration.mjs @@ -1,4 +1,4 @@ -import util from 'util' +import util from 'node:util' const { promisify } = util const sleep = promisify(setTimeout) diff --git a/services/web/migrations/lib/adapter.mjs b/services/web/migrations/lib/adapter.mjs index 98c905a50d..e1d4c072d1 100644 --- a/services/web/migrations/lib/adapter.mjs +++ b/services/web/migrations/lib/adapter.mjs @@ -1,6 +1,6 @@ -import Path from 'path' +import Path from 'node:path' import { db } from '../../app/src/infrastructure/mongodb.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const __filename = fileURLToPath(import.meta.url) const __dirname = Path.dirname(__filename) diff --git a/services/web/scripts/add_feature_override.mjs b/services/web/scripts/add_feature_override.mjs index 2ee2d6cb09..0a556e1b9d 100644 --- a/services/web/scripts/add_feature_override.mjs +++ b/services/web/scripts/add_feature_override.mjs @@ -25,7 +25,7 @@ import minimist from 'minimist' -import fs from 'fs' +import fs from 'node:fs' import { ObjectId } from '../app/src/infrastructure/mongodb.js' import pLimit from 'p-limit' import FeaturesUpdater from '../app/src/Features/Subscription/FeaturesUpdater.js' diff --git a/services/web/scripts/add_salesforce_data_to_subscriptions.mjs b/services/web/scripts/add_salesforce_data_to_subscriptions.mjs index 933cc7ce44..02ef02689f 100755 --- a/services/web/scripts/add_salesforce_data_to_subscriptions.mjs +++ b/services/web/scripts/add_salesforce_data_to_subscriptions.mjs @@ -1,7 +1,7 @@ import fs from 'node:fs' import minimist from 'minimist' import { parse } from 'csv' -import Stream from 'stream/promises' +import Stream from 'node:stream/promises' import { ObjectId } from '../app/src/infrastructure/mongodb.js' import { Subscription } from '../app/src/models/Subscription.js' diff --git a/services/web/scripts/add_user_count_to_csv.mjs b/services/web/scripts/add_user_count_to_csv.mjs index c841dab133..b5429cd520 100644 --- a/services/web/scripts/add_user_count_to_csv.mjs +++ b/services/web/scripts/add_user_count_to_csv.mjs @@ -1,7 +1,7 @@ // 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 // 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 // eslint-disable-next-line import/no-unresolved import * as csv from 'csv/sync' diff --git a/services/web/scripts/back_fill_deleted_files.mjs b/services/web/scripts/back_fill_deleted_files.mjs index 9c149e8d57..a2d8a13550 100644 --- a/services/web/scripts/back_fill_deleted_files.mjs +++ b/services/web/scripts/back_fill_deleted_files.mjs @@ -2,7 +2,7 @@ import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils' import { db } from '../app/src/infrastructure/mongodb.js' import _ from 'lodash' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const { batchedUpdate } = BatchedUpdateModule const sleep = promisify(setTimeout) diff --git a/services/web/scripts/back_fill_doc_name_for_deleted_docs.mjs b/services/web/scripts/back_fill_doc_name_for_deleted_docs.mjs index fa3c24211e..f0e44b5d09 100644 --- a/services/web/scripts/back_fill_doc_name_for_deleted_docs.mjs +++ b/services/web/scripts/back_fill_doc_name_for_deleted_docs.mjs @@ -1,7 +1,7 @@ import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils' import { db } from '../app/src/infrastructure/mongodb.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' import _ from 'lodash' const sleep = promisify(setTimeout) diff --git a/services/web/scripts/back_fill_doc_rev.mjs b/services/web/scripts/back_fill_doc_rev.mjs index bfd194b051..22bacf8608 100644 --- a/services/web/scripts/back_fill_doc_rev.mjs +++ b/services/web/scripts/back_fill_doc_rev.mjs @@ -1,6 +1,6 @@ import { db } from '../app/src/infrastructure/mongodb.js' import BatchedUpdateModule from './helpers/batchedUpdate.mjs' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const { batchedUpdate } = BatchedUpdateModule diff --git a/services/web/scripts/back_fill_dummy_doc_meta.mjs b/services/web/scripts/back_fill_dummy_doc_meta.mjs index 2a6726e1f6..0fccdc46a7 100644 --- a/services/web/scripts/back_fill_dummy_doc_meta.mjs +++ b/services/web/scripts/back_fill_dummy_doc_meta.mjs @@ -1,4 +1,4 @@ -import { promisify } from 'util' +import { promisify } from 'node:util' import mongodb from 'mongodb-legacy' import { db, @@ -6,7 +6,7 @@ import { } from '../app/src/infrastructure/mongodb.js' import _ from 'lodash' import LRUCache from 'lru-cache' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const { ObjectId } = mongodb const sleep = promisify(setTimeout) diff --git a/services/web/scripts/backfill_project_invites_token_hmac.mjs b/services/web/scripts/backfill_project_invites_token_hmac.mjs index 6e3a526c88..b7527b61fa 100644 --- a/services/web/scripts/backfill_project_invites_token_hmac.mjs +++ b/services/web/scripts/backfill_project_invites_token_hmac.mjs @@ -2,7 +2,7 @@ import { db } from '../app/src/infrastructure/mongodb.js' import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import minimist from 'minimist' import CollaboratorsInviteHelper from '../app/src/Features/Collaborators/CollaboratorsInviteHelper.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const { batchedUpdate } = BatchedUpdateModule diff --git a/services/web/scripts/bench_bcrypt.mjs b/services/web/scripts/bench_bcrypt.mjs index 79a27224cd..1aee1b583d 100644 --- a/services/web/scripts/bench_bcrypt.mjs +++ b/services/web/scripts/bench_bcrypt.mjs @@ -1,5 +1,5 @@ import minimist from 'minimist' -import { promisify } from 'util' +import { promisify } from 'node:util' import bcrypt from 'bcrypt' import { promiseMapWithLimit } from '@overleaf/promise-utils' // https://github.com/import-js/eslint-plugin-import/issues/1810 diff --git a/services/web/scripts/clear_feedback_collection.mjs b/services/web/scripts/clear_feedback_collection.mjs index 57fd376f01..7db1f0a676 100644 --- a/services/web/scripts/clear_feedback_collection.mjs +++ b/services/web/scripts/clear_feedback_collection.mjs @@ -6,7 +6,7 @@ */ import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const runScript = async (timestamp, dryRun) => { const t = new Date(timestamp) diff --git a/services/web/scripts/clear_institution_notifications.mjs b/services/web/scripts/clear_institution_notifications.mjs index ec8e2f98ef..b97c20d5ff 100644 --- a/services/web/scripts/clear_institution_notifications.mjs +++ b/services/web/scripts/clear_institution_notifications.mjs @@ -1,6 +1,6 @@ -import { promisify } from 'util' +import { promisify } from 'node:util' import InstitutionsManager from '../app/src/Features/Institutions/InstitutionsManager.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const sleep = promisify(setTimeout) async function main() { diff --git a/services/web/scripts/clear_sessions_set_must_reconfirm.mjs b/services/web/scripts/clear_sessions_set_must_reconfirm.mjs index 9b0ea35e38..a5f21a2d89 100644 --- a/services/web/scripts/clear_sessions_set_must_reconfirm.mjs +++ b/services/web/scripts/clear_sessions_set_must_reconfirm.mjs @@ -1,4 +1,4 @@ -import fs from 'fs' +import fs from 'node:fs' import { ObjectId } from '../app/src/infrastructure/mongodb.js' import async from 'async' import UserUpdater from '../app/src/Features/User/UserUpdater.js' diff --git a/services/web/scripts/confirmed_at_to_dates.mjs b/services/web/scripts/confirmed_at_to_dates.mjs index cd03679577..60fcc543fd 100644 --- a/services/web/scripts/confirmed_at_to_dates.mjs +++ b/services/web/scripts/confirmed_at_to_dates.mjs @@ -1,5 +1,5 @@ import { db } from '../app/src/infrastructure/mongodb.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' async function updateStringDates() { const users = await db.users.aggregate([ diff --git a/services/web/scripts/convert_archived_state.mjs b/services/web/scripts/convert_archived_state.mjs index 58c4b54c95..cc6df0831f 100644 --- a/services/web/scripts/convert_archived_state.mjs +++ b/services/web/scripts/convert_archived_state.mjs @@ -2,7 +2,7 @@ import _ from 'lodash' import { db } from '../app/src/infrastructure/mongodb.js' import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import { promiseMapWithLimit } from '@overleaf/promise-utils' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const { batchedUpdate } = BatchedUpdateModule diff --git a/services/web/scripts/count_files_in_projects.mjs b/services/web/scripts/count_files_in_projects.mjs index a0e2156853..437e0d50f1 100644 --- a/services/web/scripts/count_files_in_projects.mjs +++ b/services/web/scripts/count_files_in_projects.mjs @@ -1,4 +1,4 @@ -import readline from 'readline' +import readline from 'node:readline' import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js' import ProjectGetter from '../app/src/Features/Project/ProjectGetter.js' import Errors from '../app/src/Features/Errors/Errors.js' diff --git a/services/web/scripts/count_project_size.mjs b/services/web/scripts/count_project_size.mjs index 7a3a7bd1e6..02f3dea836 100644 --- a/services/web/scripts/count_project_size.mjs +++ b/services/web/scripts/count_project_size.mjs @@ -1,4 +1,4 @@ -import readline from 'readline' +import readline from 'node:readline' import { ObjectId, db } from '../app/src/infrastructure/mongodb.js' import ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.js' import ProjectGetter from '../app/src/Features/Project/ProjectGetter.js' diff --git a/services/web/scripts/create_project.mjs b/services/web/scripts/create_project.mjs index 2ebe35ad99..cc941cf12c 100644 --- a/services/web/scripts/create_project.mjs +++ b/services/web/scripts/create_project.mjs @@ -2,9 +2,9 @@ // Example: // 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 parseArgs from 'minimist' 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 ProjectEntityHandler from '../app/src/Features/Project/ProjectEntityHandler.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)) diff --git a/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs b/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs index e0fa7cd165..6eb0eceaec 100644 --- a/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs +++ b/services/web/scripts/delete-orphaned-docs/delete-orphaned-docs.mjs @@ -1,6 +1,6 @@ -import fs from 'fs' +import fs from 'node:fs' import minimist from 'minimist' -import readline from 'readline' +import readline from 'node:readline' import { db, ObjectId } from '../../app/src/infrastructure/mongodb.js' import DocstoreManagerModule from '../../app/src/Features/Docstore/DocstoreManager.js' diff --git a/services/web/scripts/delete_orphaned_docs_online_check.mjs b/services/web/scripts/delete_orphaned_docs_online_check.mjs index c571d6bd68..2affae4cf9 100644 --- a/services/web/scripts/delete_orphaned_docs_online_check.mjs +++ b/services/web/scripts/delete_orphaned_docs_online_check.mjs @@ -1,5 +1,5 @@ import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js' -import { promisify } from 'util' +import { promisify } from 'node:util' import mongodb from 'mongodb-legacy' import { db, diff --git a/services/web/scripts/disconnect_all_users.mjs b/services/web/scripts/disconnect_all_users.mjs index 41e8fe02df..41736ac69f 100644 --- a/services/web/scripts/disconnect_all_users.mjs +++ b/services/web/scripts/disconnect_all_users.mjs @@ -1,8 +1,8 @@ -import { promisify } from 'util' +import { promisify } from 'node:util' import Settings from '@overleaf/settings' import AdminController from '../app/src/Features/ServerAdmin/AdminController.js' import minimist from 'minimist' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const args = minimist(process.argv.slice(2), { string: ['confirm-site-url', 'delay-in-seconds'], diff --git a/services/web/scripts/esm-check-migration.mjs b/services/web/scripts/esm-check-migration.mjs index d283775921..2ce70d4a30 100644 --- a/services/web/scripts/esm-check-migration.mjs +++ b/services/web/scripts/esm-check-migration.mjs @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import minimist from 'minimist' const APP_CODE_PATH = ['app', 'modules', 'migrations', 'scripts', 'test'] diff --git a/services/web/scripts/example/script_for_migration.mjs b/services/web/scripts/example/script_for_migration.mjs index ed1d288aa8..0c201eebab 100644 --- a/services/web/scripts/example/script_for_migration.mjs +++ b/services/web/scripts/example/script_for_migration.mjs @@ -7,7 +7,7 @@ */ import { User } from '../../app/src/models/User.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' // const somePackage = require('some-package') diff --git a/services/web/scripts/fix_oversized_docs.mjs b/services/web/scripts/fix_oversized_docs.mjs index b3f160d362..07f66a76cf 100644 --- a/services/web/scripts/fix_oversized_docs.mjs +++ b/services/web/scripts/fix_oversized_docs.mjs @@ -1,4 +1,4 @@ -import fs from 'fs' +import fs from 'node:fs' import minimist from 'minimist' import { ObjectId } from '../app/src/infrastructure/mongodb.js' import DocstoreManager from '../app/src/Features/Docstore/DocstoreManager.js' diff --git a/services/web/scripts/learn/checkSanitize/checkSanitizeOptions.mjs b/services/web/scripts/learn/checkSanitize/checkSanitizeOptions.mjs index 6eec5ce845..90c2330bb7 100644 --- a/services/web/scripts/learn/checkSanitize/checkSanitizeOptions.mjs +++ b/services/web/scripts/learn/checkSanitize/checkSanitizeOptions.mjs @@ -1,13 +1,13 @@ -import crypto from 'crypto' -import fs from 'fs' -import Path from 'path' +import crypto from 'node:crypto' +import fs from 'node:fs' +import Path from 'node:path' import cheerio from 'cheerio' // checkSanitizeOptions is only used in dev env // eslint-disable-next-line import/no-extraneous-dependencies import prettier from 'prettier' import sanitizeHtml from 'sanitize-html' 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 EXTRACT_STYLE = process.env.EXTRACT_STYLES === 'true' diff --git a/services/web/scripts/learn/checkSanitize/index.mjs b/services/web/scripts/learn/checkSanitize/index.mjs index 6040e831e8..1c608cb2fe 100644 --- a/services/web/scripts/learn/checkSanitize/index.mjs +++ b/services/web/scripts/learn/checkSanitize/index.mjs @@ -1,6 +1,6 @@ import checkSanitizeOptions from './checkSanitizeOptions.mjs' import Scrape from './scrape.mjs' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const { getAllPagesAndCache, scrapeAndCachePage } = Scrape diff --git a/services/web/scripts/learn/checkSanitize/scrape.mjs b/services/web/scripts/learn/checkSanitize/scrape.mjs index 4052ed2797..f44dc15890 100644 --- a/services/web/scripts/learn/checkSanitize/scrape.mjs +++ b/services/web/scripts/learn/checkSanitize/scrape.mjs @@ -1,12 +1,12 @@ -import Path from 'path' -import fs from 'fs' +import Path from 'node:path' +import fs from 'node:fs' import { fetchString, fetchJson, RequestFailedError, } from '@overleaf/fetch-utils' -import crypto from 'crypto' -import { fileURLToPath } from 'url' +import crypto from 'node:crypto' +import { fileURLToPath } from 'node:url' const __dirname = Path.dirname(fileURLToPath(import.meta.url)) const CACHE_IN = Path.join( diff --git a/services/web/scripts/lezer-latex/benchmark.mjs b/services/web/scripts/lezer-latex/benchmark.mjs index d2ca0bc714..66e54f859a 100644 --- a/services/web/scripts/lezer-latex/benchmark.mjs +++ b/services/web/scripts/lezer-latex/benchmark.mjs @@ -1,8 +1,8 @@ import { parser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs' -import * as fs from 'fs' -import * as path from 'path' -import { fileURLToPath } from 'url' +import * as fs from 'node:fs' +import * as path from 'node:path' +import { fileURLToPath } from 'node:url' import minimist from 'minimist' const argv = minimist(process.argv.slice(2)) diff --git a/services/web/scripts/lezer-latex/run.mjs b/services/web/scripts/lezer-latex/run.mjs index bda582e29b..a85197ada2 100644 --- a/services/web/scripts/lezer-latex/run.mjs +++ b/services/web/scripts/lezer-latex/run.mjs @@ -1,4 +1,4 @@ -import { readFileSync } from 'fs' +import { readFileSync } from 'node:fs' import { logTree } from './print-tree.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' diff --git a/services/web/scripts/lezer-latex/test-incremental-parser.mjs b/services/web/scripts/lezer-latex/test-incremental-parser.mjs index a32894e16e..31dc0ca301 100644 --- a/services/web/scripts/lezer-latex/test-incremental-parser.mjs +++ b/services/web/scripts/lezer-latex/test-incremental-parser.mjs @@ -1,8 +1,8 @@ import { parser } from '../../frontend/js/features/source-editor/lezer-latex/latex.mjs' -import * as fs from 'fs' -import * as path from 'path' -import { fileURLToPath } from 'url' +import * as fs from 'node:fs' +import * as path from 'node:path' +import { fileURLToPath } from 'node:url' import { TreeFragment } from '@lezer/common' import minimist from 'minimist' import { seed, random } from './random.mjs' diff --git a/services/web/scripts/mark_migration.mjs b/services/web/scripts/mark_migration.mjs index 6223d607a0..cf592140a3 100644 --- a/services/web/scripts/mark_migration.mjs +++ b/services/web/scripts/mark_migration.mjs @@ -1,7 +1,7 @@ import Adapter from '../migrations/lib/adapter.mjs' -import { promises as fs } from 'fs' -import { join, dirname } from 'path' -import { fileURLToPath } from 'url' +import { promises as fs } from 'node:fs' +import { join, dirname } from 'node:path' +import { fileURLToPath } from 'node:url' const __dirname = dirname(fileURLToPath(import.meta.url)) diff --git a/services/web/scripts/migrate_audit_logs.mjs b/services/web/scripts/migrate_audit_logs.mjs index f5cf3c819e..5e1c689e38 100644 --- a/services/web/scripts/migrate_audit_logs.mjs +++ b/services/web/scripts/migrate_audit_logs.mjs @@ -2,7 +2,7 @@ import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import { promiseMapWithLimit, promisify } from '@overleaf/promise-utils' import { db, ObjectId } from '../app/src/infrastructure/mongodb.js' import _ from 'lodash' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const sleep = promisify(setTimeout) const { batchedUpdate } = BatchedUpdateModule diff --git a/services/web/scripts/plan-prices/plans.mjs b/services/web/scripts/plan-prices/plans.mjs index b648c77cb5..0ef6450370 100644 --- a/services/web/scripts/plan-prices/plans.mjs +++ b/services/web/scripts/plan-prices/plans.mjs @@ -4,10 +4,10 @@ // https://github.com/import-js/eslint-plugin-import/issues/1810 // eslint-disable-next-line import/no-unresolved import * as csv from 'csv/sync' -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import minimist from 'minimist' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const __dirname = path.dirname(fileURLToPath(import.meta.url)) diff --git a/services/web/scripts/recurly/change_prices_at_renewal.mjs b/services/web/scripts/recurly/change_prices_at_renewal.mjs index 05c28ddfe9..ad891f1b9d 100644 --- a/services/web/scripts/recurly/change_prices_at_renewal.mjs +++ b/services/web/scripts/recurly/change_prices_at_renewal.mjs @@ -1,5 +1,5 @@ -import fs from 'fs' -import { setTimeout } from 'timers/promises' +import fs from 'node:fs' +import { setTimeout } from 'node:timers/promises' import * as csv from 'csv' import minimist from 'minimist' import recurly from 'recurly' diff --git a/services/web/scripts/recurly/collect_paypal_past_due_invoice.mjs b/services/web/scripts/recurly/collect_paypal_past_due_invoice.mjs index ba07d2040e..b735ea17ed 100644 --- a/services/web/scripts/recurly/collect_paypal_past_due_invoice.mjs +++ b/services/web/scripts/recurly/collect_paypal_past_due_invoice.mjs @@ -1,7 +1,7 @@ import RecurlyWrapper from '../../app/src/Features/Subscription/RecurlyWrapper.js' import minimist from 'minimist' import logger from '@overleaf/logger' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const waitMs = fileURLToPath(import.meta.url) === process.argv[1] diff --git a/services/web/scripts/recurly/generate_recurly_prices.mjs b/services/web/scripts/recurly/generate_recurly_prices.mjs index f9d6e49e37..78cb7e2138 100644 --- a/services/web/scripts/recurly/generate_recurly_prices.mjs +++ b/services/web/scripts/recurly/generate_recurly_prices.mjs @@ -22,7 +22,7 @@ import minimist from 'minimist' // eslint-disable-next-line import/no-unresolved import * as csv from 'csv/sync' import _ from 'lodash' -import fs from 'fs' +import fs from 'node:fs' const argv = minimist(process.argv.slice(2), { string: ['output', 'file'], diff --git a/services/web/scripts/recurly/recurly_prices.mjs b/services/web/scripts/recurly/recurly_prices.mjs index cf9649da1a..91786e14ab 100644 --- a/services/web/scripts/recurly/recurly_prices.mjs +++ b/services/web/scripts/recurly/recurly_prices.mjs @@ -19,7 +19,7 @@ import recurly from 'recurly' import Settings from '@overleaf/settings' import minimist from 'minimist' import _ from 'lodash' -import fs from 'fs' +import fs from 'node:fs' const recurlySettings = Settings.apis.recurly const recurlyApiKey = recurlySettings ? recurlySettings.apiKey : undefined diff --git a/services/web/scripts/recurly/resync_subscriptions.mjs b/services/web/scripts/recurly/resync_subscriptions.mjs index d97104d526..a0b5ca1438 100644 --- a/services/web/scripts/recurly/resync_subscriptions.mjs +++ b/services/web/scripts/recurly/resync_subscriptions.mjs @@ -4,7 +4,7 @@ import SubscriptionUpdater from '../../app/src/Features/Subscription/Subscriptio import minimist from 'minimist' import { setTimeout } from 'node:timers/promises' -import util from 'util' +import util from 'node:util' import pLimit from 'p-limit' diff --git a/services/web/scripts/remove_deleted_users_from_token_access_refs.mjs b/services/web/scripts/remove_deleted_users_from_token_access_refs.mjs index b515ee48ad..6a39ce6426 100644 --- a/services/web/scripts/remove_deleted_users_from_token_access_refs.mjs +++ b/services/web/scripts/remove_deleted_users_from_token_access_refs.mjs @@ -6,7 +6,7 @@ import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import mongodb from 'mongodb-legacy' import minimist from 'minimist' import CollaboratorsHandler from '../app/src/Features/Collaborators/CollaboratorsHandler.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const { ObjectId } = mongodb diff --git a/services/web/scripts/split_tests_assigned_at_to_dates.mjs b/services/web/scripts/split_tests_assigned_at_to_dates.mjs index dbdabee23a..ea6fd3fbea 100644 --- a/services/web/scripts/split_tests_assigned_at_to_dates.mjs +++ b/services/web/scripts/split_tests_assigned_at_to_dates.mjs @@ -1,5 +1,5 @@ import { db } from '../app/src/infrastructure/mongodb.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' async function updateStringDates() { const users = db.users.find({ diff --git a/services/web/scripts/split_writefull_disabled_from_unset.mjs b/services/web/scripts/split_writefull_disabled_from_unset.mjs index 880f20f134..03181c53b3 100644 --- a/services/web/scripts/split_writefull_disabled_from_unset.mjs +++ b/services/web/scripts/split_writefull_disabled_from_unset.mjs @@ -1,8 +1,8 @@ import { db } from '../app/src/infrastructure/mongodb.js' import BatchedUpdateModule from './helpers/batchedUpdate.mjs' import mongodb from 'mongodb-legacy' -import fs from 'fs' -import { fileURLToPath } from 'url' +import fs from 'node:fs' +import { fileURLToPath } from 'node:url' const { ObjectId } = mongodb const { batchedUpdate } = BatchedUpdateModule diff --git a/services/web/scripts/stress_test.mjs b/services/web/scripts/stress_test.mjs index 3b149c1fee..64bc9f0d05 100644 --- a/services/web/scripts/stress_test.mjs +++ b/services/web/scripts/stress_test.mjs @@ -3,11 +3,11 @@ import settings from '@overleaf/settings' import ProjectDetailsHandler from '../app/src/Features/Project/ProjectDetailsHandler.js' import mongodb from '../app/src/infrastructure/mongodb.js' import mongoose from '../app/src/infrastructure/Mongoose.js' -import fs from 'fs' -import path from 'path' -import crypto from 'crypto' +import fs from 'node:fs' +import path from 'node:path' +import crypto from 'node:crypto' import fetch from 'node-fetch' -import http from 'http' +import http from 'node:http' import _ from 'lodash' const { ObjectId } = mongodb diff --git a/services/web/scripts/sync-user-entitlements/sync-user-entitlements.mjs b/services/web/scripts/sync-user-entitlements/sync-user-entitlements.mjs index 70f4d856ae..72db3e8a5b 100644 --- a/services/web/scripts/sync-user-entitlements/sync-user-entitlements.mjs +++ b/services/web/scripts/sync-user-entitlements/sync-user-entitlements.mjs @@ -1,4 +1,4 @@ -import fs from 'fs' +import fs from 'node:fs' import minimist from 'minimist' import InstitutionsAPIModule from '../../app/src/Features/Institutions/InstitutionsAPI.js'