mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Add prefer-node-protocol ESLint rule (#21532)
* Add `unicorn/prefer-node-protocol` * Fix `unicorn/prefer-node-protocol` ESLint errors * Run `npm run format:fix` * Add sandboxed-module sourceTransformers in mocha setups Fix `no such file or directory, open 'node:fs'` in `sandboxed-module` * Remove `node:` in the SandboxedModule requires * Fix new linting errors with `node:` GitOrigin-RevId: 68f6e31e2191fcff4cb8058dd0a6914c14f59926
This commit is contained in:
@@ -14,19 +14,19 @@
|
||||
*/
|
||||
const Client = require('./helpers/Client')
|
||||
const fetch = require('node-fetch')
|
||||
const { pipeline } = require('stream')
|
||||
const fs = require('fs')
|
||||
const ChildProcess = require('child_process')
|
||||
const { pipeline } = require('node:stream')
|
||||
const fs = require('node:fs')
|
||||
const ChildProcess = require('node:child_process')
|
||||
const ClsiApp = require('./helpers/ClsiApp')
|
||||
const logger = require('@overleaf/logger')
|
||||
const Path = require('path')
|
||||
const Path = require('node:path')
|
||||
const fixturePath = path => {
|
||||
if (path.slice(0, 3) === 'tmp') {
|
||||
return '/tmp/clsi_acceptance_tests' + path.slice(3)
|
||||
}
|
||||
return Path.join(__dirname, '../fixtures/', path)
|
||||
}
|
||||
const process = require('process')
|
||||
const process = require('node:process')
|
||||
console.log(
|
||||
process.pid,
|
||||
process.ppid,
|
||||
|
||||
@@ -13,7 +13,7 @@ const Client = require('./helpers/Client')
|
||||
const request = require('request')
|
||||
const { expect } = require('chai')
|
||||
const ClsiApp = require('./helpers/ClsiApp')
|
||||
const crypto = require('crypto')
|
||||
const crypto = require('node:crypto')
|
||||
|
||||
describe('Syncing', function () {
|
||||
before(function (done) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const express = require('express')
|
||||
const Path = require('path')
|
||||
const Path = require('node:path')
|
||||
const Client = require('./helpers/Client')
|
||||
const sinon = require('sinon')
|
||||
const ClsiApp = require('./helpers/ClsiApp')
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
const Client = require('./helpers/Client')
|
||||
const request = require('request')
|
||||
const { expect } = require('chai')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const path = require('node:path')
|
||||
const fs = require('node:fs')
|
||||
const ClsiApp = require('./helpers/ClsiApp')
|
||||
|
||||
describe('Syncing', function () {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
let Client
|
||||
const express = require('express')
|
||||
const request = require('request')
|
||||
const fs = require('fs')
|
||||
const fs = require('node:fs')
|
||||
const Settings = require('@overleaf/settings')
|
||||
|
||||
module.exports = Client = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const ContentCacheManager = require('../../app/js/ContentCacheManager')
|
||||
const fs = require('fs')
|
||||
const crypto = require('crypto')
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
const fs = require('node:fs')
|
||||
const crypto = require('node:crypto')
|
||||
const path = require('node:path')
|
||||
const os = require('node:os')
|
||||
const async = require('async')
|
||||
const _createHash = crypto.createHash
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
const request = require('request')
|
||||
const Settings = require('@overleaf/settings')
|
||||
const async = require('async')
|
||||
const fs = require('fs')
|
||||
const fs = require('node:fs')
|
||||
const _ = require('lodash')
|
||||
const concurentCompiles = 5
|
||||
const totalCompiles = 50
|
||||
|
||||
@@ -21,4 +21,9 @@ SandboxedModule.configure({
|
||||
},
|
||||
},
|
||||
globals: { Buffer, console, process, URL },
|
||||
sourceTransformers: {
|
||||
removeNodePrefix: function (source) {
|
||||
return source.replace(/require\(['"]node:/g, "require('")
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/CompileController'
|
||||
)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const Path = require('path')
|
||||
const Path = require('node:path')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const { expect } = require('chai')
|
||||
const sinon = require('sinon')
|
||||
|
||||
const MODULE_PATH = require('path').join(
|
||||
const MODULE_PATH = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/CompileManager'
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const Path = require('path')
|
||||
const fs = require('node:fs')
|
||||
const Path = require('node:path')
|
||||
const { expect } = require('chai')
|
||||
|
||||
const MODULE_PATH = '../../../app/js/ContentCacheManager'
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/ContentTypeMapper'
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/DockerLockManager'
|
||||
)
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/DockerRunner'
|
||||
)
|
||||
const Path = require('path')
|
||||
const Path = require('node:path')
|
||||
|
||||
describe('DockerRunner', function () {
|
||||
beforeEach(function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Path = require('path')
|
||||
const fsPromises = require('fs/promises')
|
||||
const Path = require('node:path')
|
||||
const fsPromises = require('node:fs/promises')
|
||||
const { expect } = require('chai')
|
||||
const mockFs = require('mock-fs')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
@@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
|
||||
const MODULE_PATH = require('path').join(
|
||||
const MODULE_PATH = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/LatexRunner'
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { expect } = require('chai')
|
||||
const sinon = require('sinon')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/LockManager'
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const MODULE_PATH = require('path').join(
|
||||
const MODULE_PATH = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/OutputController'
|
||||
)
|
||||
@@ -19,7 +19,7 @@ describe('OutputController', function () {
|
||||
'./OutputFileArchiveManager': {
|
||||
archiveFilesForBuild: this.archiveFilesForBuild,
|
||||
},
|
||||
'node:stream/promises': {
|
||||
'stream/promises': {
|
||||
pipeline: this.pipeline,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@ const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { assert, expect } = require('chai')
|
||||
|
||||
const MODULE_PATH = require('path').join(
|
||||
const MODULE_PATH = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/OutputFileArchiveManager'
|
||||
)
|
||||
@@ -50,7 +50,7 @@ describe('OutputFileArchiveManager', function () {
|
||||
'./OutputFileFinder': this.OutputFileFinder,
|
||||
'./OutputCacheManager': this.OutputCacheManger,
|
||||
archiver: this.archiver,
|
||||
'node:fs/promises': this.fs,
|
||||
'fs/promises': this.fs,
|
||||
'@overleaf/settings': {
|
||||
path: {
|
||||
outputDir: this.outputDir,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/OutputFileFinder'
|
||||
)
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
*/
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/OutputFileOptimiser'
|
||||
)
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
const { expect } = require('chai')
|
||||
const { EventEmitter } = require('events')
|
||||
const { EventEmitter } = require('node:events')
|
||||
|
||||
describe('OutputFileOptimiser', function () {
|
||||
beforeEach(function () {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const assert = require('chai').assert
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/ProjectPersistenceManager'
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/RequestParser'
|
||||
)
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/ResourceStateManager'
|
||||
)
|
||||
const Path = require('path')
|
||||
const Path = require('node:path')
|
||||
const Errors = require('../../../app/js/Errors')
|
||||
|
||||
describe('ResourceStateManager', function () {
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/ResourceWriter'
|
||||
)
|
||||
const path = require('path')
|
||||
const path = require('node:path')
|
||||
|
||||
describe('ResourceWriter', function () {
|
||||
beforeEach(function () {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const assert = require('assert')
|
||||
const path = require('path')
|
||||
const assert = require('node:assert')
|
||||
const path = require('node:path')
|
||||
const sinon = require('sinon')
|
||||
const modulePath = path.join(
|
||||
__dirname,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const Path = require('path')
|
||||
const Path = require('node:path')
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const { expect } = require('chai')
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const modulePath = require('path').join(
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/TikzManager'
|
||||
)
|
||||
|
||||
@@ -13,7 +13,10 @@
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = require('path').join(__dirname, '../../../app/js/UrlCache')
|
||||
const modulePath = require('node:path').join(
|
||||
__dirname,
|
||||
'../../../app/js/UrlCache'
|
||||
)
|
||||
|
||||
describe('UrlCache', function () {
|
||||
beforeEach(function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const Path = require('path')
|
||||
const fs = require('node:fs')
|
||||
const Path = require('node:path')
|
||||
const { expect } = require('chai')
|
||||
const { parseXrefTable } = require('../../../app/js/XrefParser')
|
||||
const { NoXrefTableError } = require('../../../app/js/Errors')
|
||||
|
||||
Reference in New Issue
Block a user