From a15871560f80e07386c1dabb8370cd2664ecfd1f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 31 Jan 2020 16:56:52 +0100 Subject: Move to eslint --- server/helpers/custom-validators/activitypub/actor.ts | 4 +--- server/helpers/custom-validators/activitypub/video-comments.ts | 2 -- server/helpers/custom-validators/misc.ts | 4 ++-- server/helpers/custom-validators/plugins.ts | 6 +++--- server/helpers/custom-validators/user-notifications.ts | 3 ++- server/helpers/custom-validators/video-abuses.ts | 4 +--- server/helpers/custom-validators/video-captions.ts | 2 +- server/helpers/custom-validators/video-imports.ts | 2 +- server/helpers/custom-validators/video-playlists.ts | 6 ++---- server/helpers/custom-validators/videos.ts | 8 ++++---- 10 files changed, 17 insertions(+), 24 deletions(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index fa58e163f..fec67823d 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts @@ -6,7 +6,7 @@ import { isHostValid } from '../servers' import { peertubeTruncate } from '@server/helpers/core-utils' function isActorEndpointsObjectValid (endpointObject: any) { - if (endpointObject && endpointObject.sharedInbox) { + if (endpointObject?.sharedInbox) { return isActivityPubUrlValid(endpointObject.sharedInbox) } @@ -101,8 +101,6 @@ function normalizeActor (actor: any) { actor.summary = null } } - - return } function isValidActorHandle (handle: string) { diff --git a/server/helpers/custom-validators/activitypub/video-comments.ts b/server/helpers/custom-validators/activitypub/video-comments.ts index aa3c246b5..ea852c491 100644 --- a/server/helpers/custom-validators/activitypub/video-comments.ts +++ b/server/helpers/custom-validators/activitypub/video-comments.ts @@ -48,8 +48,6 @@ function normalizeComment (comment: any) { if (typeof comment.url === 'object') comment.url = comment.url.href || comment.url.url else comment.url = comment.id } - - return } function isCommentTypeValid (comment: any): boolean { diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 89149b3e0..cf32201c4 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -94,13 +94,13 @@ function isFileValid ( if (isArray(files)) return optional // Should have a file - const fileArray = files[ field ] + const fileArray = files[field] if (!fileArray || fileArray.length === 0) { return optional } // The file should exist - const file = fileArray[ 0 ] + const file = fileArray[0] if (!file || !file.originalname) return false // Check size diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts index 3af72547b..5a4531f72 100644 --- a/server/helpers/custom-validators/plugins.ts +++ b/server/helpers/custom-validators/plugins.ts @@ -14,7 +14,7 @@ function isPluginTypeValid (value: any) { function isPluginNameValid (value: string) { return exists(value) && validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && - validator.matches(value, /^[a-z\-]+$/) + validator.matches(value, /^[a-z-]+$/) } function isNpmPluginNameValid (value: string) { @@ -146,8 +146,8 @@ function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginT } function isLibraryCodeValid (library: any) { - return typeof library.register === 'function' - && typeof library.unregister === 'function' + return typeof library.register === 'function' && + typeof library.unregister === 'function' } export { diff --git a/server/helpers/custom-validators/user-notifications.ts b/server/helpers/custom-validators/user-notifications.ts index 5a4d10504..8a33b895b 100644 --- a/server/helpers/custom-validators/user-notifications.ts +++ b/server/helpers/custom-validators/user-notifications.ts @@ -9,7 +9,8 @@ function isUserNotificationTypeValid (value: any) { function isUserNotificationSettingValid (value: any) { return exists(value) && - validator.isInt('' + value) && ( + validator.isInt('' + value) && + ( value === UserNotificationSettingValue.NONE || value === UserNotificationSettingValue.WEB || value === UserNotificationSettingValue.EMAIL || diff --git a/server/helpers/custom-validators/video-abuses.ts b/server/helpers/custom-validators/video-abuses.ts index a9478c76a..5c7bc6fd9 100644 --- a/server/helpers/custom-validators/video-abuses.ts +++ b/server/helpers/custom-validators/video-abuses.ts @@ -1,8 +1,6 @@ -import { Response } from 'express' import validator from 'validator' import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants' import { exists } from './misc' -import { VideoAbuseModel } from '../../models/video/video-abuse' const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_ABUSES @@ -15,7 +13,7 @@ function isVideoAbuseModerationCommentValid (value: string) { } function isVideoAbuseStateValid (value: string) { - return exists(value) && VIDEO_ABUSE_STATES[ value ] !== undefined + return exists(value) && VIDEO_ABUSE_STATES[value] !== undefined } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts index d06eb3695..9abbce04a 100644 --- a/server/helpers/custom-validators/video-captions.ts +++ b/server/helpers/custom-validators/video-captions.ts @@ -2,7 +2,7 @@ import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initialize import { exists, isFileValid } from './misc' function isVideoCaptionLanguageValid (value: any) { - return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined + return exists(value) && VIDEO_LANGUAGES[value] !== undefined } const videoCaptionTypes = Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT) diff --git a/server/helpers/custom-validators/video-imports.ts b/server/helpers/custom-validators/video-imports.ts index ffad482b4..c571f5ddd 100644 --- a/server/helpers/custom-validators/video-imports.ts +++ b/server/helpers/custom-validators/video-imports.ts @@ -20,7 +20,7 @@ function isVideoImportTargetUrlValid (url: string) { } function isVideoImportStateValid (value: any) { - return exists(value) && VIDEO_IMPORT_STATES[ value ] !== undefined + return exists(value) && VIDEO_IMPORT_STATES[value] !== undefined } const videoTorrentImportTypes = Object.keys(MIMETYPES.TORRENT.MIMETYPE_EXT).map(m => `(${m})`) diff --git a/server/helpers/custom-validators/video-playlists.ts b/server/helpers/custom-validators/video-playlists.ts index 4bb8384ab..180018fc5 100644 --- a/server/helpers/custom-validators/video-playlists.ts +++ b/server/helpers/custom-validators/video-playlists.ts @@ -1,8 +1,6 @@ import { exists } from './misc' import validator from 'validator' import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers/constants' -import * as express from 'express' -import { VideoPlaylistModel } from '../../models/video/video-playlist' const PLAYLISTS_CONSTRAINT_FIELDS = CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS @@ -15,7 +13,7 @@ function isVideoPlaylistDescriptionValid (value: any) { } function isVideoPlaylistPrivacyValid (value: number) { - return validator.isInt(value + '') && VIDEO_PLAYLIST_PRIVACIES[ value ] !== undefined + return validator.isInt(value + '') && VIDEO_PLAYLIST_PRIVACIES[value] !== undefined } function isVideoPlaylistTimestampValid (value: any) { @@ -23,7 +21,7 @@ function isVideoPlaylistTimestampValid (value: any) { } function isVideoPlaylistTypeValid (value: any) { - return exists(value) && VIDEO_PLAYLIST_TYPES[ value ] !== undefined + return exists(value) && VIDEO_PLAYLIST_TYPES[value] !== undefined } // --------------------------------------------------------------------------- diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index a9e859e54..cfb430c63 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -20,15 +20,15 @@ function isVideoFilterValid (filter: VideoFilter) { } function isVideoCategoryValid (value: any) { - return value === null || VIDEO_CATEGORIES[ value ] !== undefined + return value === null || VIDEO_CATEGORIES[value] !== undefined } function isVideoStateValid (value: any) { - return exists(value) && VIDEO_STATES[ value ] !== undefined + return exists(value) && VIDEO_STATES[value] !== undefined } function isVideoLicenceValid (value: any) { - return value === null || VIDEO_LICENCES[ value ] !== undefined + return value === null || VIDEO_LICENCES[value] !== undefined } function isVideoLanguageValid (value: any) { @@ -98,7 +98,7 @@ function isVideoImage (files: { [ fieldname: string ]: Express.Multer.File[] } | } function isVideoPrivacyValid (value: number) { - return VIDEO_PRIVACIES[ value ] !== undefined + return VIDEO_PRIVACIES[value] !== undefined } function isScheduleVideoUpdatePrivacyValid (value: number) { -- cgit v1.2.3