Skip to content

Commit

Permalink
Use Path Aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasCode92 authored Nov 24, 2024
1 parent 6205a55 commit 3f2320c
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/api/category.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import categoryData from "../data/categories.json";
import categoryData from "@/data/categories.json";

export function getCategories() {
return categoryData;
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoryList.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from "@testing-library/react";

import { ICategory } from "../models/Category";
import { ICategory } from "@/models/Category";
import CategoryList from "./CategoryList";

const categories: ICategory[] = [
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoryList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CategoryListItem from "./CategoryListItem";

import { ICategory } from "../models/Category";
import { ICategory } from "@/models/Category";

interface CategoryListProps {
categories: ICategory[];
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoryListItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from "@testing-library/react";

import { ICategory } from "../models/Category";
import { ICategory } from "@/models/Category";
import CategoryListItem from "./CategoryListItem";

const category: ICategory = { id: 1, title: "hats", imageUrl: "some-url" };
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoryListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ICategory } from "../models/Category";
import { ICategory } from "@/models/Category";

interface CategoryItemProps {
category: ICategory;
Expand Down
2 changes: 1 addition & 1 deletion src/components/NavigationBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Link } from "react-router-dom";

import CrownLogo from "../assets/crown.svg";
import CrownLogo from "@/assets/crown.svg";

export default function NavigationBar() {
return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/UI/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ButtonHTMLAttributes, ReactNode } from "react";
import tw from "../../utils/tw-identity";

import tw from "@/utils/tw-identity";

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
children: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion src/components/UI/FormInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InputHTMLAttributes } from "react";

import tw from "../../utils/tw-identity";
import tw from "@/utils/tw-identity";

interface FormInputProps extends InputHTMLAttributes<HTMLInputElement> {
label: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/authentication/SignInForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const mockedMethods = vi.hoisted(function () {
};
});

vi.mock("../../utils/firebase", function () {
vi.mock("@/utils/firebase", function () {
return {
signInAuthUserWithEmailAndPassword: mockedMethods.signInAuthUserFn,
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/authentication/SignInForm.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { AuthError, getRedirectResult } from "firebase/auth";
import { ChangeEvent, FormEvent, useEffect, useState } from "react";

import Button from "../UI/Button";
import FormInput from "../UI/FormInput";
import Button from "@/components/UI/Button";
import FormInput from "@/components/UI/FormInput";

import {
auth,
createUserDocumentFromAuth,
signInAuthUserWithEmailAndPassword,
signInWithGooglePopup,
signInWithGoogleRedirect,
} from "../../utils/firebase";
} from "@/utils/firebase";

const INITIAL_FORM_FIELDS = {
email: "",
Expand Down
2 changes: 1 addition & 1 deletion src/components/authentication/SignUpForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const mockedMethods = vi.hoisted(function () {
};
});

vi.mock("../../utils/firebase", function () {
vi.mock("@/utils/firebase", function () {
return {
createAuthUserWithEmailAndPassword: mockedMethods.createAuthUserFn,
createUserDocumentFromAuth: mockedMethods.createUserDocumentFn,
Expand Down
6 changes: 3 additions & 3 deletions src/components/authentication/SignUpForm.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AuthError } from "firebase/auth";
import { ChangeEvent, FormEvent, useState } from "react";

import Button from "../UI/Button";
import FormInput from "../UI/FormInput";
import Button from "@/components/UI/Button";
import FormInput from "@/components/UI/FormInput";

import {
createAuthUserWithEmailAndPassword,
createUserDocumentFromAuth,
} from "../../utils/firebase";
} from "@/utils/firebase";

const INITIAL_FORM_FIELDS = {
displayName: "",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/AuthenticationPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SignInForm from "../components/authentication/SignInForm";
import SignUpForm from "../components/authentication/SignUpForm";
import SignInForm from "@/components/authentication/SignInForm";
import SignUpForm from "@/components/authentication/SignUpForm";

export default function AuthenticationPage() {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/HomePage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { render } from "@testing-library/react";

import * as CategoryList from "../components/CategoryList";
import * as CategoryList from "@/components/CategoryList";
import HomePage from "./HomePage";

import { ICategory } from "../models/Category";
import { ICategory } from "@/models/Category";

const { categories } = vi.hoisted(function () {
const categories: ICategory[] = [
Expand Down
4 changes: 2 additions & 2 deletions src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useLoaderData } from "react-router-dom";

import CategoryList from "../components/CategoryList";
import CategoryList from "@/components/CategoryList";

import { ICategory } from "../models/Category";
import { ICategory } from "@/models/Category";

export default function HomePage() {
const categories = useLoaderData() as ICategory[];
Expand Down
3 changes: 2 additions & 1 deletion src/pages/layouts/RootLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Fragment } from "react";
import { Outlet } from "react-router-dom";
import NavigationBar from "../../components/NavigationBar";

import NavigationBar from "@/components/NavigationBar";

export default function RootLayout() {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/utils/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
setDoc,
} from "firebase/firestore";

import firebaseApp from "../config/firebase";
import firebaseApp from "@/config/firebase";

const FIREBASE_AUTH_EMULATOR = import.meta.env.VITE_FIREBASE_AUTH_EMULATOR_HOST;

Expand Down
3 changes: 3 additions & 0 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,

"baseUrl": ".",
"paths": { "@/*": ["src/*"] },

"types": ["vitest/globals", "@testing-library/jest-dom"]
},
"include": ["src"]
Expand Down
7 changes: 7 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/// <reference types="vitest" />

import path from "path";

import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import svgr, { VitePluginSvgrOptions } from "vite-plugin-svgr";
Expand All @@ -22,4 +24,9 @@ export default defineConfig({
setupFiles: "./tests/setup.ts",
exclude: [...configDefaults.exclude, "./firebase", "./config"],
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});

0 comments on commit 3f2320c

Please sign in to comment.