Lint against console.log

and replace `console.log` instances in the codebase with better alternatives!
This commit is contained in:
Emi Matchu 2021-05-03 15:01:49 -07:00
parent 71a6dbdad7
commit ec3aa1747d
11 changed files with 27 additions and 14 deletions

View file

@ -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": [

View file

@ -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")

View file

@ -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(", ")})`
);

View file

@ -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!",

View file

@ -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) => {

View file

@ -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);
}
};

View file

@ -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];

View file

@ -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}`);
});
}

View file

@ -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 };

View file

@ -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)}`
);

View file

@ -235,7 +235,7 @@ const resolvers = {
throw e;
}
console.log(`Saved outfit ${newOutfitId}`);
console.info(`Saved outfit ${newOutfitId}`);
return { id: newOutfitId };
},