mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Move to eslint
This commit is contained in:
parent
a22046d166
commit
a15871560f
390 changed files with 3950 additions and 3615 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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})`)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue