1+ /* eslint no-use-before-define: 0 */
2+ /* eslint no-console: 0 */
3+ /* eslint no-param-reassign: 0 */
4+
15// This optional code is used to register a service worker.
26// register() is not called by default.
37
1115// opt-in, read https://bit.ly/CRA-PWA
1216
1317const isLocalhost = Boolean (
14- window . location . hostname === 'localhost' ||
18+ window . location . hostname === 'localhost'
1519 // [::1] is the IPv6 localhost address.
16- window . location . hostname === '[::1]' ||
20+ || window . location . hostname === '[::1]'
1721 // 127.0.0.0/8 are considered localhost for IPv4.
18- window . location . hostname . match (
19- / ^ 1 2 7 (?: \. (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) ) { 3 } $ /
20- )
22+ || window . location . hostname . match (
23+ / ^ 1 2 7 (?: \. (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) ) { 3 } $ / ,
24+ ) ,
2125) ;
2226
2327export function register ( config ) {
@@ -42,8 +46,8 @@ export function register(config) {
4246 // service worker/PWA documentation.
4347 navigator . serviceWorker . ready . then ( ( ) => {
4448 console . log (
45- 'This web app is being served cache-first by a service ' +
46- 'worker. To learn more, visit https://bit.ly/CRA-PWA'
49+ 'This web app is being served cache-first by a service '
50+ + 'worker. To learn more, visit https://bit.ly/CRA-PWA' ,
4751 ) ;
4852 } ) ;
4953 } else {
@@ -57,7 +61,7 @@ export function register(config) {
5761function registerValidSW ( swUrl , config ) {
5862 navigator . serviceWorker
5963 . register ( swUrl )
60- . then ( registration => {
64+ . then ( ( registration ) => {
6165 registration . onupdatefound = ( ) => {
6266 const installingWorker = registration . installing ;
6367 if ( installingWorker == null ) {
@@ -70,8 +74,8 @@ function registerValidSW(swUrl, config) {
7074 // but the previous service worker will still serve the older
7175 // content until all client tabs are closed.
7276 console . log (
73- 'New content is available and will be used when all ' +
74- 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
77+ 'New content is available and will be used when all '
78+ + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' ,
7579 ) ;
7680
7781 // Execute callback
@@ -93,7 +97,7 @@ function registerValidSW(swUrl, config) {
9397 } ;
9498 } ;
9599 } )
96- . catch ( error => {
100+ . catch ( ( error ) => {
97101 console . error ( 'Error during service worker registration:' , error ) ;
98102 } ) ;
99103}
@@ -103,15 +107,15 @@ function checkValidServiceWorker(swUrl, config) {
103107 fetch ( swUrl , {
104108 headers : { 'Service-Worker' : 'script' } ,
105109 } )
106- . then ( response => {
110+ . then ( ( response ) => {
107111 // Ensure service worker exists, and that we really are getting a JS file.
108112 const contentType = response . headers . get ( 'content-type' ) ;
109113 if (
110- response . status === 404 ||
111- ( contentType != null && contentType . indexOf ( 'javascript' ) === - 1 )
114+ response . status === 404
115+ || ( contentType != null && contentType . indexOf ( 'javascript' ) === - 1 )
112116 ) {
113117 // No service worker found. Probably a different app. Reload the page.
114- navigator . serviceWorker . ready . then ( registration => {
118+ navigator . serviceWorker . ready . then ( ( registration ) => {
115119 registration . unregister ( ) . then ( ( ) => {
116120 window . location . reload ( ) ;
117121 } ) ;
@@ -123,18 +127,18 @@ function checkValidServiceWorker(swUrl, config) {
123127 } )
124128 . catch ( ( ) => {
125129 console . log (
126- 'No internet connection found. App is running in offline mode.'
130+ 'No internet connection found. App is running in offline mode.' ,
127131 ) ;
128132 } ) ;
129133}
130134
131135export function unregister ( ) {
132136 if ( 'serviceWorker' in navigator ) {
133137 navigator . serviceWorker . ready
134- . then ( registration => {
138+ . then ( ( registration ) => {
135139 registration . unregister ( ) ;
136140 } )
137- . catch ( error => {
141+ . catch ( ( error ) => {
138142 console . error ( error . message ) ;
139143 } ) ;
140144 }
0 commit comments