From a15871560f80e07386c1dabb8370cd2664ecfd1f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 31 Jan 2020 16:56:52 +0100 Subject: Move to eslint --- shared/extra-utils/server/clients.ts | 4 +- shared/extra-utils/server/contact-form.ts | 10 ++--- shared/extra-utils/server/follows.ts | 26 +++++------ shared/extra-utils/server/jobs.ts | 22 +++++----- shared/extra-utils/server/plugins.ts | 72 +++++++++++++++---------------- shared/extra-utils/server/redundancy.ts | 18 ++++---- shared/extra-utils/server/servers.ts | 27 ++++++------ 7 files changed, 89 insertions(+), 90 deletions(-) (limited to 'shared/extra-utils/server') diff --git a/shared/extra-utils/server/clients.ts b/shared/extra-utils/server/clients.ts index 273aac747..dc631e823 100644 --- a/shared/extra-utils/server/clients.ts +++ b/shared/extra-utils/server/clients.ts @@ -1,12 +1,12 @@ import * as request from 'supertest' -import * as urlUtil from 'url' +import { URL } from 'url' function getClient (url: string) { const path = '/api/v1/oauth-clients/local' return request(url) .get(path) - .set('Host', urlUtil.parse(url).host) + .set('Host', new URL(url).host) .set('Accept', 'application/json') .expect(200) .expect('Content-Type', /json/) diff --git a/shared/extra-utils/server/contact-form.ts b/shared/extra-utils/server/contact-form.ts index e002e03dd..d50f83241 100644 --- a/shared/extra-utils/server/contact-form.ts +++ b/shared/extra-utils/server/contact-form.ts @@ -2,11 +2,11 @@ import * as request from 'supertest' import { ContactForm } from '../../models/server' function sendContactForm (options: { - url: string, - fromEmail: string, - fromName: string, - subject: string, - body: string, + url: string + fromEmail: string + fromName: string + subject: string + body: string expectedStatus?: number }) { const path = '/api/v1/server/contact' diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts index 3f7729c20..006d59199 100644 --- a/shared/extra-utils/server/follows.ts +++ b/shared/extra-utils/server/follows.ts @@ -5,12 +5,12 @@ import { makePostBodyRequest } from '../requests/requests' import { ActivityPubActorType, FollowState } from '@shared/models' function getFollowersListPaginationAndSort (options: { - url: string, - start: number, - count: number, - sort: string, - search?: string, - actorType?: ActivityPubActorType, + url: string + start: number + count: number + sort: string + search?: string + actorType?: ActivityPubActorType state?: FollowState }) { const { url, start, count, sort, search, state, actorType } = options @@ -56,12 +56,12 @@ function rejectFollower (url: string, token: string, follower: string, statusCod } function getFollowingListPaginationAndSort (options: { - url: string, - start: number, - count: number, - sort: string, - search?: string, - actorType?: ActivityPubActorType, + url: string + start: number + count: number + sort: string + search?: string + actorType?: ActivityPubActorType state?: FollowState }) { const { url, start, count, sort, search, state, actorType } = options @@ -92,7 +92,7 @@ function follow (follower: string, following: string[], accessToken: string, exp .post(path) .set('Accept', 'application/json') .set('Authorization', 'Bearer ' + accessToken) - .send({ 'hosts': followingHosts }) + .send({ hosts: followingHosts }) .expect(expectedStatus) } diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index 56fe5fa2a..d984b3d1e 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts @@ -8,20 +8,20 @@ function getJobsList (url: string, accessToken: string, state: JobState) { const path = '/api/v1/jobs/' + state return request(url) - .get(path) - .set('Accept', 'application/json') - .set('Authorization', 'Bearer ' + accessToken) - .expect(200) - .expect('Content-Type', /json/) + .get(path) + .set('Accept', 'application/json') + .set('Authorization', 'Bearer ' + accessToken) + .expect(200) + .expect('Content-Type', /json/) } function getJobsListPaginationAndSort (options: { - url: string, - accessToken: string, - state: JobState, - start: number, - count: number, - sort: string, + url: string + accessToken: string + state: JobState + start: number + count: number + sort: string jobType?: JobType }) { const { url, accessToken, state, start, count, sort, jobType } = options diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts index 5c0d1e511..2d02d823d 100644 --- a/shared/extra-utils/server/plugins.ts +++ b/shared/extra-utils/server/plugins.ts @@ -7,13 +7,13 @@ import { root } from '../miscs/miscs' import { join } from 'path' function listPlugins (parameters: { - url: string, - accessToken: string, - start?: number, - count?: number, - sort?: string, - pluginType?: PluginType, - uninstalled?: boolean, + url: string + accessToken: string + start?: number + count?: number + sort?: string + pluginType?: PluginType + uninstalled?: boolean expectedStatus?: number }) { const { url, accessToken, start, count, sort, pluginType, uninstalled, expectedStatus = 200 } = parameters @@ -35,13 +35,13 @@ function listPlugins (parameters: { } function listAvailablePlugins (parameters: { - url: string, - accessToken: string, - start?: number, - count?: number, - sort?: string, - pluginType?: PluginType, - currentPeerTubeEngine?: string, + url: string + accessToken: string + start?: number + count?: number + sort?: string + pluginType?: PluginType + currentPeerTubeEngine?: string search?: string expectedStatus?: number }) { @@ -67,9 +67,9 @@ function listAvailablePlugins (parameters: { } function getPlugin (parameters: { - url: string, - accessToken: string, - npmName: string, + url: string + accessToken: string + npmName: string expectedStatus?: number }) { const { url, accessToken, npmName, expectedStatus = 200 } = parameters @@ -84,10 +84,10 @@ function getPlugin (parameters: { } function updatePluginSettings (parameters: { - url: string, - accessToken: string, - npmName: string, - settings: any, + url: string + accessToken: string + npmName: string + settings: any expectedStatus?: number }) { const { url, accessToken, npmName, settings, expectedStatus = 204 } = parameters @@ -103,9 +103,9 @@ function updatePluginSettings (parameters: { } function getPluginRegisteredSettings (parameters: { - url: string, - accessToken: string, - npmName: string, + url: string + accessToken: string + npmName: string expectedStatus?: number }) { const { url, accessToken, npmName, expectedStatus = 200 } = parameters @@ -120,8 +120,8 @@ function getPluginRegisteredSettings (parameters: { } function getPublicSettings (parameters: { - url: string, - npmName: string, + url: string + npmName: string expectedStatus?: number }) { const { url, npmName, expectedStatus = 200 } = parameters @@ -135,8 +135,8 @@ function getPublicSettings (parameters: { } function getPluginTranslations (parameters: { - url: string, - locale: string, + url: string + locale: string expectedStatus?: number }) { const { url, locale, expectedStatus = 200 } = parameters @@ -150,9 +150,9 @@ function getPluginTranslations (parameters: { } function installPlugin (parameters: { - url: string, - accessToken: string, - path?: string, + url: string + accessToken: string + path?: string npmName?: string expectedStatus?: number }) { @@ -169,9 +169,9 @@ function installPlugin (parameters: { } function updatePlugin (parameters: { - url: string, - accessToken: string, - path?: string, + url: string + accessToken: string + path?: string npmName?: string expectedStatus?: number }) { @@ -188,8 +188,8 @@ function updatePlugin (parameters: { } function uninstallPlugin (parameters: { - url: string, - accessToken: string, + url: string + accessToken: string npmName: string expectedStatus?: number }) { diff --git a/shared/extra-utils/server/redundancy.ts b/shared/extra-utils/server/redundancy.ts index 7b488e23e..08467e4c0 100644 --- a/shared/extra-utils/server/redundancy.ts +++ b/shared/extra-utils/server/redundancy.ts @@ -15,11 +15,11 @@ function updateRedundancy (url: string, accessToken: string, host: string, redun function listVideoRedundancies (options: { url: string - accessToken: string, - target: VideoRedundanciesTarget, - start?: number, - count?: number, - sort?: string, + accessToken: string + target: VideoRedundanciesTarget + start?: number + count?: number + sort?: string statusCodeExpected?: number }) { const path = '/api/v1/server/redundancy/videos' @@ -41,8 +41,8 @@ function listVideoRedundancies (options: { } function addVideoRedundancy (options: { - url: string, - accessToken: string, + url: string + accessToken: string videoId: number }) { const path = '/api/v1/server/redundancy/videos' @@ -58,8 +58,8 @@ function addVideoRedundancy (options: { } function removeVideoRedundancy (options: { - url: string, - accessToken: string, + url: string + accessToken: string redundancyId: number }) { const { url, accessToken, redundancyId } = options diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index a0720d778..a0f0ce9c9 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -1,16 +1,15 @@ -/* tslint:disable:no-unused-expression */ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ import { ChildProcess, exec, fork } from 'child_process' import { join } from 'path' import { root, wait } from '../miscs/miscs' import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' -import { existsSync } from 'fs' import { expect } from 'chai' import { VideoChannel } from '../../models/videos' import { randomInt } from '../../core-utils/miscs/miscs' interface ServerInfo { - app: ChildProcess, + app: ChildProcess url: string host: string @@ -20,13 +19,13 @@ interface ServerInfo { serverNumber: number client: { - id: string, + id: string secret: string } user: { - username: string, - password: string, + username: string + password: string email?: string } @@ -57,7 +56,7 @@ function parallelTests () { } function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) { - let apps = [] + const apps = [] let i = 0 return new Promise(res => { @@ -203,20 +202,20 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] // Capture things if we want to for (const key of Object.keys(regexps)) { - const regexp = regexps[ key ] + const regexp = regexps[key] const matches = data.toString().match(regexp) if (matches !== null) { - if (key === 'client_id') server.client.id = matches[ 1 ] - else if (key === 'client_secret') server.client.secret = matches[ 1 ] - else if (key === 'user_username') server.user.username = matches[ 1 ] - else if (key === 'user_password') server.user.password = matches[ 1 ] + if (key === 'client_id') server.client.id = matches[1] + else if (key === 'client_secret') server.client.secret = matches[1] + else if (key === 'user_username') server.user.username = matches[1] + else if (key === 'user_password') server.user.password = matches[1] } } // Check if all required sentences are here for (const key of Object.keys(serverRunString)) { - if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true - if (serverRunString[ key ] === false) dontContinue = true + if (data.toString().indexOf(key) !== -1) serverRunString[key] = true + if (serverRunString[key] === false) dontContinue = true } // If no, there is maybe one thing not already initialized (client/user credentials generation...) -- cgit v1.2.3