82 // At this point, everything has been precached.
83 // It's the perfect time to display a
84 // "Content is cached for offline use." message.
85 console.log('Content is cached for offline use.'); 86
87 // Execute callback
88 if (config && config.onSuccess) {
122 }
123 })
124 .catch(() => {
125 console.log(126 'No internet connection found. App is running in offline mode.'127 );128 });
129}
130
41 // Add some additional logging to localhost, pointing developers to the
42 // service worker/PWA documentation.
43 navigator.serviceWorker.ready.then(() => {
44 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' 47 ); 48 });
49 } else {
50 // Is not localhost. Just register service worker
69 // At this point, the updated precached content has been fetched,
70 // but the previous service worker will still serve the older
71 // content until all client tabs are closed.
72 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.' 75 ); 76
77 // Execute callback
78 if (config && config.onUpdate) {
It is considered a best practice to avoid the use of any console
methods in JavaScript code that will run on the browser.
NOTE: If your repository contains a server side project, you can add "nodejs"
to the environment
property of analyzer meta in .deepsource.toml
.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.
If a specific console
call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.
Usually, console
methods are only used for debugging, and can leak internal info to the client.
Removing the console
call will fix this issue.
Bad Practice
if (!secure(data)) {
console.log("data is not secure", data) // `data` is visible to the client
}
console.table(tableObj)
Recommended
if (!secure(data)) {
// alter the DOM to inform the user that `data` is insecure.
}
console.table(tableObj) // skipcq: JS-0002 Easter egg. Users are meant to see this.