From 9df52d660feb722404be00a50f3c8a612bec1c15 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Aug 2021 14:42:53 +0200 Subject: Migrate client to eslint --- .../+video-edit/shared/i18n-primeng-calendar.service.ts | 2 +- .../+video-edit/shared/video-caption-add-modal.component.ts | 8 ++++---- client/src/app/+videos/+video-edit/shared/video-edit-utils.ts | 2 +- .../src/app/+videos/+video-edit/shared/video-edit.component.ts | 10 +++++----- .../+video-edit/video-add-components/drag-drop.directive.ts | 8 ++++---- .../video-add-components/video-go-live.component.ts | 2 +- .../video-add-components/video-import-torrent.component.html | 2 +- .../video-add-components/video-import-torrent.component.ts | 4 ++-- .../video-add-components/video-import-url.component.ts | 2 +- .../app/+videos/+video-edit/video-add-components/video-send.ts | 2 +- .../video-add-components/video-upload.component.html | 2 +- .../+video-edit/video-add-components/video-upload.component.ts | 5 ++++- client/src/app/+videos/+video-edit/video-update.component.ts | 5 ++--- client/src/app/+videos/+video-edit/video-update.resolver.ts | 6 +++--- 14 files changed, 31 insertions(+), 29 deletions(-) (limited to 'client/src/app/+videos/+video-edit') diff --git a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts b/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts index 34848b036..4b201ac74 100644 --- a/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts +++ b/client/src/app/+videos/+video-edit/shared/i18n-primeng-calendar.service.ts @@ -73,7 +73,7 @@ export class I18nPrimengCalendarService { } getTimezone () { - const gmt = new Date().toString().match(/([A-Z]+[\+-][0-9]+)/)[1] + const gmt = new Date().toString().match(/([A-Z]+[+-][0-9]+)/)[1] const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone return `${timezone} - ${gmt}` diff --git a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts index 875911b91..98d66ff00 100644 --- a/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-caption-add-modal.component.ts @@ -66,18 +66,18 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni isReplacingExistingCaption () { if (this.closingModal === true) return false - const languageId = this.form.value[ 'language' ] + const languageId = this.form.value['language'] - return languageId && this.existingCaptions.indexOf(languageId) !== -1 + return languageId && this.existingCaptions.includes(languageId) } async addCaption () { - const languageId = this.form.value[ 'language' ] + const languageId = this.form.value['language'] const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId) this.captionAdded.emit({ language: languageObject, - captionfile: this.form.value[ 'captionfile' ] + captionfile: this.form.value['captionfile'] }) this.hide() diff --git a/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts b/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts index 3a7dbed36..db1ef8d73 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts @@ -24,7 +24,7 @@ function hydrateFormFromVideo (formGroup: FormGroup, video: VideoEdit, thumbnail .then(response => response.blob()) .then(data => { formGroup.patchValue({ - [ obj.name ]: data + [obj.name]: data }) }) } diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 90a0e8f52..366c93a79 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts @@ -233,7 +233,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { async deleteCaption (caption: VideoCaptionEdit) { // Caption recovers his former state - if (caption.action && this.initialVideoCaptions.indexOf(caption.language.id) !== -1) { + if (caption.action && this.initialVideoCaptions.includes(caption.language.id)) { caption.action = undefined return } @@ -297,7 +297,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { private trackPrivacyChange () { // We will update the schedule input and the wait transcoding checkbox validators - this.form.controls[ 'privacy' ] + this.form.controls['privacy'] .valueChanges .pipe(map(res => parseInt(res.toString(), 10))) .subscribe( @@ -336,12 +336,12 @@ export class VideoEditComponent implements OnInit, OnDestroy { private trackChannelChange () { // We will update the "support" field depending on the channel - this.form.controls[ 'channelId' ] + this.form.controls['channelId'] .valueChanges .pipe(map(res => parseInt(res.toString(), 10))) .subscribe( newChannelId => { - const oldChannelId = parseInt(this.form.value[ 'channelId' ], 10) + const oldChannelId = parseInt(this.form.value['channelId'], 10) // Not initialized yet if (isNaN(newChannelId)) return @@ -350,7 +350,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { // Wait support field update setTimeout(() => { - const currentSupport = this.form.value[ 'support' ] + const currentSupport = this.form.value['support'] // First time we set the channel? if (isNaN(oldChannelId)) { diff --git a/client/src/app/+videos/+video-edit/video-add-components/drag-drop.directive.ts b/client/src/app/+videos/+video-edit/video-add-components/drag-drop.directive.ts index 7b1a38c62..7c35e6b84 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/drag-drop.directive.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/drag-drop.directive.ts @@ -1,26 +1,26 @@ import { Directive, Output, EventEmitter, HostBinding, HostListener } from '@angular/core' @Directive({ - selector: '[dragDrop]' + selector: '[myDragDrop]' }) export class DragDropDirective { @Output() fileDropped = new EventEmitter() @HostBinding('class.dragover') dragover = false - @HostListener('dragover', ['$event']) onDragOver (e: Event) { + @HostListener('dragover', [ '$event' ]) onDragOver (e: Event) { e.preventDefault() e.stopPropagation() this.dragover = true } - @HostListener('dragleave', ['$event']) public onDragLeave (e: Event) { + @HostListener('dragleave', [ '$event' ]) public onDragLeave (e: Event) { e.preventDefault() e.stopPropagation() this.dragover = false } - @HostListener('drop', ['$event']) public ondrop (e: DragEvent) { + @HostListener('drop', [ '$event' ]) public ondrop (e: DragEvent) { e.preventDefault() e.stopPropagation() this.dragover = false diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 30c79594d..1b9447e03 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -41,7 +41,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView private liveVideoService: LiveVideoService, private router: Router, private hooks: HooksService - ) { + ) { super() } diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.html index 20a7538db..0f1a94c84 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.html +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts index fef1f5d65..87e47683f 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts @@ -5,7 +5,7 @@ import { scrollToTop } from '@app/helpers' import { FormValidatorService } from '@app/shared/shared-forms' import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { PeerTubeProblemDocument, ServerErrorCode, VideoPrivacy, VideoUpdate } from '@shared/models' +import { PeerTubeProblemDocument, ServerErrorCode, VideoUpdate } from '@shared/models' import { hydrateFormFromVideo } from '../shared/video-edit-utils' import { VideoSend } from './video-send' @@ -43,7 +43,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af private router: Router, private videoImportService: VideoImportService, private hooks: HooksService - ) { + ) { super() } diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts index e1893b28f..3487c1adf 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts @@ -59,7 +59,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV } isTargetUrlValid () { - return this.targetUrl && this.targetUrl.match(/https?:\/\//) + return this.targetUrl?.match(/https?:\/\//) } importVideo () { diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts index ce8de049d..efa8c85a3 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts @@ -9,7 +9,7 @@ import { LoadingBarService } from '@ngx-loading-bar/core' import { HTMLServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' @Directive() -// tslint:disable-next-line: directive-class-suffix +// eslint-disable-next-line @angular-eslint/directive-class-suffix export abstract class VideoSend extends FormReactive implements OnInit { userVideoChannels: SelectChannelItem[] = [] videoPrivacies: VideoConstant[] = [] diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html index 14cd06fcf..db494a02f 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index b8cb4fa1e..dee2bb57a 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -128,7 +128,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy onUploadVideoOngoing (state: UploadState) { switch (state.status) { - case 'error': + case 'error': { const error = state.response?.error || 'Unknow error' this.handleUploadError({ @@ -143,6 +143,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy url: state.url }) break + } case 'cancelled': this.isUploadingVideo = false @@ -323,6 +324,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy const videoQuotaUsedBytes = bytePipes.transform(this.userVideoQuotaUsed, 0) const videoQuotaBytes = bytePipes.transform(videoQuota, 0) + // eslint-disable-next-line max-len const msg = $localize`Your video quota is exceeded with this video (video size: ${videoSizeBytes}, used: ${videoQuotaUsedBytes}, quota: ${videoQuotaBytes})` this.notifier.error(msg) @@ -341,6 +343,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy const videoSizeBytes = bytePipes.transform(videofile.size, 0) const quotaUsedDailyBytes = bytePipes.transform(this.userVideoQuotaUsedDaily, 0) const quotaDailyBytes = bytePipes.transform(videoQuotaDaily, 0) + // eslint-disable-next-line max-len const msg = $localize`Your daily video quota is exceeded with this video (video size: ${videoSizeBytes}, used: ${quotaUsedDailyBytes}, quota: ${quotaDailyBytes})` this.notifier.error(msg) diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index 95336dc75..9bef60133 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts @@ -38,7 +38,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { private loadingBar: LoadingBarService, private videoCaptionService: VideoCaptionService, private liveVideoService: LiveVideoService - ) { + ) { super() } @@ -119,8 +119,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { } update () { - if (this.checkForm() === false - || this.isUpdatingVideo === true) { + if (this.checkForm() === false || this.isUpdatingVideo === true) { return } diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts index 9172b78a8..91e76b7fe 100644 --- a/client/src/app/+videos/+video-edit/video-update.resolver.ts +++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts @@ -18,7 +18,7 @@ export class VideoUpdateResolver implements Resolve { } resolve (route: ActivatedRouteSnapshot) { - const uuid: string = route.params[ 'uuid' ] + const uuid: string = route.params['uuid'] return this.videoService.getVideo({ videoId: uuid }) .pipe( @@ -42,8 +42,8 @@ export class VideoUpdateResolver implements Resolve { ), video.isLive - ? this.liveVideoService.getVideoLive(video.id) - : of(undefined) + ? this.liveVideoService.getVideoLive(video.id) + : of(undefined) ] } } -- cgit v1.2.3