From ec3aa1747d3409c461360ff545acfc09918c4b70 Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 3 May 2021 15:01:49 -0700 Subject: [PATCH] Lint against console.log and replace `console.log` instances in the codebase with better alternatives! --- package.json | 15 ++++++++++++++- src/app/WardrobePage/OutfitControls.js | 2 +- src/app/WardrobePage/WardrobeDevHacks.js | 6 +++--- src/app/WardrobePage/index.js | 2 +- src/app/WardrobePage/useOutfitState.js | 2 +- src/app/util.js | 4 ++-- src/server/auth.js | 2 +- src/server/index.js | 2 +- src/server/modeling.js | 2 +- src/server/types/AppearanceLayer.js | 2 +- src/server/types/Outfit.js | 2 +- 11 files changed, 27 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 4f1f0ab..62418b5 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,20 @@ "export-users-to-auth0": "ts-node --compiler=typescript-cached-transpile --transpile-only -r dotenv/config scripts/export-users-to-auth0.js" }, "eslintConfig": { - "extends": "react-app" + "extends": "react-app", + "rules": { + "no-console": [ + "error", + { + "allow": [ + "debug", + "info", + "warn", + "error" + ] + } + ] + } }, "browserslist": { "production": [ diff --git a/src/app/WardrobePage/OutfitControls.js b/src/app/WardrobePage/OutfitControls.js index 76ffd3c..ecfe67d 100644 --- a/src/app/WardrobePage/OutfitControls.js +++ b/src/app/WardrobePage/OutfitControls.js @@ -542,7 +542,7 @@ function useDownloadableImage(visibleLayers) { context.drawImage(image, 0, 0); } - console.log( + console.debug( "Generated image for download", layerIds, canvas.toDataURL("image/png") diff --git a/src/app/WardrobePage/WardrobeDevHacks.js b/src/app/WardrobePage/WardrobeDevHacks.js index e8262cd..f2f2f47 100644 --- a/src/app/WardrobePage/WardrobeDevHacks.js +++ b/src/app/WardrobePage/WardrobeDevHacks.js @@ -77,7 +77,7 @@ function WardrobeDevHacks() { data: { zone: { __ref: `Zone:${zone.id}` } }, }); - console.log( + console.info( `Updated layer ${layerId} to zone ${zone.id} (was ${layer?.zone?.id})` ); }, @@ -171,7 +171,7 @@ function WardrobeDevHacks() { }, }); - console.log( + console.info( `Added restricted zone ${zone.id} to item ${itemId} ` + `(now it's zones ${[...restrictedZoneIds].join(", ")})` ); @@ -262,7 +262,7 @@ function WardrobeDevHacks() { }, }); - console.log( + console.info( `Removed restricted zone ${zone.id} from item ${itemId} ` + `(now it's zones ${[...restrictedZoneIds].join(", ")})` ); diff --git a/src/app/WardrobePage/index.js b/src/app/WardrobePage/index.js index 0a6f3ac..b21b982 100644 --- a/src/app/WardrobePage/index.js +++ b/src/app/WardrobePage/index.js @@ -32,7 +32,7 @@ function WardrobePage() { // isn't very common, so this lil toast notification seems good enough! React.useEffect(() => { if (error) { - console.log(error); + console.error(error); toast({ title: "We couldn't load this outfit 😖", description: "Please reload the page to try again. Sorry!", diff --git a/src/app/WardrobePage/useOutfitState.js b/src/app/WardrobePage/useOutfitState.js index 1409643..4402f56 100644 --- a/src/app/WardrobePage/useOutfitState.js +++ b/src/app/WardrobePage/useOutfitState.js @@ -248,7 +248,7 @@ function useOutfitState() { } const outfitStateReducer = (apolloClient) => (baseState, action) => { - console.log("[Outfit state] Action:", action); + console.info("[Outfit state] Action:", action); switch (action.type) { case "rename": return produce(baseState, (state) => { diff --git a/src/app/util.js b/src/app/util.js index 0a26e09..1810467 100644 --- a/src/app/util.js +++ b/src/app/util.js @@ -288,7 +288,7 @@ export function useLocalStorage(key, initialValue) { const item = window.localStorage.getItem(key); return item ? JSON.parse(item) : initialValue; } catch (error) { - console.log(error); + console.error(error); return initialValue; } }, [key, initialValue]); @@ -301,7 +301,7 @@ export function useLocalStorage(key, initialValue) { window.localStorage.setItem(key, JSON.stringify(value)); storageListeners.forEach((l) => l()); } catch (error) { - console.log(error); + console.error(error); } }; diff --git a/src/server/auth.js b/src/server/auth.js index 6cc1e15..8af6082 100644 --- a/src/server/auth.js +++ b/src/server/auth.js @@ -48,7 +48,7 @@ async function getUserIdFromToken(token) { const subMatch = payload.sub.match(/auth0\|impress-([0-9]+)/); if (!subMatch) { - console.log("Unexpected auth token sub format", payload.sub); + console.error("Unexpected auth token sub format", payload.sub); return null; } const userId = subMatch[1]; diff --git a/src/server/index.js b/src/server/index.js index e1b6c5f..0174a38 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -91,7 +91,7 @@ if (require.main === module) { const { ApolloServer } = require("apollo-server"); const server = new ApolloServer(config); server.listen().then(({ url }) => { - console.log(`🚀 Server ready at ${url}`); + console.info(`🚀 Server ready at ${url}`); }); } diff --git a/src/server/modeling.js b/src/server/modeling.js index 6429120..d81eda6 100644 --- a/src/server/modeling.js +++ b/src/server/modeling.js @@ -22,7 +22,7 @@ async function saveModelingData(customPetData, petMetaData, context) { const modelingLogs = []; const addToModelingLogs = (entry) => { - console.log("[Modeling] " + JSON.stringify(entry, null, 4)); + console.info("[Modeling] " + JSON.stringify(entry, null, 4)); modelingLogs.push(entry); }; context = { ...context, addToModelingLogs }; diff --git a/src/server/types/AppearanceLayer.js b/src/server/types/AppearanceLayer.js index bf26f8e..134c9d8 100644 --- a/src/server/types/AppearanceLayer.js +++ b/src/server/types/AppearanceLayer.js @@ -490,7 +490,7 @@ async function loadAndCacheAssetManifest(db, layer) { `Expected to affect 1 asset, but affected ${result.affectedRows}` ); } - console.log( + console.info( `Loaded and saved manifest for ${layer.type} ${layer.remoteId}. ` + `DTI ID: ${layer.id}. Exists?: ${Boolean(manifest)}` ); diff --git a/src/server/types/Outfit.js b/src/server/types/Outfit.js index 251081f..89b22a9 100644 --- a/src/server/types/Outfit.js +++ b/src/server/types/Outfit.js @@ -235,7 +235,7 @@ const resolvers = { throw e; } - console.log(`Saved outfit ${newOutfitId}`); + console.info(`Saved outfit ${newOutfitId}`); return { id: newOutfitId }; },