Skip to content

Commit

Permalink
chore: disallow the use of console.log (#1025)
Browse files Browse the repository at this point in the history
* chore: disallow the use of `console.log`

* chore: use `error` instead of `log`

* fix: remove lint check from build script

---------

Co-authored-by: Branko Bosnic <[email protected]>
Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2024
1 parent ecaa60a commit 504950e
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion api/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ module.exports = {
"no-compare-neg-zero": ["error"],
"no-cond-assign": ["error"],
"no-confusing-arrow": ["error"],
"no-console": ["off"],
"no-console": ["error", { allow: ["warn", "error"] }],
"no-const-assign": ["off"],
"no-constant-condition": ["error"],
"no-constructor-return": ["error"],
Expand Down
5 changes: 2 additions & 3 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
"build-clean": "rimraf ./dist/*",
"build-compile": "tsc",
"build-watch": "tsc --watch",
"build-lint": "eslint src --ext .tsx,.ts",
"format": "prettier --ignore-path=.prettierignore --write src && eslint --fix src",
"lint:check": "eslint src --ext .ts,.js",
"lint:check": "eslint src --ext .tsx,.ts,.js",
"format:check": "prettier --ignore-path=.prettierignore src",
"build-config": "copyfiles -u 2 ./src/data/config*.json ./dist/data/",
"build": "npm-run-all build-clean build-compile build-lint build-config",
"build": "npm-run-all build-clean build-compile build-config",
"serve-mon": "nodemon ./dist/index",
"start-dev": "NODE_ENV=development run-p serve-mon build-watch",
"start": "node ./dist/index"
Expand Down
3 changes: 2 additions & 1 deletion client/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rules: {
no-empty: off,
"@typescript-eslint/no-inferrable-types": off,
"@typescript-eslint/no-unused-vars": [2, { args: "none" }],
"@typescript-eslint/no-empty-function": off
"@typescript-eslint/no-empty-function": off,
"no-console": ["error", { allow: ["warn", "error"] }],
}

6 changes: 2 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
"start": "vite",
"preview": "vite preview",
"format": "prettier --ignore-path=.prettierignore --write src && eslint src --ext .tsx,.ts --fix",
"lint:check": "eslint src --ext .tsx,.ts",
"lint:check": "eslint src --ext .tsx,.ts && stylelint ./src/**/*.scss",
"format:check": "prettier --ignore-path=.prettierignore --check src",
"sass-lint": "stylelint ./src/**/*.scss",
"build-internal": "tsc && vite build",
"build": "run-s lint:check sass-lint build-internal",
"build": "tsc && vite build",
"test": "vitest"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions client/src/app/components/identity/DIDResolver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,17 @@ async function constructVerifiedDomains(resolvedDID: IDIDResolverResponse): Prom
reject(err);
}
} catch (err) {
console.log(err);
console.error(err);
reject(new Error(`Domain Linkage credential invalid domain ${domain}`));
}
})
.catch((err) => {
console.log(err);
console.error(err);
reject(new Error(`could not parse configuration from domain ${domain}`));
});
})
.catch((err) => {
console.log(err);
console.error(err);
reject(new Error(`could not fetch configuration from ${domain}, this could be a CORS error`));
});
}),
Expand Down
2 changes: 1 addition & 1 deletion client/src/helpers/hooks/useAddressHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function useAddressHistory(
}
return null;
} catch {
console.log("Failed loading transaction history details!");
console.error("Failed loading transaction history details!");
return null;
}
};
Expand Down
8 changes: 4 additions & 4 deletions client/src/helpers/hooks/useChartsState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ export function useChartsState(): [
setLedgerSize(graphsData.ledgerSizeDaily);
setStorageDeposit(graphsData.storageDepositDaily);
} else {
console.log("Fetching influx stats failed", influxStats.error);
console.error("Fetching influx stats failed", influxStats.error);
}
})
.catch((e) => console.log("Influx analytics fetch failed", e));
.catch((e) => console.error("Influx analytics fetch failed", e));

apiClient
.chronicleAnalytics({ network })
.then((analytics) => {
if (!analytics.error && analytics) {
setAnalyticStats(analytics);
} else {
console.log("Fetching chronicle stats failed", analytics.error);
console.error("Fetching chronicle stats failed", analytics.error);
}
})
.catch((e) => console.log("Chronicle analytics fetch failed", e));
.catch((e) => console.error("Chronicle analytics fetch failed", e));
}, [network]);

