From ce6bf90b00a5df835258cda9976c9909e4226f9a Mon Sep 17 00:00:00 2001 From: thomasgross Date: Fri, 10 Jan 2025 12:23:09 +0100 Subject: [PATCH] fix: re-introduce no-console rule for debug statements but allow console.error in ESLint --- eslint.config.mjs | 1 + src/apps/material-grid/MaterialGrid.tsx | 1 + src/apps/material-search/useGetHiddenInputs.tsx | 2 ++ src/apps/material-search/useUpdateFields.ts | 1 + src/apps/opening-hours-editor/helper.ts | 1 + src/components/guarded-app.tsx | 4 ++++ src/core/guardedRequests.slice.ts | 2 ++ src/core/statistics/useStatistics.ts | 1 + 8 files changed, 13 insertions(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index 078b5d9c0c..283a695d3a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -85,6 +85,7 @@ export default [ }, rules: { + "no-console": ["error", { allow: ["error"] }], "prefer-arrow-callback": [ "error", { diff --git a/src/apps/material-grid/MaterialGrid.tsx b/src/apps/material-grid/MaterialGrid.tsx index 6fd23f7606..8f5f741341 100644 --- a/src/apps/material-grid/MaterialGrid.tsx +++ b/src/apps/material-grid/MaterialGrid.tsx @@ -60,6 +60,7 @@ const MaterialGrid: React.FC = ({ } if (!materials.length) { + // eslint-disable-next-line no-console console.warn(`No materials to show for MaterialGrid: ${title}`); return null; } diff --git a/src/apps/material-search/useGetHiddenInputs.tsx b/src/apps/material-search/useGetHiddenInputs.tsx index 4309cb5df8..d70fd53cdf 100644 --- a/src/apps/material-search/useGetHiddenInputs.tsx +++ b/src/apps/material-search/useGetHiddenInputs.tsx @@ -24,6 +24,7 @@ const useGetHiddenInputs = (uniqueIdentifier: string): HiddenInputsResult => { ) as HTMLInputElement | null; if (!workElement) { + // eslint-disable-next-line no-console console.debug( `Could not find input for work ID with unique identifier: ${uniqueIdentifier}` ); @@ -33,6 +34,7 @@ const useGetHiddenInputs = (uniqueIdentifier: string): HiddenInputsResult => { } if (!materialElement) { + // eslint-disable-next-line no-console console.debug( `Could not find input for material type with unique identifier: ${uniqueIdentifier}` ); diff --git a/src/apps/material-search/useUpdateFields.ts b/src/apps/material-search/useUpdateFields.ts index 084b458e28..13d9259c2f 100644 --- a/src/apps/material-search/useUpdateFields.ts +++ b/src/apps/material-search/useUpdateFields.ts @@ -41,6 +41,7 @@ const useUpdateFields = ({ } // Leaving a debug message hif the input element is not found. + // eslint-disable-next-line no-console console.debug( `Could not find input element to update with ID: ${uniqueIdentifier}` ); diff --git a/src/apps/opening-hours-editor/helper.ts b/src/apps/opening-hours-editor/helper.ts index 8688bd6b84..79875b3799 100644 --- a/src/apps/opening-hours-editor/helper.ts +++ b/src/apps/opening-hours-editor/helper.ts @@ -188,6 +188,7 @@ export const getInitialDateFromUrl = (): Date | null => { return date; } + // eslint-disable-next-line no-console console.debug( "Invalid date format in URL parameter: initialDate =", initialDateString diff --git a/src/components/guarded-app.tsx b/src/components/guarded-app.tsx index 9ade184032..47462d249c 100644 --- a/src/components/guarded-app.tsx +++ b/src/components/guarded-app.tsx @@ -31,6 +31,7 @@ const GuardedApp = ({ app, children }: GuardedAppProps) => { const didAuthenticate = getUrlQueryParam(AUTH_PARAM); // We'll leave this debugging here temporarily also in the testing phase for troubleshooting. + // eslint-disable-next-line no-console console.debug("PERSISTED REQUEST:", persistedRequest); useEffect(() => { @@ -39,8 +40,11 @@ const GuardedApp = ({ app, children }: GuardedAppProps) => { } // We'll leave this debugging here temporarily also in the testing phase for troubleshooting. + // eslint-disable-next-line no-console console.debug("HAS REQUEST EXPIRED?", hasRequestExpired(persistedRequest)); + // eslint-disable-next-line no-console console.debug("CURRENT TIMESTAMP", getCurrentUnixTime()); + // eslint-disable-next-line no-console console.debug("EXPIRE TIMESTAMP", persistedRequest.expire); // If request has expired remove it. diff --git a/src/core/guardedRequests.slice.ts b/src/core/guardedRequests.slice.ts index 5c7cc7201a..d5dcc76d07 100644 --- a/src/core/guardedRequests.slice.ts +++ b/src/core/guardedRequests.slice.ts @@ -109,6 +109,7 @@ export const guardedRequest = createAsyncThunk( } // We'll leave this debugging here temporarily also in the testing phase for troubleshooting. + // eslint-disable-next-line no-console console.debug("PERFORMING REQUEST CALLBACK"); // The user is authorized to perform callback. Let's do it! const requestCallback = getRequestCallback(type); @@ -125,6 +126,7 @@ export const reRunRequest = createAsyncThunk( if (requestCallbackExists(type)) { const requestCallback = getRequestCallback(type); // We'll leave this debugging here temporarily also in the testing phase for troubleshooting. + // eslint-disable-next-line no-console console.debug("RERUNNING REQUEST"); return requestCallback(args); } diff --git a/src/core/statistics/useStatistics.ts b/src/core/statistics/useStatistics.ts index e58e5a8c96..aab65c64bf 100644 --- a/src/core/statistics/useStatistics.ts +++ b/src/core/statistics/useStatistics.ts @@ -36,6 +36,7 @@ export function useStatistics() { if (!window.wts) { window.wts = { push(trackingProps: [EventAction, EventType, EventData]) { + // eslint-disable-next-line no-console console.log( `Tracking: ${trackingProps[0]}, ${trackingProps[1]}, ${JSON.stringify( trackingProps[2]