From c0255c8a481ad58a2400f6ea03fd1f3e1039f711 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 24 Oct 2021 22:40:47 +0200 Subject: [PATCH] refactor: eslint fixes and code improvements --- .eslintrc.json | 4 ++++ .../player/components/epg-list/epg-list.component.spec.ts | 3 +-- .../html-video-player/html-video-player.component.ts | 7 +++++-- .../player/components/vjs-player/vjs-player.component.ts | 5 ++++- src/app/settings/settings.component.spec.ts | 5 +---- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e1f7d15a7..ee8e7d6e0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -41,7 +41,11 @@ "ignoredNodes": ["TSTypeParameterInstantiation"] } ], + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": ["error"], + "@typescript-eslint/no-duplicate-imports": ["error"], "@typescript-eslint/no-empty-function": 0, + "@typescript-eslint/no-unsafe-argument": 0, "@typescript-eslint/no-var-requires": 0, "@typescript-eslint/no-explicit-any": 0, "@typescript-eslint/no-unsafe-call": 0, diff --git a/src/app/player/components/epg-list/epg-list.component.spec.ts b/src/app/player/components/epg-list/epg-list.component.spec.ts index 70130c926..286ae8a35 100644 --- a/src/app/player/components/epg-list/epg-list.component.spec.ts +++ b/src/app/player/components/epg-list/epg-list.component.spec.ts @@ -1,4 +1,4 @@ -import { MockComponent, MockProvider } from 'ng-mocks'; +import { MockComponent, MockProvider, MockModule, MockPipe } from 'ng-mocks'; /* eslint-disable @typescript-eslint/unbound-method */ import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { TranslatePipe } from '@ngx-translate/core'; @@ -6,7 +6,6 @@ import { MatTooltipModule } from '@angular/material/tooltip'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { EpgListComponent, EpgData } from './epg-list.component'; import { MatListModule } from '@angular/material/list'; -import { MockModule, MockPipe } from 'ng-mocks'; import { ElectronService } from '../../../services/electron.service'; import { ElectronServiceStub } from '../../../home/home.component.spec'; import * as moment from 'moment'; diff --git a/src/app/player/components/html-video-player/html-video-player.component.ts b/src/app/player/components/html-video-player/html-video-player.component.ts index 36532724e..1d0ea2816 100644 --- a/src/app/player/components/html-video-player/html-video-player.component.ts +++ b/src/app/player/components/html-video-player/html-video-player.component.ts @@ -10,6 +10,9 @@ import { import { Channel } from '../../../state'; import Hls from 'hls.js'; +/** + * This component contains the implementation of HTML5 based video player + */ @Component({ selector: 'app-html-video-player', templateUrl: './html-video-player.component.html', @@ -78,13 +81,13 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy { if (playPromise !== undefined) { playPromise - .then((_) => { + .then(() => { // Automatic playback started! if (!this.showCaptions) { this.disableCaptions(); } }) - .catch((error) => {}); + .catch(() => {}); } } diff --git a/src/app/player/components/vjs-player/vjs-player.component.ts b/src/app/player/components/vjs-player/vjs-player.component.ts index 7977c8b43..e9acd40fb 100644 --- a/src/app/player/components/vjs-player/vjs-player.component.ts +++ b/src/app/player/components/vjs-player/vjs-player.component.ts @@ -13,6 +13,9 @@ import 'videojs-hls-quality-selector'; import 'videojs-contrib-quality-levels'; import '@yangkghjh/videojs-aspect-ratio-panel'; +/** + * This component contains the implementation of video player that is based on video.js library + */ @Component({ selector: 'app-vjs-player', templateUrl: './vjs-player.component.html', @@ -21,7 +24,7 @@ import '@yangkghjh/videojs-aspect-ratio-panel'; }) export class VjsPlayerComponent implements OnInit, OnDestroy { /** DOM-element reference */ - @ViewChild('target', { static: true }) target: ElementRef; + @ViewChild('target', { static: true }) target: ElementRef; /** Options of VideoJs player */ @Input() options: videoJs.PlayerOptions; /** VideoJs object */ diff --git a/src/app/settings/settings.component.spec.ts b/src/app/settings/settings.component.spec.ts index ed3f74243..cd952b394 100644 --- a/src/app/settings/settings.component.spec.ts +++ b/src/app/settings/settings.component.spec.ts @@ -1,6 +1,5 @@ import { MatCheckboxModule } from '@angular/material/checkbox'; import { StorageMap } from '@ngx-pwa/local-storage'; -import { FormBuilder } from '@angular/forms'; /* eslint-disable @typescript-eslint/unbound-method */ import { ElectronService } from './../services/electron.service'; import { ElectronServiceStub } from './../home/home.component.spec'; @@ -18,7 +17,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { MockModule, MockPipe, MockComponent } from 'ng-mocks'; import { MatIconModule } from '@angular/material/icon'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { EPG_FETCH } from '../../../shared/ipc-commands'; import { Router } from '@angular/router'; @@ -37,7 +36,6 @@ describe('SettingsComponent', () => { let component: SettingsComponent; let fixture: ComponentFixture; let electronService: ElectronService; - let storage: StorageMap; let router: Router; beforeEach( @@ -82,7 +80,6 @@ describe('SettingsComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(SettingsComponent); electronService = TestBed.inject(ElectronService); - storage = TestBed.inject(StorageMap); router = TestBed.inject(Router); component = fixture.componentInstance; fixture.detectChanges();