From 364639680648df3bb499cf65ce267e7f68a3e8cc Mon Sep 17 00:00:00 2001
From: paflov <paf@titelfrei.de>
Date: Fri, 16 Apr 2021 12:19:27 +0200
Subject: [PATCH] lints

---
 .../sys-check/welcome/welcome.component.ts    | 90 ++++++++++++++-----
 1 file changed, 70 insertions(+), 20 deletions(-)

diff --git a/src/app/sys-check/welcome/welcome.component.ts b/src/app/sys-check/welcome/welcome.component.ts
index 7f80909f..9cf79181 100644
--- a/src/app/sys-check/welcome/welcome.component.ts
+++ b/src/app/sys-check/welcome/welcome.component.ts
@@ -1,24 +1,22 @@
 import { Component, OnInit } from '@angular/core';
 import { SysCheckDataService } from '../sys-check-data.service';
 import { ReportEntry } from '../sys-check.interfaces';
-import {CustomtextService} from "iqb-components";
 
 @Component({
   styleUrls: ['../sys-check.component.css'],
   templateUrl: './welcome.component.html'
 })
 export class WelcomeComponent implements OnInit {
-
   private report: Map<string, ReportEntry> = new Map<string, ReportEntry>();
 
   private rating = {
     browser: {
-      'Chrome': 79,
-      'Safari': 13,
-      'Edge': 79,
-      'Firefox': 72,
+      Chrome: 79,
+      Safari: 13,
+      Edge: 79,
+      Firefox: 72,
       'Internet Explorer': 11,
-      'Opera': 64
+      Opera: 64
     },
     screen: {
       width: 800,
@@ -30,7 +28,7 @@ export class WelcomeComponent implements OnInit {
     public ds: SysCheckDataService
   ) { }
 
-  ngOnInit() {
+  ngOnInit(): void {
     setTimeout(() => {
       this.ds.setNewCurrentStep('w');
       this.getBrowser(); // fallback if UAParser does not work
@@ -42,27 +40,42 @@ export class WelcomeComponent implements OnInit {
       this.rateBrowser();
 
       const report = Array.from(this.report.values())
-        .sort((item1: ReportEntry, item2: ReportEntry) => (item1.label > item2.label) ? 1 : -1);
+        .sort((item1: ReportEntry, item2: ReportEntry) => (item1.label > item2.label ? 1 : -1));
       this.ds.environmentReport = Object.values(report);
-    })
+    });
   }
 
   private getBrowser() {
     const userAgent = window.navigator.userAgent;
+    // eslint-disable-next-line max-len
     const regex = /(MSIE|Trident|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari(?!.+Edge)|(?!AppleWebKit.+)Chrome(?!.+Edge)|(?!AppleWebKit.+Chrome.+Safari.+)Edge|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d\.apre]+)/;
     // credit due to: https://gist.github.com/ticky/3909462#gistcomment-2245669
     const deviceInfoSplits = regex.exec(userAgent);
     const helperRegex = /[^.]*/;
     const browserInfo = helperRegex.exec(deviceInfoSplits[0]);
     const browserInfoSplits = browserInfo[0].split('/');
-    this.report.set('Browser', {'id': 'browser', 'type': 'environment', 'label': 'Browser', 'value': browserInfoSplits[0], 'warning': false});
-    this.report.set('Browser-Version', {'id': 'browser-version', 'type': 'environment', 'label': 'Browser-Version', 'value': browserInfoSplits[1], 'warning': false});
+    this.report.set('Browser', {
+      id: 'browser',
+      type: 'environment',
+      label: 'Browser',
+      value: browserInfoSplits[0],
+      warning: false
+    });
+    this.report.set('Browser-Version', {
+      id: 'browser-version',
+      type: 'environment',
+      label: 'Browser-Version',
+      value: browserInfoSplits[1],
+      warning: false
+    });
   }
 
   private getFromUAParser() {
+    // eslint-disable-next-line @typescript-eslint/dot-notation
     if (typeof window['UAParser'] === 'undefined') {
       return;
     }
+    // eslint-disable-next-line @typescript-eslint/dot-notation
     const uaInfos = window['UAParser']();
     [
       ['cpu', 'architecture', 'CPU-Architektur'],
@@ -75,7 +88,13 @@ export class WelcomeComponent implements OnInit {
       ['os', 'version', 'Betriebsystem-Version']
     ].forEach((item: Array<string>) => {
       if ((typeof uaInfos[item[0]] !== 'undefined') && (typeof uaInfos[item[0]][item[1]] !== 'undefined')) {
-        this.report.set(item[2], {'id': item[2], 'type': 'environment', 'label': item[2], 'value': uaInfos[item[0]][item[1]], 'warning': false});
+        this.report.set(item[2], {
+          id: item[2],
+          type: 'environment',
+          label: item[2],
+          value: uaInfos[item[0]][item[1]],
+          warning: false
+        });
       }
     });
   }
@@ -98,7 +117,13 @@ export class WelcomeComponent implements OnInit {
       ['language', 'Browser-Sprache']
     ].forEach((item: string[]) => {
       if (typeof navigator[item[0]] !== 'undefined') {
-        this.report.set(item[1], {'id': item[0], 'type': 'environment', 'label': item[1], 'value': navigator[item[0]], 'warning': false});
+        this.report.set(item[1], {
+          id: item[0],
+          type: 'environment',
+          label: item[1],
+          value: navigator[item[0]],
+          warning: false
+        });
       }
     });
   }
@@ -107,11 +132,17 @@ export class WelcomeComponent implements OnInit {
     if ((typeof navigator.plugins === 'undefined') || (!navigator.plugins.length)) {
       return;
     }
-    const pluginNames = Array<String>();
+    const pluginNames = Array<string>();
     for (let i = 0; i < navigator.plugins.length; i++) {
       pluginNames.push(navigator.plugins[i].name);
     }
-    this.report.set('Browser-Plugins', {'id': 'browser-plugins', 'type': 'environment', 'label': 'Browser-Plugins', 'value': pluginNames.join(', '), 'warning': false});
+    this.report.set('Browser-Plugins', {
+      id: 'browser-plugins',
+      type: 'environment',
+      label: 'Browser-Plugins',
+      value: pluginNames.join(', '),
+      warning: false
+    });
   }
 
   private setOS() {
@@ -140,14 +171,33 @@ export class WelcomeComponent implements OnInit {
     } else {
       osName = window.navigator.platform;
     }
-    this.report.set('Betriebsystem', {'id': 'os', 'type': 'environment', 'label': 'Betriebsystem', 'value': osName, 'warning': false});
+    this.report.set('Betriebsystem', {
+      id: 'os',
+      type: 'environment',
+      label: 'Betriebsystem',
+      value: osName,
+      warning: false
+    });
   }
 
   private setScreenData() {
-    const isLargeEnough = (window.screen.width >= this.rating.screen.width) && (window.screen.height >= this.rating.screen.height);
-    this.report.set('Bildschirm-Auflösung', {'id': 'screen-resolution', 'type': 'environment', 'label': 'Bildschirm-Auflösung', 'value': window.screen.width + ' x ' + window.screen.height, 'warning': !isLargeEnough});
+    const isLargeEnough = (window.screen.width >= this.rating.screen.width) &&
+      (window.screen.height >= this.rating.screen.height);
+    this.report.set('Bildschirm-Auflösung', {
+      id: 'screen-resolution',
+      type: 'environment',
+      label: 'Bildschirm-Auflösung',
+      value: `${window.screen.width} x ${window.screen.height}`,
+      warning: !isLargeEnough
+    });
     const windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.offsetWidth;
     const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.offsetHeight;
-    this.report.set('Fenster-Größe', {'id': 'screen-size', 'type': 'environment', 'label': 'Fenster-Größe', 'value': windowWidth + ' x ' + windowHeight, 'warning': false});
+    this.report.set('Fenster-Größe', {
+      id: 'screen-size',
+      type: 'environment',
+      label: 'Fenster-Größe',
+      value: `${windowWidth} x ${windowHeight}`,
+      warning: false
+    });
   }
 }
-- 
GitLab