return [
Expand Down
2 changes: 1 addition & 1 deletion client/src/helpers/hooks/useChronicleAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function useChronicleAnalytics(network: string): [IAnalyticStats | null]
unclaimedShimmer: analyticStats?.unclaimedShimmer,
});
} else {
console.log("Analytics stats refresh failed.");
console.error("Analytics stats refresh failed.");
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/helpers/hooks/useOutputsDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function useOutputsDetails(network: string, outputIds: string[] | null):
setError(response.error);
}
})
.catch((e) => console.log(e));
.catch((e) => console.error(e));

promises.push(promise);
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/helpers/hooks/useParticipationEventDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function useParticipationEventDetails(participations?: IParticipation[]):
setError(response.error);
}
})
.catch((e) => console.log(e));
.catch((e) => console.error(e));

promises.push(promise);
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/helpers/hooks/useTokenDistributionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ export function useTokenDistributionState(): [IRichAddress[] | null, IDistributi
if (!response.error && response.distribution) {
setTokenDistribution(response.distribution);
} else {
console.log(`Fetching token distribution failed (${network})`, response.error);
console.error(`Fetching token distribution failed (${network})`, response.error);
}
})
.catch((e) => console.log(`Fetching token distribution failed (${network})`, e));
.catch((e) => console.error(`Fetching token distribution failed (${network})`, e));

apiClient
.richestAddresses({ network })
.then((response) => {
if (!response.error && response.top) {
setRichestAddresses(response.top);
} else {
console.log(`Fetching richest addresses failed (${network})`, response.error);
console.error(`Fetching richest addresses failed (${network})`, response.error);
}
})
.catch((e) => console.log(`Fetching richest addresses failed (${network})`, e));
.catch((e) => console.error(`Fetching richest addresses failed (${network})`, e));
}, [network]);

return [richestAddresses, tokenDistribution];
Expand Down
8 changes: 4 additions & 4 deletions client/src/services/stardust/stardustFeedClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class StardustFeedClient {

this.socket.on("subscribe", (subscribeResponse: IFeedSubscribeResponse) => {
if (subscribeResponse.error) {
console.log("Failed subscribing to feed", this._networkConfig?.network, subscribeResponse.error);
console.error("Failed subscribing to feed", this._networkConfig?.network, subscribeResponse.error);
} else {
this.blockSubscriptionId = subscribeResponse.subscriptionId;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ export class StardustFeedClient {
this.socket.emit("subscribe", subscribeRequest);
}
} catch (error) {
console.log("Failed subscribing to block feed", this._networkConfig?.network, error);
console.error("Failed subscribing to block feed", this._networkConfig?.network, error);
}
}

Expand Down Expand Up @@ -180,7 +180,7 @@ export class StardustFeedClient {

this.socket.on("subscribe", (subscribeResponse: IFeedSubscribeResponse) => {
if (subscribeResponse.error) {
console.log("Failed subscribing to feed", this._networkConfig?.network, subscribeResponse.error);
console.error("Failed subscribing to feed", this._networkConfig?.network, subscribeResponse.error);
} else {
this.milestoneSubscriptionId = subscribeResponse.subscriptionId;
}
Expand All @@ -193,7 +193,7 @@ export class StardustFeedClient {
});
}
} catch (error) {
console.log("Failed subscribing to milestone feed", this._networkConfig?.network, error);
console.error("Failed subscribing to milestone feed", this._networkConfig?.network, error);
}
}

Expand Down
4 changes: 2 additions & 2 deletions client/src/services/stardust/tokenRegistryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class TokenRegistryClient {
try {
response = await FetchHelper.json<unknown, IWhitelistedResponse>(endpoint, `${BASE_PATH}${network}${NFTS_PATH}${id}`, "get");
} catch (e) {
console.log("Failed to check token registry", e);
console.error("Failed to check token registry", e);
}

return response?.success ?? false;
Expand All @@ -56,7 +56,7 @@ export class TokenRegistryClient {
"get",
);
} catch (e) {
console.log("Failed to check token registry", e);
console.error("Failed to check token registry", e);
}

return response?.success ?? false;
Expand Down

0 comments on commit 504950e

Please sign in to comment.