From b049801ef9b80985dee1be8dfc38facf5928308e Mon Sep 17 00:00:00 2001 From: zivglik Date: Sun, 23 Jun 2024 10:04:57 +0300 Subject: [PATCH] fix eslint --- src/config/mock/buildLogsMock.js | 1 + src/serviceWorker.js | 78 +++++++++++++++++--------------- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/config/mock/buildLogsMock.js b/src/config/mock/buildLogsMock.js index e6109015f..eb02354df 100644 --- a/src/config/mock/buildLogsMock.js +++ b/src/config/mock/buildLogsMock.js @@ -62,6 +62,7 @@ const mockData = [ ]; const buildLog = + // eslint-disable-next-line no-template-curly-in-string '\nIMAGE_NAME=docker.io/hkubedev/reduce:v1.0.0\nBUILD_PATH=builds/nodejs/reduce\nBASE_IMAGE=node:10.17-slim\nDOCKER_PULL_REGISTRY=docker.io/hkube\nINSECURE_PULL=false\nSKIP_TLS_VERIFY_PULL=false\nDOCKER_PUSH_REGISTRY=docker.io/hkubedev\nSKIP_TLS_VERIFY=false\nINSECURE=false\nPACKAGES_REGISTRY=\nREMOVE_IMAGE=True\nTMP_FOLDER=/tmp\n\n\nBuilding image docker.io/hkubedev/reduce:v1.0.0\ncopy context from builds/nodejs/reduce to /tmp/workspace\n\u001b[36mINFO\u001b[0m[0000] Checking push permissions \n\u001b[36mINFO\u001b[0m[0001] Resolved base name ${baseImage} to node:10.17-slim \n\u001b[36mINFO\u001b[0m[0001] Resolved base name ${baseImage} to node:10.17-slim \n\u001b[36mINFO\u001b[0m[0001] Resolved base name ${baseImage} to node:10.17-slim \n\u001b[36mINFO\u001b[0m[0001] Resolved base name ${baseImage} to node:10.17-slim \n\u001b[36mINFO\u001b[0m[0001] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0003] Error while retrieving image from cache: getting file info: stat /cache/sha256:17df3b18bc0f1d3ebccbd91e8ca8e2b06d67cb4dc6ca55e8c09c36c39fd4535d: no such file or directory \n\u001b[36mINFO\u001b[0m[0003] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0010] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0010] Error while retrieving image from cache: getting file info: stat /cache/sha256:17df3b18bc0f1d3ebccbd91e8ca8e2b06d67cb4dc6ca55e8c09c36c39fd4535d: no such file or directory \n\u001b[36mINFO\u001b[0m[0010] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0017] Built cross stage deps: map[0:[/hkube/algorithm-runner/algorithm_unique_folder/]] \n\u001b[36mINFO\u001b[0m[0017] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0017] Error while retrieving image from cache: getting file info: stat /cache/sha256:17df3b18bc0f1d3ebccbd91e8ca8e2b06d67cb4dc6ca55e8c09c36c39fd4535d: no such file or directory \n\u001b[36mINFO\u001b[0m[0017] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0020] Unpacking rootfs as cmd RUN ../dockerfile/requirements.sh ${packagesRegistry} ${packagesToken} requires it. \n\u001b[36mINFO\u001b[0m[0037] Taking snapshot of full filesystem... \n\u001b[36mINFO\u001b[0m[0042] LABEL maintainer="hkube.dev@gmail.com" \n\u001b[36mINFO\u001b[0m[0042] Applying label maintainer=hkube.dev@gmail.com \n\u001b[36mINFO\u001b[0m[0042] Using files from context: [/workspace/algorithm_unique_folder] \n\u001b[36mINFO\u001b[0m[0042] COPY ./algorithm_unique_folder/ /hkube/algorithm-runner/algorithm_unique_folder/ \n\u001b[36mINFO\u001b[0m[0042] Taking snapshot of files... \n\u001b[36mINFO\u001b[0m[0042] Using files from context: [/workspace/dockerfile] \n\u001b[36mINFO\u001b[0m[0042] COPY ./dockerfile /hkube/algorithm-runner/dockerfile \n\u001b[36mINFO\u001b[0m[0042] Taking snapshot of files... \n\u001b[36mINFO\u001b[0m[0042] WORKDIR /hkube/algorithm-runner/algorithm_unique_folder \n\u001b[36mINFO\u001b[0m[0042] cmd: workdir \n\u001b[36mINFO\u001b[0m[0042] Changed working directory to /hkube/algorithm-runner/algorithm_unique_folder \n\u001b[36mINFO\u001b[0m[0042] RUN ../dockerfile/requirements.sh ${packagesRegistry} ${packagesToken} \n\u001b[36mINFO\u001b[0m[0042] cmd: /bin/sh \n\u001b[36mINFO\u001b[0m[0042] args: [-c ../dockerfile/requirements.sh ${packagesRegistry} ${packagesToken}] \nno npm credentials found\nnpm WARN saveError ENOENT: no such file or directory, open \'/hkube/algorithm-runner/algorithm_unique_folder/package.json\'\nnpm notice created a lockfile as package-lock.json. You should commit this file.\nnpm WARN enoent ENOENT: no such file or directory, open \'/hkube/algorithm-runner/algorithm_unique_folder/package.json\'\nnpm WARN algorithm_unique_folder No description\nnpm WARN algorithm_unique_folder No repository field.\nnpm WARN algorithm_unique_folder No README data\nnpm WARN algorithm_unique_folder No license field.\n\nup to date in 0.455s\nfound 0 vulnerabilities\n\n\u001b[36mINFO\u001b[0m[0043] Taking snapshot of full filesystem... \n\u001b[36mINFO\u001b[0m[0045] Saving file /hkube/algorithm-runner/algorithm_unique_folder/ for later use. \n\u001b[36mINFO\u001b[0m[0045] Deleting filesystem... \n\u001b[36mINFO\u001b[0m[0045] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0047] Error while retrieving image from cache: getting file info: stat /cache/sha256:17df3b18bc0f1d3ebccbd91e8ca8e2b06d67cb4dc6ca55e8c09c36c39fd4535d: no such file or directory \n\u001b[36mINFO\u001b[0m[0047] Downloading base image node:10.17-slim \n\u001b[36mINFO\u001b[0m[0059] Skipping unpacking as no commands require it. \n\u001b[36mINFO\u001b[0m[0059] Taking snapshot of full filesystem... \n\u001b[36mINFO\u001b[0m[0059] Using files from context: [/workspace/wrapper] \n\u001b[36mINFO\u001b[0m[0059] COPY ./wrapper /hkube/algorithm-runner \n\u001b[36mINFO\u001b[0m[0059] Taking snapshot of files... \n\u001b[36mINFO\u001b[0m[0059] Using files from context: [/workspace/packages] \n\u001b[36mINFO\u001b[0m[0059] COPY ./packages/ /hkube/algorithm-runner/ \n\u001b[36mINFO\u001b[0m[0059] Taking snapshot of files... \n\u001b[36mINFO\u001b[0m[0060] COPY --from=build /hkube/algorithm-runner/algorithm_unique_folder/ /hkube/algorithm-runner/algorithm_unique_folder/ \n\u001b[36mINFO\u001b[0m[0060] Taking snapshot of files... \n\u001b[36mINFO\u001b[0m[0060] WORKDIR /hkube/algorithm-runner \n\u001b[36mINFO\u001b[0m[0060] cmd: workdir \n\u001b[36mINFO\u001b[0m[0060] Changed working directory to /hkube/algorithm-runner \n\u001b[36mINFO\u001b[0m[0060] CMD ["npm", "start"] \nbuild done\nbuild finished with code 0\n\n'; export { buildLog, mockData }; diff --git a/src/serviceWorker.js b/src/serviceWorker.js index 881bb5f7d..0b459bdf1 100644 --- a/src/serviceWorker.js +++ b/src/serviceWorker.js @@ -16,47 +16,15 @@ const isLocalhost = Boolean( // [::1] is the IPv6 localhost address. window.location.hostname === '[::1]' || // 127.0.0.1/8 is 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}$/ + ) ); - -export function register(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); - 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 - // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; - } - - window.addEventListener('load', () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; - - if (isLocalhost) { - // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); - - // Add some additional logging to localhost, pointing developers to the - // 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 http://bit.ly/CRA-PWA' - ); - }); - } else { - // Is not localhost. Just register service worker - registerValidSW(swUrl, config); - } - }); - } -} - function registerValidSW(swUrl, config) { navigator.serviceWorker .register(swUrl) .then(registration => { + // eslint-disable-next-line no-param-reassign registration.onupdatefound = () => { const installingWorker = registration.installing; if (installingWorker == null) { @@ -119,10 +87,46 @@ function checkValidServiceWorker(swUrl, config) { } }) .catch(() => { - console.log('No internet connection found. App is running in offline mode.'); + console.log( + 'No internet connection found. App is running in offline mode.' + ); }); } +export function register(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); + 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 + // serve assets; see https://github.com/facebook/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Let's check if a service worker still exists or not. + checkValidServiceWorker(swUrl, config); + + // Add some additional logging to localhost, pointing developers to the + // 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 http://bit.ly/CRA-PWA' + ); + }); + } else { + // Is not localhost. Just register service worker + registerValidSW(swUrl, config); + } + }); + } +} + export function unregister() { if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => {