mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #6120 from overleaf/jpa-same-linting-packages
[misc] move the linting setup to the root of the monorepo GitOrigin-RevId: 1633e2a58598add0b727738cd3bfba0ab7bae781
This commit is contained in:
@@ -6,7 +6,7 @@ module.exports = class AbstractPersistor {
|
||||
method: 'sendFile',
|
||||
location,
|
||||
target,
|
||||
source
|
||||
source,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = class AbstractPersistor {
|
||||
method: 'sendStream',
|
||||
location,
|
||||
target,
|
||||
opts
|
||||
opts,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = class AbstractPersistor {
|
||||
method: 'getObjectStream',
|
||||
location,
|
||||
name,
|
||||
opts
|
||||
opts,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = class AbstractPersistor {
|
||||
throw new NotImplementedError('method not implemented in persistor', {
|
||||
method: 'getRedirectUrl',
|
||||
location,
|
||||
name
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ module.exports = class AbstractPersistor {
|
||||
throw new NotImplementedError('method not implemented in persistor', {
|
||||
method: 'getObjectSize',
|
||||
location,
|
||||
name
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ module.exports = class AbstractPersistor {
|
||||
throw new NotImplementedError('method not implemented in persistor', {
|
||||
method: 'getObjectMd5Hash',
|
||||
location,
|
||||
name
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ module.exports = class AbstractPersistor {
|
||||
method: 'copyObject',
|
||||
location,
|
||||
fromName,
|
||||
toName
|
||||
toName,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ module.exports = class AbstractPersistor {
|
||||
throw new NotImplementedError('method not implemented in persistor', {
|
||||
method: 'deleteObject',
|
||||
location,
|
||||
name
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ module.exports = class AbstractPersistor {
|
||||
throw new NotImplementedError('method not implemented in persistor', {
|
||||
method: 'deleteDirectory',
|
||||
location,
|
||||
name
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ module.exports = class AbstractPersistor {
|
||||
throw new NotImplementedError('method not implemented in persistor', {
|
||||
method: 'checkIfObjectExists',
|
||||
location,
|
||||
name
|
||||
name,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ module.exports = class AbstractPersistor {
|
||||
throw new NotImplementedError('method not implemented in persistor', {
|
||||
method: 'directorySize',
|
||||
location,
|
||||
name
|
||||
name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ module.exports = {
|
||||
WriteError,
|
||||
ReadError,
|
||||
SettingsError,
|
||||
NotImplementedError
|
||||
NotImplementedError,
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ const fsOpen = promisify(fs.open)
|
||||
const fsStat = promisify(fs.stat)
|
||||
const fsGlob = promisify(glob)
|
||||
|
||||
const filterName = (key) => key.replace(/\//g, '_')
|
||||
const filterName = key => key.replace(/\//g, '_')
|
||||
|
||||
module.exports = class FSPersistor extends AbstractPersistor {
|
||||
constructor(settings) {
|
||||
@@ -59,7 +59,7 @@ module.exports = class FSPersistor extends AbstractPersistor {
|
||||
sourceMd5,
|
||||
destMd5,
|
||||
location,
|
||||
target
|
||||
target,
|
||||
})
|
||||
}
|
||||
} finally {
|
||||
@@ -165,7 +165,7 @@ module.exports = class FSPersistor extends AbstractPersistor {
|
||||
await Promise.all(
|
||||
(
|
||||
await fsGlob(`${location}/${filteredName}_*`)
|
||||
).map((file) => fsUnlink(file))
|
||||
).map(file => fsUnlink(file))
|
||||
)
|
||||
} catch (err) {
|
||||
throw PersistorHelper.wrapError(
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
||||
// https://github.com/googleapis/nodejs-storage/issues/898
|
||||
if (this.settings.endpoint && this.settings.endpoint.apiEndpoint) {
|
||||
this.storage.interceptors.push({
|
||||
request: (reqOpts) => {
|
||||
request: reqOpts => {
|
||||
const url = new URL(reqOpts.uri)
|
||||
url.host = this.settings.endpoint.apiEndpoint
|
||||
if (this.settings.endpoint.apiScheme) {
|
||||
@@ -30,7 +30,7 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
||||
}
|
||||
reqOpts.uri = url.toString()
|
||||
return reqOpts
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
||||
// egress from us to gcs
|
||||
const observeOptions = {
|
||||
metric: 'gcs.egress',
|
||||
Metrics: this.settings.Metrics
|
||||
Metrics: this.settings.Metrics,
|
||||
}
|
||||
|
||||
let sourceMd5 = opts.sourceMd5
|
||||
@@ -57,7 +57,7 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
||||
|
||||
const writeOptions = {
|
||||
// disabling of resumable uploads is recommended by Google:
|
||||
resumable: false
|
||||
resumable: false,
|
||||
}
|
||||
|
||||
if (sourceMd5) {
|
||||
@@ -107,7 +107,7 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
||||
// ingress to us from gcs
|
||||
const observer = new PersistorHelper.ObserverStream({
|
||||
metric: 'gcs.ingress',
|
||||
Metrics: this.settings.Metrics
|
||||
Metrics: this.settings.Metrics,
|
||||
})
|
||||
|
||||
try {
|
||||
@@ -139,7 +139,7 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
||||
.file(key)
|
||||
.getSignedUrl({
|
||||
action: 'read',
|
||||
expires: Date.now() + this.settings.signedUrlExpiryInMs
|
||||
expires: Date.now() + this.settings.signedUrlExpiryInMs,
|
||||
})
|
||||
return url
|
||||
} catch (err) {
|
||||
@@ -228,7 +228,7 @@ module.exports = class GcsPersistor extends AbstractPersistor {
|
||||
await asyncPool(
|
||||
this.settings.deleteConcurrency,
|
||||
files,
|
||||
async (file) => {
|
||||
async file => {
|
||||
await this.deleteObject(bucketName, file.name)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -81,13 +81,13 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
// start listening on both straight away so that we don't consume bytes
|
||||
// in one place before the other
|
||||
const returnStream = new Stream.PassThrough()
|
||||
pipeline(fallbackStream, returnStream).catch((error) => {
|
||||
pipeline(fallbackStream, returnStream).catch(error => {
|
||||
Logger.warn({ error }, 'failed to copy object from fallback')
|
||||
})
|
||||
|
||||
if (shouldCopy) {
|
||||
const copyStream = new Stream.PassThrough()
|
||||
pipeline(fallbackStream, copyStream).catch((error) => {
|
||||
pipeline(fallbackStream, copyStream).catch(error => {
|
||||
Logger.warn({ error }, 'failed to copy object from fallback')
|
||||
})
|
||||
|
||||
@@ -97,7 +97,7 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
bucket,
|
||||
key,
|
||||
key
|
||||
).catch((error) => {
|
||||
).catch(error => {
|
||||
Logger.warn({ error }, 'failed to copy file from fallback')
|
||||
})
|
||||
}
|
||||
@@ -120,13 +120,13 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
)
|
||||
|
||||
const copyStream = new Stream.PassThrough()
|
||||
pipeline(fallbackStream, copyStream).catch((error) => {
|
||||
pipeline(fallbackStream, copyStream).catch(error => {
|
||||
Logger.warn({ error }, 'failed to copy object from fallback')
|
||||
})
|
||||
|
||||
if (this.settings.copyOnMiss) {
|
||||
const missStream = new Stream.PassThrough()
|
||||
pipeline(fallbackStream, missStream).catch((error) => {
|
||||
pipeline(fallbackStream, missStream).catch(error => {
|
||||
Logger.warn({ error }, 'failed to copy object from fallback')
|
||||
})
|
||||
|
||||
@@ -173,7 +173,7 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
}
|
||||
|
||||
await this.primaryPersistor.sendStream(destBucket, destKey, stream, {
|
||||
sourceMd5
|
||||
sourceMd5,
|
||||
})
|
||||
} catch (err) {
|
||||
const error = new WriteError(
|
||||
@@ -182,7 +182,7 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
sourceBucket,
|
||||
destBucket,
|
||||
sourceKey,
|
||||
destKey
|
||||
destKey,
|
||||
},
|
||||
err
|
||||
)
|
||||
@@ -197,7 +197,7 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
'unable to clean up destination copy artifact',
|
||||
{
|
||||
destBucket,
|
||||
destKey
|
||||
destKey,
|
||||
},
|
||||
err
|
||||
)
|
||||
@@ -215,7 +215,7 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
|
||||
await Promise.all([
|
||||
this.primaryPersistor[methodName](bucket, ...moreArgs),
|
||||
this.fallbackPersistor[methodName](fallbackBucket, ...moreArgs)
|
||||
this.fallbackPersistor[methodName](fallbackBucket, ...moreArgs),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ module.exports = class MigrationPersistor extends AbstractPersistor {
|
||||
bucket,
|
||||
key,
|
||||
key
|
||||
).catch((err) => {
|
||||
).catch(err => {
|
||||
Logger.warn({ err }, 'failed to copy file from fallback')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ function getPersistor(backend, settings) {
|
||||
case 'fs':
|
||||
return new FSPersistor({
|
||||
paths: settings.paths,
|
||||
Metrics: settings.Metrics
|
||||
Metrics: settings.Metrics,
|
||||
})
|
||||
case 'gcs':
|
||||
return new GcsPersistor(
|
||||
@@ -30,7 +30,7 @@ module.exports = function create(settings) {
|
||||
Logger.info(
|
||||
{
|
||||
backend: settings.backend,
|
||||
fallback: settings.fallback && settings.fallback.backend
|
||||
fallback: settings.fallback && settings.fallback.backend,
|
||||
},
|
||||
'Loading backend'
|
||||
)
|
||||
|
||||
@@ -52,7 +52,7 @@ module.exports = {
|
||||
getReadyPipeline,
|
||||
wrapError,
|
||||
hexToBase64,
|
||||
base64ToHex
|
||||
base64ToHex,
|
||||
}
|
||||
|
||||
// returns a promise which resolves with the md5 hash of the stream
|
||||
@@ -84,7 +84,7 @@ async function verifyMd5(persistor, bucket, key, sourceMd5, destMd5 = null) {
|
||||
sourceMd5,
|
||||
destMd5,
|
||||
bucket,
|
||||
key
|
||||
key,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -133,8 +133,8 @@ function getReadyPipeline(...streams) {
|
||||
for (const stream of streams) {
|
||||
// when a stream receives a pipe, set up the drain handler to drain the
|
||||
// connection if an error occurs or the stream is closed
|
||||
stream.on('pipe', (previousStream) => {
|
||||
stream.on('error', (x) => {
|
||||
stream.on('pipe', previousStream => {
|
||||
stream.on('error', x => {
|
||||
drainPreviousStream(previousStream)
|
||||
})
|
||||
stream.on('close', () => {
|
||||
|
||||
@@ -17,7 +17,7 @@ const {
|
||||
WriteError,
|
||||
ReadError,
|
||||
NotFoundError,
|
||||
SettingsError
|
||||
SettingsError,
|
||||
} = require('./Errors')
|
||||
|
||||
module.exports = class S3Persistor extends AbstractPersistor {
|
||||
@@ -36,7 +36,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
// egress from us to S3
|
||||
const observeOptions = {
|
||||
metric: 's3.egress',
|
||||
Metrics: this.settings.Metrics
|
||||
Metrics: this.settings.Metrics,
|
||||
}
|
||||
|
||||
const observer = new PersistorHelper.ObserverStream(observeOptions)
|
||||
@@ -47,7 +47,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
const uploadOptions = {
|
||||
Bucket: bucketName,
|
||||
Key: key,
|
||||
Body: observer
|
||||
Body: observer,
|
||||
}
|
||||
|
||||
if (opts.contentType) {
|
||||
@@ -84,7 +84,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
|
||||
const params = {
|
||||
Bucket: bucketName,
|
||||
Key: key
|
||||
Key: key,
|
||||
}
|
||||
if (opts.start != null && opts.end != null) {
|
||||
params.Range = `bytes=${opts.start}-${opts.end}`
|
||||
@@ -97,7 +97,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
// ingress from S3 to us
|
||||
const observer = new PersistorHelper.ObserverStream({
|
||||
metric: 's3.ingress',
|
||||
Metrics: this.settings.Metrics
|
||||
Metrics: this.settings.Metrics,
|
||||
})
|
||||
|
||||
try {
|
||||
@@ -122,7 +122,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
).getSignedUrlPromise('getObject', {
|
||||
Bucket: bucketName,
|
||||
Key: key,
|
||||
Expires: expiresSeconds
|
||||
Expires: expiresSeconds,
|
||||
})
|
||||
return url
|
||||
} catch (err) {
|
||||
@@ -155,7 +155,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
)
|
||||
}
|
||||
|
||||
const objects = response.Contents.map((item) => ({ Key: item.Key }))
|
||||
const objects = response.Contents.map(item => ({ Key: item.Key }))
|
||||
if (objects.length) {
|
||||
try {
|
||||
await this._getClientForBucket(bucketName)
|
||||
@@ -163,8 +163,8 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
Bucket: bucketName,
|
||||
Delete: {
|
||||
Objects: objects,
|
||||
Quiet: true
|
||||
}
|
||||
Quiet: true,
|
||||
},
|
||||
})
|
||||
.promise()
|
||||
} catch (err) {
|
||||
@@ -248,7 +248,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
const params = {
|
||||
Bucket: bucketName,
|
||||
Key: destKey,
|
||||
CopySource: `${bucketName}/${sourceKey}`
|
||||
CopySource: `${bucketName}/${sourceKey}`,
|
||||
}
|
||||
try {
|
||||
await this._getClientForBucket(bucketName).copyObject(params).promise()
|
||||
@@ -283,7 +283,7 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
try {
|
||||
const options = {
|
||||
Bucket: bucketName,
|
||||
Prefix: key
|
||||
Prefix: key,
|
||||
}
|
||||
if (continuationToken) {
|
||||
options.ContinuationToken = continuationToken
|
||||
@@ -341,12 +341,12 @@ module.exports = class S3Persistor extends AbstractPersistor {
|
||||
if (bucketCredentials) {
|
||||
options.credentials = {
|
||||
accessKeyId: bucketCredentials.auth_key,
|
||||
secretAccessKey: bucketCredentials.auth_secret
|
||||
secretAccessKey: bucketCredentials.auth_secret,
|
||||
}
|
||||
} else {
|
||||
options.credentials = {
|
||||
accessKeyId: this.settings.key,
|
||||
secretAccessKey: this.settings.secret
|
||||
secretAccessKey: this.settings.secret,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user