Skip to content

Commit

Permalink
chore: change import alias
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js committed Aug 4, 2024
1 parent 22bd099 commit 693261c
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ rules:
settings:
'import/resolver':
alias:
map: [['@components', './src/components']]
map: [['~/components', './src/components']]
extensions: ['.ts', '.js', '.jsx', '.ts', '.tsx', '.json']
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CRUD implemenation with React;

- React
- TypeScript
- TailwindCSS
- daisyUI & TailwindCSS
- Storybook

## Contribution
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
},
"dependencies": {
"@growthbook/growthbook-react": "^0.20.0",
"daisyui": "^2.50.0",
"daisyui": "^3.9.4",
"dexie": "^3.2.4",
"dexie-react-hooks": "^1.1.6",
"react": "^18.2.0",
Expand Down
46 changes: 7 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useEffect } from 'react';
import { Outlet, useLocation } from 'react-router-dom';
import { GrowthBook, GrowthBookProvider } from '@growthbook/growthbook-react';

import Header from '@components/Header';
import Alert from '@components/Alert';
import Breadcrumbs from '@components/Breadcrumbs';
import Header from '~/components/Header';
import Alert from '~/components/Alert';
import Breadcrumbs from '~/components/Breadcrumbs';

// Create a GrowthBook instance
const growthbook = new GrowthBook({
Expand Down
2 changes: 1 addition & 1 deletion src/components/PostPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';

import { db } from '@services/db';
import { db } from '~/services/db';

Check failure on line 5 in src/components/PostPreview.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/services/db"

interface IAuthor {
userId: string;
Expand Down
14 changes: 7 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { createBrowserRouter, RouterProvider, Link } from 'react-router-dom';

import './index.css';

const App = lazy(async () => import('@components/App'));
const Home = lazy(async () => import('@pages/index'));
const NoMatch = lazy(async () => import('@pages/[all]'));
const App = lazy(async () => import('~/components/App'));
const Home = lazy(async () => import('~/pages/index'));

Check failure on line 8 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/pages/index"
const NoMatch = lazy(async () => import('~/pages/[all]'));

Check failure on line 9 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/pages/[all]"

const NewPost = lazy(async () => import('@pages/posts/new'));
const BlogPost = lazy(async () => import('@pages/posts/[postId]'));
const EditPost = lazy(async () => import('@pages/posts/[postId]/edit'));
const UserInfo = lazy(async () => import('@pages/users/[userName]'));
const NewPost = lazy(async () => import('~/pages/posts/new'));

Check failure on line 11 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/pages/posts/new"
const BlogPost = lazy(async () => import('~/pages/posts/[postId]'));

Check failure on line 12 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/pages/posts/[postId]"
const EditPost = lazy(async () => import('~/pages/posts/[postId]/edit'));

Check failure on line 13 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/pages/posts/[postId]/edit"
const UserInfo = lazy(async () => import('~/pages/users/[userName]'));

Check failure on line 14 in src/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/pages/users/[userName]"

const root = createRoot(document.getElementById('app'));

Expand Down
10 changes: 5 additions & 5 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Fragment } from 'react';
import { useLiveQuery } from 'dexie-react-hooks';
import { useFeature } from '@growthbook/growthbook-react';

import { db } from '@services/db';
import PostPreview from '@components/PostPreview';
import Search from '@components/Search';
import { db } from '~/services/db';

Check failure on line 5 in src/pages/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

`~/services/db` import should occur after type import of `~/components/PostPreview`

Check failure on line 5 in src/pages/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/services/db"
import PostPreview from '~/components/PostPreview';
import Search from '~/components/Search';

import type { IBlogPost } from '@components/PostPreview';
import { timestampToLocaleString } from '@services/timestampToLocaleString';
import type { IBlogPost } from '~/components/PostPreview';
import { timestampToLocaleString } from '~/services/timestampToLocaleString';

Check failure on line 10 in src/pages/index.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Missing file extension for "~/services/timestampToLocaleString"

function handleDeleteStory(id: string) {
db.posts.delete(id);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/posts/[postId]/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { useState } from 'react';
import { redirect, useParams } from 'react-router-dom';
import { useLiveQuery } from 'dexie-react-hooks';

import { db } from '@services/db';
import { db } from '~/services/db';

import { Input } from '@components/Input';
import type { IBlogPost } from '@components/PostPreview';
import { Input } from '~/components/Input';
import type { IBlogPost } from '~/components/PostPreview';

interface IBlogPostProps {
post: IBlogPost;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/posts/[postId]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useNavigate, useParams } from 'react-router-dom';
import { useLiveQuery } from 'dexie-react-hooks';

import { db } from '@services/db';
import type { IBlogPost } from '@components/PostPreview';
import { db } from '~/services/db';
import type { IBlogPost } from '~/components/PostPreview';

function Post({ heading, text }: IBlogPost) {
const navigate = useNavigate();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/posts/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { v4 as uuidv4 } from 'uuid';

import { db } from '@services/db';
import { db } from '~/services/db';

import { Input } from '@components/Input';
import { Input } from '~/components/Input';

function getRandomInt(max: number) {
return Math.floor(Math.random() * max);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/users/[userName].tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useParams } from 'react-router-dom';
import { useLiveQuery } from 'dexie-react-hooks';

import { db } from '@services/db';
import type { IUser } from '@components/PostPreview';
import { db } from '~/services/db';
import type { IUser } from '~/components/PostPreview';

function Info({ name }: IUser) {
return (
Expand Down
7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
"moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": {
"@components/*": ["./src/components/*"],
"@pages/*": ["./src/pages/*"],
"@services/*": ["./src/services/*"]
"~/*": ["./src/*"],
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
Expand Down Expand Up @@ -103,5 +101,6 @@
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
},
"include": ["src"],
}
12 changes: 2 additions & 10 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,8 @@ export default defineConfig({
resolve: {
alias: [
{
find: '@components',
replacement: '/src/components',
},
{
find: '@pages',
replacement: '/src/pages',
},
{
find: '@services',
replacement: '/src/services',
find: '~/',
replacement: '/src/',
},
],
},
Expand Down

0 comments on commit 693261c

Please sign in to comment.