From 693261cb5751e4aa4477b5d033ac230ad1e9dfba Mon Sep 17 00:00:00 2001 From: Arthur Green Date: Sun, 4 Aug 2024 15:44:04 +0400 Subject: [PATCH] chore: change import alias --- .eslintrc.yml | 2 +- README.md | 2 +- package.json | 2 +- pnpm-lock.yaml | 46 +++++------------------------- src/components/App.tsx | 6 ++-- src/components/PostPreview.tsx | 2 +- src/index.tsx | 14 ++++----- src/pages/index.tsx | 10 +++---- src/pages/posts/[postId]/edit.tsx | 6 ++-- src/pages/posts/[postId]/index.tsx | 4 +-- src/pages/posts/new.tsx | 4 +-- src/pages/users/[userName].tsx | 4 +-- tsconfig.json | 7 ++--- vite.config.ts | 12 ++------ 14 files changed, 40 insertions(+), 81 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 0262c802..8671c2cc 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -28,5 +28,5 @@ rules: settings: 'import/resolver': alias: - map: [['@components', './src/components']] + map: [['~/components', './src/components']] extensions: ['.ts', '.js', '.jsx', '.ts', '.tsx', '.json'] diff --git a/README.md b/README.md index 9db8a346..ae31d4cd 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ CRUD implemenation with React; - React - TypeScript -- TailwindCSS +- daisyUI & TailwindCSS - Storybook ## Contribution diff --git a/package.json b/package.json index efa80ebd..18b15b43 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a8462027..965f0b91 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^0.20.0 version: 0.20.0(react@18.2.0) daisyui: - specifier: ^2.50.0 - version: 2.50.0(autoprefixer@10.4.13(postcss@8.4.31))(postcss@8.4.31) + specifier: ^3.9.4 + version: 3.9.4 dexie: specifier: ^3.2.4 version: 3.2.4 @@ -3622,13 +3622,6 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - color-string@1.9.1: - resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} - - color@4.2.3: - resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} - engines: {node: '>=12.5.0'} - colord@2.9.3: resolution: {integrity: sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==} @@ -3868,11 +3861,9 @@ packages: csstype@3.1.1: resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==} - daisyui@2.50.0: - resolution: {integrity: sha512-KiqRvqMXi9rgoH84M8D69gXPg6x+cbdiaHqm8pFHOsXXN1rTl/+OcCKkSnkEwTtIge9VJVDGU6l4B8/n+Juc5g==} - peerDependencies: - autoprefixer: ^10.0.2 - postcss: ^8.1.6 + daisyui@3.9.4: + resolution: {integrity: sha512-fvi2RGH4YV617/6DntOVGcOugOPym9jTGWW2XySb5ZpvdWO4L7bEG77VHirrnbRUEWvIEVXkBpxUz2KFj0rVnA==} + engines: {node: '>=16.9.0'} damerau-levenshtein@1.0.8: resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} @@ -4946,9 +4937,6 @@ packages: is-arrayish@0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - is-arrayish@0.3.2: - resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} - is-async-function@2.0.0: resolution: {integrity: sha512-Y1JXKrfykRJGdlDwdKlLpLyMIiWqWvuSd17TvZk68PLAOGOoF4Xyav1z0Xhoi+gCYjZVeC5SI+hYFOfvXmGRCA==} engines: {node: '>= 0.4'} @@ -6825,9 +6813,6 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} - simple-swizzle@0.2.2: - resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} - sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} @@ -11968,16 +11953,6 @@ snapshots: color-name@1.1.4: {} - color-string@1.9.1: - dependencies: - color-name: 1.1.4 - simple-swizzle: 0.2.2 - - color@4.2.3: - dependencies: - color-convert: 2.0.1 - color-string: 1.9.1 - colord@2.9.3: {} combined-stream@1.0.8: @@ -12283,10 +12258,9 @@ snapshots: csstype@3.1.1: {} - daisyui@2.50.0(autoprefixer@10.4.13(postcss@8.4.31))(postcss@8.4.31): + daisyui@3.9.4: dependencies: - autoprefixer: 10.4.13(postcss@8.4.31) - color: 4.2.3 + colord: 2.9.3 css-selector-tokenizer: 0.8.0 postcss: 8.4.31 postcss-js: 4.0.1(postcss@8.4.31) @@ -13691,8 +13665,6 @@ snapshots: is-arrayish@0.2.1: {} - is-arrayish@0.3.2: {} - is-async-function@2.0.0: dependencies: has-tostringtag: 1.0.2 @@ -15722,10 +15694,6 @@ snapshots: signal-exit@4.1.0: {} - simple-swizzle@0.2.2: - dependencies: - is-arrayish: 0.3.2 - sisteransi@1.0.5: {} slash@3.0.0: {} diff --git a/src/components/App.tsx b/src/components/App.tsx index 9e661be8..a6c99a33 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -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({ diff --git a/src/components/PostPreview.tsx b/src/components/PostPreview.tsx index b1cd9b4f..7b4e9bff 100644 --- a/src/components/PostPreview.tsx +++ b/src/components/PostPreview.tsx @@ -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'; interface IAuthor { userId: string; diff --git a/src/index.tsx b/src/index.tsx index ae53eff8..aa43b231 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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')); +const NoMatch = lazy(async () => import('~/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')); +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 root = createRoot(document.getElementById('app')); diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 6c555457..249e551b 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -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'; +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'; function handleDeleteStory(id: string) { db.posts.delete(id); diff --git a/src/pages/posts/[postId]/edit.tsx b/src/pages/posts/[postId]/edit.tsx index efdd3522..0316c9bf 100644 --- a/src/pages/posts/[postId]/edit.tsx +++ b/src/pages/posts/[postId]/edit.tsx @@ -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; diff --git a/src/pages/posts/[postId]/index.tsx b/src/pages/posts/[postId]/index.tsx index 3e179aec..658965df 100644 --- a/src/pages/posts/[postId]/index.tsx +++ b/src/pages/posts/[postId]/index.tsx @@ -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(); diff --git a/src/pages/posts/new.tsx b/src/pages/posts/new.tsx index 6d914d71..6f2280c3 100644 --- a/src/pages/posts/new.tsx +++ b/src/pages/posts/new.tsx @@ -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); diff --git a/src/pages/users/[userName].tsx b/src/pages/users/[userName].tsx index d51fb434..1b405c41 100644 --- a/src/pages/users/[userName].tsx +++ b/src/pages/users/[userName].tsx @@ -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 ( diff --git a/tsconfig.json b/tsconfig.json index 466c4511..d228a4f5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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'. */ @@ -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"], } diff --git a/vite.config.ts b/vite.config.ts index 71f3a541..4e6f8d48 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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/', }, ], },