Skip to content

Commit

Permalink
Merge pull request #77 from FacundoInza/fix/error-token-expired
Browse files Browse the repository at this point in the history
feat: Eslint without console.logs for production
  • Loading branch information
FacundoInza authored Oct 2, 2023
2 parents 03eb70f + 13ff294 commit 62b4122
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 41 deletions.
11 changes: 6 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended" // Agrega esta línea para utilizar las reglas de Prettier
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaFeatures": {
Expand All @@ -26,7 +26,7 @@
"sourceType": "module",
"requireConfigFile": false
},
"plugins": ["react", "cypress", "prettier"], // Agrega "prettier" a la lista de plugins
"plugins": ["react", "cypress", "prettier"],
"rules": {
"indent": ["warn", "tab"],
"linebreak-style": ["warn", "unix"],
Expand All @@ -36,7 +36,7 @@
"react/display-name": "off",
"react-hooks/exhaustive-deps": "off",
"react-hooks/rules-of-hooks": "error",
"prettier/prettier": "warn" // Asegúrate de activar la verificación de Prettier en ESLint
"prettier/prettier": "warn"
},
"overrides": [
{
Expand All @@ -46,7 +46,7 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended" // Agrega esta línea para utilizar las reglas de Prettier en TypeScript
"plugin:prettier/recommended"
],
"rules": {
"indent": ["warn", 4],
Expand All @@ -56,7 +56,8 @@
"@typescript-eslint/no-explicit-any": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"prettier/prettier": "warn" // Asegúrate de activar la verificación de Prettier en ESLint para TypeScript
"prettier/prettier": "warn",
"no-console": "error" // Agrega la regla para prohibir console.log en archivos JS
}
}
]
Expand Down
7 changes: 0 additions & 7 deletions app/error.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
'use client'; // Error components must be Client Components

import { useEffect } from 'react';
import React from 'react';
import Link from 'next/link';
import logo from '../assets/deliverit-full.png';
import Image from 'next/image';
import { Navbar } from '../components/ui/navbar';

export default function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
// Log the error to an error reporting service
console.error(error);
}, [error]);

return (
<>
<div className='min-h-screen bg-primary'>
Expand Down
1 change: 0 additions & 1 deletion components/commons/buttons/ButtonStartDay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const ButtonStartDay: FC<Props> = ({ enabled, isBlocked, blockUntil }) => {
setShowModal(false);
router.push('/dealer/home');
} catch (error: any) {
console.log(error);
const { message } = error.response.data.error.data;
setIsSuccess(false);
setButtonText('Ok');
Expand Down
11 changes: 3 additions & 8 deletions components/commons/buttons/CancelInteractiveButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ const CancelInteractiveButtons: FC<{ delivery: IDeliveryResponse }> = ({
const id = delivery.data._id;

const postponeDelivery = async () => {
console.log('postpone delivery called');
try {
const result = await api.put(`/api/delivery/${id}`, {
await api.put(`/api/delivery/${id}`, {
status: 'pending',
});
console.log('Postpone Result', result);

setModalMessage('Delivery postponed!');
setIsModalSuccess(true);
setShowModal(true);
} catch (error) {
console.log('Postpone Delivery error', error);
const axiosError = error as AxiosError<ErrorResponse>;
const errorMessage =
axiosError?.response?.data?.error?.data?.message ??
Expand All @@ -49,17 +47,14 @@ const CancelInteractiveButtons: FC<{ delivery: IDeliveryResponse }> = ({
}
};
const cancelDelivery = async () => {
console.log('cancel delivery called');
try {
const result = await api.put(`/api/delivery/${id}`, {
await api.put(`/api/delivery/${id}`, {
status: 'cancelled',
});
console.log('Cancel Result', result);
setModalMessage('Delivery cancelled!');
setIsModalSuccess(true);
setShowModal(true);
} catch (error) {
console.log('Cancel Delivery error', error);
setModalMessage((error as Error).message);
setIsModalSuccess(false);
setShowModal(true);
Expand Down
11 changes: 3 additions & 8 deletions components/commons/buttons/StartInteractiveButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ const StartInteractiveButtons: FC<{ delivery: IDeliveryResponse }> = ({
const id = delivery.data._id;

const startDelivery = async () => {
console.log('start delivery called');
try {
const result = await api.put(`/api/delivery/${id}`, {
await api.put(`/api/delivery/${id}`, {
status: 'on-course',
});
console.log('Start Result', result);

setModalMessage('Delivery started!');
setIsModalSuccess(true);
setShowModal(true);
} catch (error) {
console.log('Start Delivery error', error);
const axiosError = error as AxiosError<ErrorResponse>;
const errorMessage =
axiosError?.response?.data?.error?.data?.message ??
Expand All @@ -49,17 +47,14 @@ const StartInteractiveButtons: FC<{ delivery: IDeliveryResponse }> = ({
}
};
const completeDelivery = async () => {
console.log('complete delivery called');
try {
const result = await api.put(`/api/delivery/${id}`, {
await api.put(`/api/delivery/${id}`, {
status: 'delivered',
});
console.log('Complete Result', result);
setModalMessage('Delivery completed!');
setIsModalSuccess(true);
setShowModal(true);
} catch (error) {
console.log('Complete Delivery error', error);
setModalMessage((error as Error).message);
setIsModalSuccess(false);
setShowModal(true);
Expand Down
1 change: 0 additions & 1 deletion components/commons/switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const Switch: FC = () => {
const [isActive, setIsActive] = useState(false);

const toggle = () => {
console.log('Activated!');
setIsActive(!isActive);
};

Expand Down
9 changes: 2 additions & 7 deletions components/ui/locationMap/LocationMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ const LocationMap: FC<LocationMapProps> = ({
id: 'google-map-script',
googleMapsApiKey: apikey,
});

//eslint-disable-next-line
const [map, setMap] = useState<google.maps.Map | null>(null);

const [directions, setDirections] =
useState<google.maps.DirectionsResult | null>(null);

Expand All @@ -49,8 +50,6 @@ const LocationMap: FC<LocationMapProps> = ({
setMap(null);
}, []);

console.log('Map created', map);

useEffect(() => {
if (isLoaded && navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
Expand All @@ -69,10 +68,6 @@ const LocationMap: FC<LocationMapProps> = ({
(result, status) => {
if (status === google.maps.DirectionsStatus.OK) {
setDirections(result);
} else {
console.error(
`error fetching directions ${result}`
);
}
}
);
Expand Down
4 changes: 1 addition & 3 deletions components/ui/locationMap/SimpleLocationMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SimpleLocationMap: FC<LocationMapProps> = ({
id: 'google-map-script',
googleMapsApiKey: apikey,
});

//eslint-disable-next-line
const [map, setMap] = useState<google.maps.Map | null>(null);
const [showInfoWindow, setShowInfoWindow] = useState(true);

Expand All @@ -48,8 +48,6 @@ const SimpleLocationMap: FC<LocationMapProps> = ({
setMap(null);
}, []);

console.log('Map created', map);

return isLoaded ? (
<GoogleMap
mapContainerStyle={containerStyle}
Expand Down
1 change: 0 additions & 1 deletion components/ui/statusBadge/StatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const colorMap: ColorMap = {
export const StatusBadge: React.FC<BadgeProps> = ({ status }) => {
const color = colorMap[status];
if (!color) {
console.error(`Status desconocido: ${status}`);
return null;
}
return (
Expand Down

0 comments on commit 62b4122

Please sign in to comment.