Skip to content

Commit

Permalink
style: get rid of non necessary async
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js committed Aug 23, 2024
1 parent 7f63706 commit 1f114c4
Show file tree
Hide file tree
Showing 17 changed files with 808 additions and 574 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ rules:
'@typescript-eslint/explicit-function-return-type': 'off'
'@typescript-eslint/no-floating-promises': 'off'
unicorn/filename-case: ['error', { 'case': 'kebabCase' }]
'require-await': 'error'
settings:
'import/resolver':
alias:
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@
"@storybook/react-vite": "^8.0.10",
"@storybook/testing-library": "^0.2.2",
"@tailwindcss/typography": "^0.5.7",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vanilla-extract/vite-plugin": "^4.0.15",
"@vitejs/plugin-react-swc": "~3.7.0",
"autoprefixer": "^10.4.13",
"browserslist": "~4.22.1",
Expand Down Expand Up @@ -79,11 +80,12 @@
},
"dependencies": {
"@growthbook/growthbook-react": "^0.20.0",
"@vanilla-extract/css": "^1.15.5",
"daisyui": "^3.9.4",
"dexie": "^3.2.4",
"dexie-react-hooks": "^1.1.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.15.0",
"theme-change": "^2.5.0",
"uuid": "^9.0.0"
Expand All @@ -93,7 +95,7 @@
],
"engines": {
"node": ">=20.9",
"pnpm": ">=8.10"
"pnpm": ">=9.8"
},
"msw": {
"workerDirectory": "public"
Expand All @@ -103,5 +105,5 @@
"plugin:storybook/recommended"
]
},
"packageManager": "pnpm@9.6.0"
"packageManager": "pnpm@9.8.0"
}
1,273 changes: 746 additions & 527 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function App() {
import.meta.env.VITE_GROWTH_BOOK_KEY
}`,
)
.then(async (res) => res.json())
.then((res) => res.json())
.then((json) => {
growthbook.setFeatures(json.features);
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMatches } from 'react-router-dom';

Check failure on line 1 in src/components/Breadcrumbs.tsx

View workflow job for this annotation

GitHub Actions / lint (20)

Filename is not in kebab case. Rename it to `breadcrumbs.tsx`

import classes from './breadcrumbs.module.css';
import { breadcrumbs, crumb as StCrumb } from './breadcrumbs.css';

function Breadcrumbs() {
const matches = useMatches();
Expand All @@ -13,10 +13,10 @@ function Breadcrumbs() {

return (
<div className="container mx-auto px-4">
<ol className={classes.breadcrumbs}>
<ol className={breadcrumbs}>
{crumbs.map((crumb, index) => (
// eslint-disable-next-line react/no-array-index-key
<li className={classes.crumb} key={index}>
<li className={StCrumb} key={index}>
{crumb}
</li>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function App() {
import.meta.env.VITE_GROWTH_BOOK_KEY
}`,
)
.then(async (res) => res.json())
.then((res) => res.json())
.then((json) => {
growthbook.setFeatures(json.features);
});
Expand Down
29 changes: 29 additions & 0 deletions src/components/breadcrumbs.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { style } from '@vanilla-extract/css';

export const breadcrumbs = style({
display: 'flex',
flexDirection: 'row',
gap: '0.4rem',
});

export const crumb = style({
selectors: {
'&:last-child::after': {
content: '',
},
'&::after': {
content: '>',
marginLeft: '0.4rem',
},
},
// &::after {
// content: '>';
// margin-left: 0.4rem;
// }

// &:last-child {
// &::after {
// content: '';
// }
// }
});
18 changes: 0 additions & 18 deletions src/components/breadcrumbs.module.css

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMatches } from 'react-router-dom';

import classes from './breadcrumbs.module.css';
import { breadcrumbs, crumb as StCrumb } from './breadcrumbs.css';

function Breadcrumbs() {
const matches = useMatches();
Expand All @@ -13,10 +13,10 @@ function Breadcrumbs() {

return (
<div className="container mx-auto px-4">
<ol className={classes.breadcrumbs}>
<ol className={breadcrumbs}>
{crumbs.map((crumb, index) => (
// eslint-disable-next-line react/no-array-index-key
<li className={classes.crumb} key={index}>
<li className={StCrumb} key={index}>
{crumb}
</li>
))}
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(() => import('~/components/app'));
const Home = lazy(() => import('~/pages/index'));
const NoMatch = lazy(() => 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/[user-name]'));
const NewPost = lazy(() => import('~/pages/posts/new'));
const BlogPost = lazy(() => import('~/pages/posts/[postId]'));
const EditPost = lazy(() => import('~/pages/posts/[postId]/edit'));
const UserInfo = lazy(() => import('~/pages/users/[user-name]'));

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

Expand Down
2 changes: 1 addition & 1 deletion src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { rest } from 'msw';
import postsJson from './posts.json';

export const handlers = [
rest.get('/posts', async (req, res, ctx) =>
rest.get('/posts', (req, res, ctx) =>
res(ctx.status(200), ctx.json(postsJson)),
),
];
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function handleDeleteStory(id: string) {
}

export function PostList() {
const posts = useLiveQuery(async () =>
const posts = useLiveQuery(() =>
db.posts
// .where('text')
// .anyOf(['The'])
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/[postId]/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function EditPost({ post }: IBlogPostProps) {

function EditPostWrapper() {
const { postId } = useParams();
const posts = useLiveQuery(async () =>
const posts = useLiveQuery(() =>
db.posts.filter(({ id }) => id === Number(postId)).toArray(),
);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/[postId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Post({ heading, text }: IBlogPost) {

function BlogPost() {
const { postId } = useParams();
const postArr = useLiveQuery(async () =>
const postArr = useLiveQuery(() =>
db.posts.filter(({ id }) => id === Number(postId)).toArray(),
);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/users/[user-name].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Info({ name }: IUser) {

function UserInfo() {
const { userName } = useParams();
const authorArr = useLiveQuery(async () =>
const authorArr = useLiveQuery(() =>
db.authors.filter(({ username }) => username === userName).toArray(),
);

Expand Down
4 changes: 2 additions & 2 deletions src/services/get-stories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const getStories = async (url: string) =>
export const getStories = (url: string) =>
fetch(url)
.then(async (response) => response.json())
.then((response) => response.json())
.then((data) => data.result);

export default getStories;
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import { VitePWA } from 'vite-plugin-pwa';
// import browserslist from 'browserslist';
// import { browserslistToTargets } from 'lightningcss';
Expand All @@ -16,7 +17,7 @@ export default defineConfig({
emptyOutDir: true,
cssMinify: 'lightningcss',
},
plugins: [react(), VitePWA({})],
plugins: [react(), VitePWA({}), vanillaExtractPlugin()],
define: {
APP_VERSION: JSON.stringify(process.env.npm_package_version),
},
Expand Down

0 comments on commit 1f114c4

Please sign in to comment.