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-watch/player-styles.component.ts | 2 +- .../shared/comment/video-comment-add.component.ts | 6 ++-- .../shared/comment/video-comment.component.html | 2 +- .../shared/comment/video-comment.component.ts | 2 +- .../shared/comment/video-comments.component.ts | 8 +++-- .../shared/information/video-alert.component.ts | 2 +- .../metadata/video-description.component.html | 2 +- .../playlist/video-watch-playlist.component.ts | 10 +++--- .../recommended-videos.component.html | 2 +- .../recommended-videos.component.ts | 2 +- .../timestamp-route-transformer.directive.ts | 8 ++--- .../+videos/+video-watch/video-watch.component.ts | 39 +++++++++++----------- 12 files changed, 45 insertions(+), 40 deletions(-) (limited to 'client/src/app/+videos/+video-watch') diff --git a/client/src/app/+videos/+video-watch/player-styles.component.ts b/client/src/app/+videos/+video-watch/player-styles.component.ts index 9b1672a8c..448a0ee96 100644 --- a/client/src/app/+videos/+video-watch/player-styles.component.ts +++ b/client/src/app/+videos/+video-watch/player-styles.component.ts @@ -8,7 +8,7 @@ import { Component, ViewEncapsulation } from '@angular/core' selector: 'my-player-styles', template: '', styleUrls: [ './player-styles.component.scss' ], - // tslint:disable:use-component-view-encapsulation + /* eslint-disable @angular-eslint/use-component-view-encapsulation */ encapsulation: ViewEncapsulation.None }) export class PlayerStylesComponent { diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts index ac65f7260..71fb127f6 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment-add.component.ts @@ -25,7 +25,7 @@ import { VideoCommentCreate } from '@shared/models' @Component({ selector: 'my-video-comment-add', templateUrl: './video-comment-add.component.html', - styleUrls: ['./video-comment-add.component.scss'] + styleUrls: [ './video-comment-add.component.scss' ] }) export class VideoCommentAddComponent extends FormReactive implements OnChanges, OnInit { @Input() user: User @@ -64,7 +64,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, for (const emojiMarkupName in emojiMarkupObjectList) { if (emojiMarkupName) { const emoji = emojiMarkupObjectList[emojiMarkupName] - emojiMarkupArrayList.push([emoji, emojiMarkupName]) + emojiMarkupArrayList.push([ emoji, emojiMarkupName ]) } } @@ -91,7 +91,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges, // Not initialized yet if (!this.form) return - if (changes.textValue && changes.textValue.currentValue && changes.textValue.currentValue !== changes.textValue.previousValue) { + if (changes.textValue?.currentValue && changes.textValue.currentValue !== changes.textValue.previousValue) { this.patchTextValue(changes.textValue.currentValue, true) } } diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.html b/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.html index d8b944b35..d0e9bcd29 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.html +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.html @@ -29,7 +29,7 @@ class="comment-html" [innerHTML]="sanitizedCommentHTML" (timestampClicked)="handleTimestampClicked($event)" - timestampRouteTransformer + myTimestampRouteTransformer >
diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts index f858f4750..5bbcffe82 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comment.component.ts @@ -10,7 +10,7 @@ import { User, UserRight } from '@shared/models' @Component({ selector: 'my-video-comment', templateUrl: './video-comment.component.html', - styleUrls: ['./video-comment.component.scss'] + styleUrls: [ './video-comment.component.scss' ] }) export class VideoCommentComponent implements OnInit, OnChanges { @ViewChild('commentReportModal') commentReportModal: CommentReportComponent diff --git a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts b/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts index 72866b874..17e0af3bc 100644 --- a/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts +++ b/client/src/app/+videos/+video-watch/shared/comment/video-comments.component.ts @@ -9,7 +9,7 @@ import { VideoComment, VideoCommentService, VideoCommentThreadTree } from '@app/ @Component({ selector: 'my-video-comments', templateUrl: './video-comments.component.html', - styleUrls: ['./video-comments.component.scss'] + styleUrls: [ './video-comments.component.scss' ] }) export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { @ViewChild('commentHighlightBlock') commentHighlightBlock: ElementRef @@ -200,7 +200,11 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { } async onWantedToRedraft (commentToRedraft: VideoComment) { - const confirm = await this.onWantedToDelete(commentToRedraft, $localize`Delete and re-draft`, $localize`Do you really want to delete and re-draft this comment?`) + const confirm = await this.onWantedToDelete( + commentToRedraft, + $localize`Delete and re-draft`, + $localize`Do you really want to delete and re-draft this comment?` + ) if (confirm) { this.inReplyToCommentId = commentToRedraft.inReplyToCommentId diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts index 0072492ac..257d463b4 100644 --- a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts +++ b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts @@ -23,7 +23,7 @@ export class VideoAlertComponent { } hasVideoScheduledPublication () { - return this.video && this.video.scheduledUpdate !== undefined + return this.video?.scheduledUpdate !== undefined } isWaitingForLive () { diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html index 57f682899..2cfaad8f6 100644 --- a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html +++ b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html @@ -3,7 +3,7 @@ class="video-info-description-html" [innerHTML]="videoHTMLDescription" (timestampClicked)="onTimestampClicked($event)" - timestampRouteTransformer + myTimestampRouteTransformer >
diff --git a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts index f0f7966b1..78b3af4a7 100644 --- a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts +++ b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts @@ -39,7 +39,7 @@ export class VideoWatchPlaylistComponent { private notifier: Notifier, private videoPlaylist: VideoPlaylistService, private localStorageService: LocalStorageService, - private sessionStorageService: SessionStorageService, + private sessionStorage: SessionStorageService, private router: Router ) { // defaults to true @@ -50,7 +50,7 @@ export class VideoWatchPlaylistComponent { this.setAutoPlayNextVideoPlaylistSwitchText() // defaults to false - this.loopPlaylist = this.sessionStorageService.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true' + this.loopPlaylist = this.sessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true' this.setLoopPlaylistSwitchText() } @@ -145,7 +145,7 @@ export class VideoWatchPlaylistComponent { const start = previous.startTimestamp const stop = previous.stopTimestamp - this.router.navigate([],{ queryParams: { playlistPosition: previous.position, start, stop } }) + this.router.navigate([], { queryParams: { playlistPosition: previous.position, start, stop } }) } findPlaylistVideo (position: number, type: 'previous' | 'next'): VideoPlaylistElement { @@ -163,7 +163,7 @@ export class VideoWatchPlaylistComponent { } const found = this.playlistElements.find(e => e.position === position) - if (found && found.video) return found + if (found?.video) return found const newPosition = type === 'previous' ? position - 1 @@ -178,7 +178,7 @@ export class VideoWatchPlaylistComponent { const start = next.startTimestamp const stop = next.stopTimestamp - this.router.navigate([],{ queryParams: { playlistPosition: next.position, start, stop } }) + this.router.navigate([], { queryParams: { playlistPosition: next.position, start, stop } }) } switchAutoPlayNextVideoPlaylist () { diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html index e1040fead..bbfcab2ae 100644 --- a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html +++ b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html @@ -20,7 +20,7 @@ > -
+
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts index 7f3703c08..dfc296d15 100644 --- a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts +++ b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts @@ -51,7 +51,7 @@ export class RecommendedVideosComponent implements OnInit, OnChanges { } else { this.autoPlayNextVideo = this.sessionStorageService.getItem(UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true' - this.sessionStorageService.watch([UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO]).subscribe( + this.sessionStorageService.watch([ UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO ]).subscribe( () => { this.autoPlayNextVideo = this.sessionStorageService.getItem(UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true' } diff --git a/client/src/app/+videos/+video-watch/shared/timestamp-route-transformer.directive.ts b/client/src/app/+videos/+video-watch/shared/timestamp-route-transformer.directive.ts index 45e023695..91fe5bf5d 100644 --- a/client/src/app/+videos/+video-watch/shared/timestamp-route-transformer.directive.ts +++ b/client/src/app/+videos/+video-watch/shared/timestamp-route-transformer.directive.ts @@ -1,12 +1,12 @@ import { Directive, EventEmitter, HostListener, Output } from '@angular/core' @Directive({ - selector: '[timestampRouteTransformer]' + selector: '[myTimestampRouteTransformer]' }) export class TimestampRouteTransformerDirective { @Output() timestampClicked = new EventEmitter() - @HostListener('click', ['$event']) + @HostListener('click', [ '$event' ]) public onClick ($event: Event) { const target = $event.target as HTMLLinkElement @@ -21,10 +21,10 @@ export class TimestampRouteTransformerDirective { const ngxLinkParams = new URLSearchParams(ngxLink.search) if (ngxLinkParams.has('start') !== true) return - const separators = ['h', 'm', 's'] + const separators = [ 'h', 'm', 's' ] const start = ngxLinkParams .get('start') - .match(new RegExp('(\\d{1,9}[' + separators.join('') + '])','g')) // match digits before any given separator + .match(new RegExp('(\\d{1,9}[' + separators.join('') + '])', 'g')) // match digits before any given separator .map(t => { if (t.includes('h')) return parseInt(t, 10) * 3600 if (t.includes('m')) return parseInt(t, 10) * 60 diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 85100b653..2007bdecb 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -195,10 +195,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private loadRouteParams () { this.paramsSub = this.route.params.subscribe(routeParams => { - const videoId = routeParams[ 'videoId' ] + const videoId = routeParams['videoId'] if (videoId) return this.loadVideo(videoId) - const playlistId = routeParams[ 'playlistId' ] + const playlistId = routeParams['playlistId'] if (playlistId) return this.loadPlaylist(playlistId) }) } @@ -206,7 +206,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private loadRouteQuery () { this.queryParamsSub = this.route.queryParams.subscribe(queryParams => { // Handle the ?playlistPosition - const positionParam = queryParams[ 'playlistPosition' ] ?? 1 + const positionParam = queryParams['playlistPosition'] ?? 1 this.playlistPosition = positionParam === 'last' ? -1 // Handle the "last" index @@ -219,7 +219,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition) - const start = queryParams[ 'start' ] + const start = queryParams['start'] if (this.player && start) this.player.currentTime(parseInt(start, 10)) }) } @@ -237,7 +237,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { 'filter:api.video-watch.video.get.result' ) - forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId)]) + forkJoin([ videoObs, this.videoCaptionService.listCaptions(videoId) ]) .subscribe({ next: ([ video, captionsResult ]) => { const queryParams = this.route.snapshot.queryParams @@ -292,6 +292,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { const originUrl = errorBody.originUrl + (window.location.search ?? '') const res = await this.confirmService.confirm( + // eslint-disable-next-line max-len $localize`This video is not available on this instance. Do you want to be redirected on the origin instance: ${originUrl}?`, $localize`Redirection` ) @@ -312,7 +313,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { if (!errorMessage) return // Display a message in the video player instead of a notification - if (errorMessage.indexOf('from xs param') !== -1) { + if (errorMessage.includes('from xs param')) { this.flushPlayer() this.remoteServerDown = true @@ -466,7 +467,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { if (this.nextVideoUUID) { this.router.navigate([ '/w', this.nextVideoUUID ]) - return } } @@ -483,14 +483,14 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private isAutoPlayNext () { return ( - (this.user && this.user.autoPlayNextVideo) || + (this.user?.autoPlayNextVideo) || this.anonymousUser.autoPlayNextVideo ) } private isPlaylistAutoPlayNext () { return ( - (this.user && this.user.autoPlayNextVideoPlaylist) || + (this.user?.autoPlayNextVideoPlaylist) || this.anonymousUser.autoPlayNextVideoPlaylist ) } @@ -508,9 +508,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } private buildPlayerManagerOptions (params: { - video: VideoDetails, - videoCaptions: VideoCaption[], - urlOptions: CustomizationOptions & { playerMode: PlayerMode }, + video: VideoDetails + videoCaptions: VideoCaption[] + urlOptions: CustomizationOptions & { playerMode: PlayerMode } user?: AuthUser }) { const { video, videoCaptions, urlOptions, user } = params @@ -573,10 +573,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy { language: this.localeId, - userWatching: user && user.videosHistoryEnabled === true ? { - url: this.videoService.getUserWatchingVideoUrl(video.uuid), - authorizationHeader: this.authService.getRequestHeaderValue() - } : undefined, + userWatching: user && user.videosHistoryEnabled === true + ? { + url: this.videoService.getUserWatchingVideoUrl(video.uuid), + authorizationHeader: this.authService.getRequestHeaderValue() + } + : undefined, serverUrl: environment.apiUrl, @@ -704,9 +706,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { if (this.isUserLoggedIn()) { this.hotkeys = this.hotkeys.concat([ new Hotkey('shift+s', () => { - this.subscribeButton.isSubscribedToAll() - ? this.subscribeButton.unsubscribe() - : this.subscribeButton.subscribe() + if (this.subscribeButton.isSubscribedToAll()) this.subscribeButton.unsubscribe() + else this.subscribeButton.subscribe() return false }, undefined, $localize`Subscribe to the account`) -- cgit v1.2.3