Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SAH-53]: Add pre-commit hooks for code linting and formatting #135

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/admin/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const baseConfig: Config = require("@sahil/configs/tailwind/tailwind.config");
const extendedConfig: Config = {
...baseConfig,
content: [
// @ts-expect-error
// @ts-ignore
...baseConfig.content,
"./src/Addresses/**/**.{js,ts,jsx,tsx,mdx}",
"./src/Agents/**/*.{js,ts,tsx,tsx,mdx}",
Expand Down
1 change: 1 addition & 0 deletions apps/agent/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const nextConfig = {
reactStrictMode: true,
transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs'],
output: "standalone",
images: {
remotePatterns: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const BusinessInfo = () => {

const router = useRouter();

const { formData } = useBusinessFormStore((state) => state);
//const { formData } = useBusinessFormStore((state) => state);
const onSubmit: SubmitHandler<FormData> = async (data) => {
const validatedInput = businessInfoSchema.parse(data);
};
Expand All @@ -36,7 +36,7 @@ export const BusinessInfo = () => {
<input
type="text"
className="input input-sm input-bordered w-full bg-gray-100"
placeholder="Keji's Foods"
placeholder="Keji Foods"
/>
</FormControl>
<div className="btn btn-sm btn-primary w-fit">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const BusinessStepsPaginator = ({
onNextStep,
onPrevStep,
}: Props) => {
const { steps, currentStep } = useBusinessFormStore((state) => state);
const { steps, currentStep } = useBusinessFormStore()((state) => state);
const currentIndex = steps.indexOf(currentStep);
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const courierContactSchema = z.object({
type FormData = z.infer<typeof courierContactSchema>;

export const CourierContactDetails = () => {
// @ts-ignore
const { goToStep, updateStepFormData } = useCourierFormStore((state) => ({
formData: state.formData,
goToStep: state.goToStep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { JoinGrid } from "ui";
import { HiArrowSmallLeft, HiArrowSmallRight } from "react-icons/hi2";

export const CourierFormStepPaginator = () => {
const { steps, goToStep, currentStep } = useCourierFormStore(
// @ts-ignore
const { steps, goToStep, currentStep } = useCourierFormStore()(
(state) => state
);
const router = useRouter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import toast, { Toaster } from "react-hot-toast";

export const CourierFormSummary = () => {
const router = useRouter();
const formData = useCourierFormStore((state) => state.formData);
const formData = useCourierFormStore()((state) => state.formData);

const { insertCourier, loading, error } = useRegisterCourier();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const courierInfoSchema = z.object({
type FormData = z.infer<typeof courierInfoSchema>;

export const CourierPersonalInfo = () => {
const { goToStep, updateStepFormData } = useCourierFormStore((state) => ({
const { goToStep, updateStepFormData } = useCourierFormStore()((state) => ({
formData: state.formData,
goToStep: state.goToStep,
updateStepFormData: state.updateStepFormData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const courierVehicleSchema = z.object({
type FormData = z.infer<typeof courierVehicleSchema>;

export const CourierVehicleInfo = () => {
const { goToStep, updateStepFormData } = useCourierFormStore((state) => ({
const { goToStep, updateStepFormData } = useCourierFormStore()((state) => ({
formData: state.formData,
goToStep: state.goToStep,
updateStepFormData: state.updateStepFormData,
Expand Down
1 change: 1 addition & 0 deletions apps/agent/src/Couriers/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const em = "";
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const DeliveryDetails = ({ navigateToNextStep }) => {
watch,
formState: { errors },
} = useForm<FormData>({
// @ts-expect-error
// @ts-ignore
resolver: zodResolver(deliveryDetailsSchema),
});
const onSubmit: SubmitHandler<FormData> = async (data) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/Orders/OrderProcessingForm/OrderSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const OrderSummary = () => {
watch,
formState: { errors },
} = useForm<FormData>({
// @ts-expect-error
// @ts-ignore
resolver: zodResolver(checkoutSchema),
});
const orderItems = useOrderItemsStore((state) => state.orderItems);
Expand Down
4 changes: 2 additions & 2 deletions apps/agent/src/Orders/ProductsCatalogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const ProductsCatalogue = () => {
<HiSignalSlash />
</span>
<p>
Products aren't loading due to a technical problem on our side. Please
try again. If the issue continues,{" "}
Products are not loading due to a technical problem on our side.
Please try again. If the issue continues,{" "}
<span className="text-primary">contact support.</span>
</p>
<div className="card-actions justify-end">
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/Suppliers/FilterSuppliersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const FilterSuppliersModal = () => {
<button
className="btn btn-sm normal-case"
onClick={() => {
// @ts-expect-error
// @ts-ignore
return document.getElementById("filter_suppliers_modal")?.showModal();
}}
>
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/Suppliers/SupplierProductForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const SupplierProductForm = ({
setValue,
formState: { errors },
} = useForm<ProductFormData>({
// @ts-expect-error
// @ts-ignore
resolver: zodResolver(supplierProductSchema),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const PreviewSupplierInfo = () => {
formState: { errors },
} = useForm<FormData>();
const router = useRouter();
const formData = useSupplierFormStore((state) => state.formData);
const formData = useSupplierFormStore()((state) => state.formData);

const { error, insertSupplier, loading, supplier } = useRegisterSupplier();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const supplierBasicInfoSchema = z.object({
type FormData = z.infer<typeof supplierBasicInfoSchema>;

export const SupplierBasicInfoForm = () => {
const { formData, goToStep, updateStepFormData } = useSupplierFormStore(
const { formData, goToStep, updateStepFormData } = useSupplierFormStore()(
(state) => ({
formData: state.formData,
goToStep: state.goToStep,
Expand All @@ -26,7 +26,7 @@ export const SupplierBasicInfoForm = () => {
handleSubmit,
formState: { errors },
} = useForm<FormData>({
// @ts-expect-error
// @ts-ignore
resolver: zodResolver(supplierBasicInfoSchema),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const supplierContactInfoSchema = z.object({
type FormData = z.infer<typeof supplierContactInfoSchema>;

export const SupplierBusinessInfoForm = () => {
const { currentStep, goToStep, updateStepFormData } = useSupplierFormStore(
const { currentStep, goToStep, updateStepFormData } = useSupplierFormStore()(
(state) => state
);
const {
Expand All @@ -24,7 +24,7 @@ export const SupplierBusinessInfoForm = () => {
watch,
formState: { errors },
} = useForm<FormData>({
// @ts-expect-error
// @ts-ignore
resolver: zodResolver(supplierContactInfoSchema),
});
const router = useRouter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const supplierPrefencesSchema = z.object({
type FormData = z.infer<typeof supplierPrefencesSchema>;

export const SupplierPreferencesForm = () => {
const { goToStep, updateStepFormData } = useSupplierFormStore((state) => ({
const { goToStep, updateStepFormData } = useSupplierFormStore()((state) => ({
goToStep: state.goToStep,
updateStepFormData: state.updateStepFormData,
}));
Expand All @@ -22,7 +22,7 @@ export const SupplierPreferencesForm = () => {
watch,
formState: { errors },
} = useForm<FormData>({
// @ts-expect-error
// @ts-ignore
resolver: zodResolver(supplierPrefencesSchema),
});
const router = useRouter();
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/hooks/suppliers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const useFetchSupplierProducts = (page: number = 0, id?: string) => {
// Memoize the result based on the page and ids
return useMemo(() => {
return { error, data: data?.products, loading };
}, [page, id, product, supplierId, error, data, loading]);
}, [error, data, loading]);
};

export const useRegisterSupplier = () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/agent/src/hooks/useBusinessFormStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ const steps = [
"summary",
] as const;

export const useBusinessFormStore = useCreateFormStore(INITIAL_STEP, steps);
export const useBusinessFormStore = () =>
useCreateFormStore(INITIAL_STEP, steps);
3 changes: 2 additions & 1 deletion apps/agent/src/hooks/useCourierFormStore.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { INITIAL_STEP, steps } from "@/Couriers/constants";
import { useCreateFormStore } from "@sahil/lib";

export const useCourierFormStore = useCreateFormStore(INITIAL_STEP, steps);
export const useCourierFormStore = () =>
useCreateFormStore(INITIAL_STEP, steps);
3 changes: 2 additions & 1 deletion apps/agent/src/hooks/useSupplierFormStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ const steps = [
"preview",
] as const;

export const useSupplierFormStore = useCreateFormStore(INITIAL_STEP, steps);
export const useSupplierFormStore = () =>
useCreateFormStore(INITIAL_STEP, steps);
3 changes: 1 addition & 2 deletions apps/agent/src/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-ignore
import { useEffect } from "react";
import type { NextPage } from "next";
import { getProviders, signIn, useSession } from "next-auth/react";
Expand All @@ -12,7 +11,7 @@ const SignInPage: NextPage = ({ providers }: any) => {
if (session) {
router.push("/auth/new");
}
}, [session]);
}, [router, session]);

return (
<div className="p-4">
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/pages/businesses/register/[...step].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const headers = [

export default function BusinessRegistrationPage() {
const { currentStep, goToStep, steps, updateStepByIndex } =
useBusinessFormStore((state) => state);
useBusinessFormStore()((state) => state);
const currentIndex = steps.indexOf(currentStep);
const router = useRouter();

Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/pages/couriers/register/[...step].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const headers = [

export default function CourierRegistrationPage() {
const { steps, currentStep, goToStep, updateStepByIndex } =
useCourierFormStore((state) => state);
useCourierFormStore()((state) => state);
const router = useRouter();
const params = useParams();
const currentIndex = steps.indexOf(currentStep);
Expand Down
4 changes: 2 additions & 2 deletions apps/agent/src/pages/suppliers/register/[[...step]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Card, IconButton } from "ui";
import { HiArrowSmallLeft, HiArrowSmallRight } from "react-icons/hi2";

const StepsPaginator = () => {
const { steps, goToStep, currentStep } = useSupplierFormStore(
const { steps, goToStep, currentStep } = useSupplierFormStore()(
(state) => state
);
const router = useRouter();
Expand Down Expand Up @@ -82,7 +82,7 @@ const headers = [
];

export default function SupplierRegistrationPage() {
const { steps, currentStep, updateStepByIndex } = useSupplierFormStore(
const { steps, currentStep, updateStepByIndex } = useSupplierFormStore()(
(state) => state
);
const router = useRouter();
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const baseConfig: Config = require("@sahil/configs/tailwind/tailwind.config");
const extendedConfig: Config = {
...baseConfig,
content: [
// @ts-expect-error
// @ts-ignore
...baseConfig.content,
"./src/Suppliers/**/**.{js,ts,jsx,tsx,mdx}",
"./src/Businesses/**/*.{js,ts,tsx,tsx,mdx}",
Expand Down
1 change: 1 addition & 0 deletions apps/client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const nextConfig = {
reactStrictMode: true,
transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs'],
output: "standalone",
images: {
remotePatterns: [
{
Expand Down
23 changes: 17 additions & 6 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,33 @@
"lint": "next lint"
},
"dependencies": {
"@apollo/client": "^3.8.10",
"@formkit/auto-animate": "^0.8.1",
"@hookform/resolvers": "^3.3.4",
"@react-google-maps/api": "^2.19.2",
"@sahil/configs": "*",
"@sahil/lib": "*",
"daisyui": "^4.6.0",
"date-fns": "^3.2.0",
"graphql": "^16.8.1",
"next": "14.0.1",
"react": "^18",
"react-dom": "^18",
"next": "14.0.1",
"react-hook-form": "^7.49.3",
"react-icons": "^5.0.1",
"ui": "*",
"@sahil/lib": "*",
"@sahil/configs": "*"
"zod": "^3.22.4",
"zustand": "^4.4.7"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.1",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"eslint": "^8",
"eslint-config-next": "14.0.1"
"typescript": "^5"
}
}
10 changes: 5 additions & 5 deletions apps/client/src/Products/ProductsCatalogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export const ProductsCatalogue = () => {
orderItems,
setProducts,
products: availableProducts,
} = useOrderItemsStore((state) => state);
} = useOrderItemsStore((state: any) => state);

const orderItemsMap = new Map(
orderItems.map((item) => [item.productId, item])
orderItems.map((item: any) => [item.productId, item])
);

useEffect(() => {
Expand All @@ -49,8 +49,8 @@ export const ProductsCatalogue = () => {
<HiSignalSlash />
</span>
<p>
Products aren't loading due to a technical problem on our side. Please
try again. If the issue continues,{" "}
Products are not loading due to a technical problem on our side.
Please try again. If the issue continues,{" "}
<span className="text-primary">contact support.</span>
</p>
<div className="card-actions justify-end">
Expand Down Expand Up @@ -104,7 +104,7 @@ export const ProductsCatalogue = () => {
error={error}
loading={loading}
cols={4}
renderItem={(product) => {
renderItem={(product: any) => {
const isInCart = orderItemsMap.has(product.id);
return (
<ProductSummary
Expand Down
4 changes: 2 additions & 2 deletions apps/client/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const baseConfig: Config = require("@sahil/configs/tailwind/tailwind.config");
const extendedConfig: Config = {
...baseConfig,
content: [
// @ts-expect-error
// @ts-ignore
...baseConfig.content,
"./src/Addresses/**/**.{js,ts,jsx,tsx,mdx}",
"./src/Maps/**/*.{js,ts,tsx,tsx,mdx}",
Expand All @@ -23,7 +23,7 @@ const extendedConfig: Config = {
...baseConfig.theme?.extend,
},
},
// @ts-expect-error
// @ts-ignore
plugins: [...baseConfig.plugins, require("daisyui")],
daisyui: {
themes: [
Expand Down
Loading