From 07f6ad78a071cce8f73887bbcbc22c81bedb66dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chif=20Gerg=C5=91?= <chif.gergo@cloud.bme.hu>
Date: Thu, 6 Aug 2020 10:14:23 +0200
Subject: [PATCH] Fix commands, run fix command to format code

---
 .eslintignore                 |  4 ++++
 .prettierignore               |  4 ++++
 package.json                  |  8 +++----
 src/index.tsx                 | 12 +++++-----
 src/serviceWorker.ts          | 43 ++++++++++++++++-------------------
 src/{tests => }/setupTests.ts |  0
 tsconfig.json                 | 10 ++------
 7 files changed, 40 insertions(+), 41 deletions(-)
 rename src/{tests => }/setupTests.ts (100%)

diff --git a/.eslintignore b/.eslintignore
index fd250ef..9c30e8e 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,7 @@
 .*rc.js
 .eslintrc*.js
 .prettierrc.js
+
+# Auto generated by React
+serviceWorker.*
+setupTests.*
\ No newline at end of file
diff --git a/.prettierignore b/.prettierignore
index 626f9cc..18a79da 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -59,3 +59,7 @@ Dockerfile.*
 docker-compose.*
 # Configuration files
 config/*
+
+# Auto generated by React
+serviceWorker.*
+setupTests.*
\ No newline at end of file
diff --git a/package.json b/package.json
index 3421b96..85e908b 100644
--- a/package.json
+++ b/package.json
@@ -5,16 +5,16 @@
   "scripts": {
     "build": "react-scripts build",
     "eject": "react-scripts eject",
-    "fix": "rus -s format lint:fix",
+    "fix": "run-s format lint:fix",
     "format": "prettier --write .",
     "format:check": "prettier --check .",
     "lint": "eslint --cache src",
     "lint:fix": "eslint src --fix",
     "pre-commit": "lint-staged -p false",
     "start": "react-scripts start",
-    "test": "react-scripts test --watchAll=false",
+    "test": "react-scripts test --watchAll=false --passWithNoTests",
     "test:watch": "react-scripts test",
-    "validate": "run -s format:check lint"
+    "validate": "run-s format:check lint"
   },
   "husky": {
     "hooks": {
@@ -23,7 +23,7 @@
   },
   "lint-staged": {
     "*": [
-      "prettier --write"
+      "prettier --write ."
     ],
     "*.{js,jsx,ts,tsx}": [
       "eslint --cache --fix"
diff --git a/src/index.tsx b/src/index.tsx
index ae24187..76d6f71 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,10 +1,10 @@
-import React from "react";
-import ReactDOM from "react-dom";
-import App from "./core/App";
-import * as serviceWorker from "./serviceWorker";
-import "semantic-ui-css/semantic.min.css";
+import React from 'react';
+import ReactDOM from 'react-dom';
+import 'semantic-ui-css/semantic.min.css';
+import App from './core/App';
+import * as serviceWorker from './serviceWorker';
 
-ReactDOM.render(<App />, document.getElementById("root"));
+ReactDOM.render(<App />, document.getElementById('root'));
 
 // If you want your app to work offline and load faster, you can change
 // unregister() to register() below. Note this comes with some pitfalls.
diff --git a/src/serviceWorker.ts b/src/serviceWorker.ts
index b09523f..9ac78e9 100644
--- a/src/serviceWorker.ts
+++ b/src/serviceWorker.ts
@@ -11,13 +11,13 @@
 // opt-in, read https://bit.ly/CRA-PWA
 
 const isLocalhost = Boolean(
-  window.location.hostname === 'localhost' ||
+  window.location.hostname === 'localhost'
     // [::1] is the IPv6 localhost address.
-    window.location.hostname === '[::1]' ||
+    || window.location.hostname === '[::1]'
     // 127.0.0.0/8 are considered localhost for IPv4.
-    window.location.hostname.match(
-      /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
-    )
+    || window.location.hostname.match(
+      /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
+    ),
 );
 
 type Config = {
@@ -28,10 +28,7 @@ type Config = {
 export function register(config?: Config) {
   if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
     // The URL constructor is available in all browsers that support SW.
-    const publicUrl = new URL(
-      process.env.PUBLIC_URL,
-      window.location.href
-    );
+    const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
     if (publicUrl.origin !== window.location.origin) {
       // Our service worker won't work if PUBLIC_URL is on a different origin
       // from what our page is served on. This might happen if a CDN is used to
@@ -50,8 +47,8 @@ export function register(config?: Config) {
         // service worker/PWA documentation.
         navigator.serviceWorker.ready.then(() => {
           console.log(
-            'This web app is being served cache-first by a service ' +
-              'worker. To learn more, visit https://bit.ly/CRA-PWA'
+            'This web app is being served cache-first by a service '
+              + 'worker. To learn more, visit https://bit.ly/CRA-PWA',
           );
         });
       } else {
@@ -65,7 +62,7 @@ export function register(config?: Config) {
 function registerValidSW(swUrl: string, config?: Config) {
   navigator.serviceWorker
     .register(swUrl)
-    .then(registration => {
+    .then((registration) => {
       registration.onupdatefound = () => {
         const installingWorker = registration.installing;
         if (installingWorker == null) {
@@ -78,8 +75,8 @@ function registerValidSW(swUrl: string, config?: Config) {
               // but the previous service worker will still serve the older
               // content until all client tabs are closed.
               console.log(
-                'New content is available and will be used when all ' +
-                  'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
+                'New content is available and will be used when all '
+                  + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
               );
 
               // Execute callback
@@ -101,7 +98,7 @@ function registerValidSW(swUrl: string, config?: Config) {
         };
       };
     })
-    .catch(error => {
+    .catch((error) => {
       console.error('Error during service worker registration:', error);
     });
 }
@@ -109,17 +106,17 @@ function registerValidSW(swUrl: string, config?: Config) {
 function checkValidServiceWorker(swUrl: string, config?: Config) {
   // Check if the service worker can be found. If it can't reload the page.
   fetch(swUrl, {
-    headers: { 'Service-Worker': 'script' }
+    headers: { 'Service-Worker': 'script' },
   })
-    .then(response => {
+    .then((response) => {
       // Ensure service worker exists, and that we really are getting a JS file.
       const contentType = response.headers.get('content-type');
       if (
-        response.status === 404 ||
-        (contentType != null && contentType.indexOf('javascript') === -1)
+        response.status === 404
+        || (contentType != null && contentType.indexOf('javascript') === -1)
       ) {
         // No service worker found. Probably a different app. Reload the page.
-        navigator.serviceWorker.ready.then(registration => {
+        navigator.serviceWorker.ready.then((registration) => {
           registration.unregister().then(() => {
             window.location.reload();
           });
@@ -131,7 +128,7 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
     })
     .catch(() => {
       console.log(
-        'No internet connection found. App is running in offline mode.'
+        'No internet connection found. App is running in offline mode.',
       );
     });
 }
@@ -139,10 +136,10 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
 export function unregister() {
   if ('serviceWorker' in navigator) {
     navigator.serviceWorker.ready
-      .then(registration => {
+      .then((registration) => {
         registration.unregister();
       })
-      .catch(error => {
+      .catch((error) => {
         console.error(error.message);
       });
   }
diff --git a/src/tests/setupTests.ts b/src/setupTests.ts
similarity index 100%
rename from src/tests/setupTests.ts
rename to src/setupTests.ts
diff --git a/tsconfig.json b/tsconfig.json
index f2850b7..af10394 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,11 +1,7 @@
 {
   "compilerOptions": {
     "target": "es5",
-    "lib": [
-      "dom",
-      "dom.iterable",
-      "esnext"
-    ],
+    "lib": ["dom", "dom.iterable", "esnext"],
     "allowJs": true,
     "skipLibCheck": true,
     "esModuleInterop": true,
@@ -19,7 +15,5 @@
     "noEmit": true,
     "jsx": "react"
   },
-  "include": [
-    "src"
-  ]
+  "include": ["src"]
 }
-- 
GitLab