Skip to content

Commit

Permalink
ci: migrate to use biome for formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbrusegard committed Aug 22, 2024
1 parent 1a1dd3b commit 49a5745
Show file tree
Hide file tree
Showing 32 changed files with 92 additions and 409 deletions.
53 changes: 0 additions & 53 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bunx lint-staged
bunx biome check --staged --write --unsafe
9 changes: 0 additions & 9 deletions .vscode/extensions.json

This file was deleted.

11 changes: 0 additions & 11 deletions .vscode/settings.json

This file was deleted.

34 changes: 34 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"formatter": {
"enabled": true,
"indentStyle": "space"
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"nursery": {
"useSortedClasses": "warn"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "single"
}
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"ignore": [".next"]
}
}
Binary file modified bun.lockb
Binary file not shown.
21 changes: 2 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@
"prebuild": "next telemetry disable",
"build": "next build",
"dev": "next dev --turbo",
"lint": "next lint && prettier --write .",
"lint": "biome check --write --unsafe",
"start": "next start"
},
"lint-staged": {
"*.{js,ts,tsx}": [
"eslint --fix",
"prettier --write"
]
},
"dependencies": {
"@libsql/client": "^0.6.2",
"@radix-ui/react-avatar": "^1.1.0",
Expand All @@ -32,7 +26,6 @@
"@trpc/react-query": "^10.45.2",
"@trpc/server": "^10.45.2",
"autoprefixer": "^10.4.19",
"clsx": "^2.1.1",
"country-flag-icons": "^1.5.12",
"cva": "^1.0.0-beta.1",
"drizzle-orm": "^0.31.2",
Expand All @@ -52,22 +45,12 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/eslint": "^8.56.10",
"@biomejs/biome": "1.8.3",
"@types/node": "^20.14.8",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"drizzle-kit": "^0.22.7",
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-drizzle": "^0.2.3",
"lint-staged": "^15.2.7",
"postcss": "^8.4.38",
"prettier": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.5",
"tailwind-scrollbar": "^3.1.0",
"tailwindcss": "^3.4.4",
"tailwindcss-animate": "^1.0.7",
Expand Down
23 changes: 0 additions & 23 deletions prettier.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/[locale]/(dashboard)/news/(header)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { articleMockData as articleData } from '@/mock-data/article';
import { useTranslations } from 'next-intl';
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server';
import { createSearchParamsCache, parseAsInteger } from 'nuqs/parsers';
import { createSearchParamsCache, parseAsInteger } from 'nuqs/server';
import { Suspense } from 'react';

import { PaginationCarousel } from '@/components/layout/PaginationCarousel';
Expand Down
12 changes: 8 additions & 4 deletions src/app/[locale]/(dashboard)/news/[article]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ export default function Article({
return notFound();
}

const { minutes } = readingTime(article.content!);
const author = authorData[0]!;
const { minutes } = readingTime(article.content as string); // assert because its a mock data file
const author = authorData[0] as {
name: string;
photoUrl: string;
initials: string;
}; // same as above
return (
<article>
<header>
<div className='mb-10 mt-5 flex justify-center'>
<div className='mt-5 mb-10 flex justify-center'>
<Image
className='h-auto w-full max-w-4xl rounded-lg'
src={`/${article.photoUrl}`}
Expand Down Expand Up @@ -79,7 +83,7 @@ export default function Article({
</small>
</div>
</div>
<Badge variant='secondary'>{article.views + ' ' + t('views')}</Badge>
<Badge variant='secondary'>{`${article.views} ${t('views')}`}</Badge>
</section>
<section className='my-6'>{article.content}</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function Localelayout({
>
<body className='h-full w-full bg-background font-inter text-foreground antialiased'>
<RootProviders locale={locale}>
<div className='fixed bottom-0 top-0 flex h-full w-full flex-col overflow-y-scroll scroll-smooth scrollbar-thin scrollbar-track-background scrollbar-thumb-primary/40 scrollbar-corner-background scrollbar-thumb-rounded-lg hover:scrollbar-thumb-primary/80'>
<div className='scrollbar-thin scrollbar-track-background scrollbar-thumb-primary/40 scrollbar-corner-background scrollbar-thumb-rounded-lg hover:scrollbar-thumb-primary/80 fixed top-0 bottom-0 flex h-full w-full flex-col overflow-y-scroll scroll-smooth'>
{children}
</div>
</RootProviders>
Expand Down
2 changes: 1 addition & 1 deletion src/components/assets/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Logo({ className, ...rest }: { className?: string }) {
d='M46.697,71.821l-1.193-2.641l4.751-1.918l-0.56-9.096c-0.026-0.418,0.131-0.826,0.43-1.121l6.133-6.028 c0.299-0.295,0.71-0.447,1.131-0.411l9.086,0.732l1.573-3.699l-6.829-6.041c-0.315-0.278-0.493-0.68-0.49-1.1l0.093-8.594 c0.004-0.42,0.19-0.817,0.511-1.089l6.938-5.893l-1.507-3.734l-9.085,0.558c-0.418,0.03-0.828-0.131-1.122-0.43l-6.029-6.131 c-0.294-0.299-0.444-0.713-0.411-1.132l0.734-9.085l-3.709-1.575l-6.033,6.822c-0.278,0.314-0.645,0.512-1.099,0.489l-8.604-0.082 c-0.419-0.004-0.816-0.19-1.088-0.51l-5.904-6.931l-3.725,1.499l0.559,9.085c0.03,0.5-0.254,0.915-0.608,1.27 c-1.073,1.074-5.148,5.041-5.813,5.705c-0.354,0.354-0.773,0.634-1.281,0.586L4.47,20.602l-1.575,3.699l6.819,6.022 c0.315,0.279,0.494,0.68,0.49,1.1l-0.082,8.614c-0.004,0.42-0.189,0.817-0.51,1.09L2.673,47.03l1.507,3.726l9.096-0.56 c0.415-0.035,0.829,0.132,1.123,0.431l6.019,6.142c0.294,0.301,0.443,0.713,0.409,1.133l-0.732,9.064l4.67,1.992l-1.136,2.664 l-5.631-2.401c-0.574-0.244-0.927-0.828-0.875-1.449l0.766-9.446l-5.096-5.197L3.316,53.71c-0.619,0.022-1.198-0.324-1.432-0.902 l-2.289-5.661C-0.638,46.569-0.475,45.905,0,45.5l7.232-6.153l0.069-7.291l-7.107-6.276c-0.468-0.413-0.618-1.078-0.374-1.653 l2.392-5.619c0.243-0.574,0.82-0.934,1.448-0.877l9.325,0.744c0.986-0.986,4.042-3.944,5.322-5.224l-0.574-9.336 c-0.039-0.621,0.326-1.199,0.905-1.432l5.659-2.279c0.578-0.232,1.239-0.069,1.645,0.405l6.151,7.222l7.282,0.07l6.286-7.108 c0.412-0.467,1.077-0.619,1.65-0.374l5.632,2.391c0.574,0.244,0.929,0.828,0.877,1.45l-0.765,9.467l5.102,5.188l9.469-0.582 c0.625-0.045,1.199,0.325,1.432,0.903l2.29,5.671c0.232,0.578,0.068,1.242-0.406,1.646l-7.232,6.143l-0.076,7.271l7.114,6.295 c0.468,0.414,0.617,1.079,0.374,1.651l-2.392,5.621c-0.244,0.574-0.823,0.921-1.45,0.877l-9.465-0.764l-5.189,5.101l0.584,9.478 c0.039,0.625-0.326,1.201-0.905,1.435L46.697,71.821z'
/>
<path
className='fill-foreground-primary dark dark:fill-foreground'
className='dark fill-foreground-primary dark:fill-foreground'
d='M33.593,77.743l13.104-5.923l-1.192-2.64l-13.061,5.902l-0.002-0.002l-2.549,1.047l-3.007-1.503 c-0.557-0.278-1.23-0.169-1.671,0.271l-1.717,1.716c-0.443,0.44-0.552,1.116-0.272,1.673l1.453,2.904 c-0.345,0.658-0.631,1.35-0.855,2.072l-3.08,1.022c-0.593,0.196-0.991,0.751-0.991,1.374v2.423c0,0.623,0.398,1.177,0.988,1.373 l3.196,1.071l0.794,1.923l-1.506,3.017c-0.278,0.561-0.167,1.234,0.276,1.676l1.717,1.707c0.44,0.436,1.112,0.545,1.668,0.268 l3.006-1.504l1.936,0.802l1.059,3.185c0.196,0.592,0.75,0.99,1.372,0.99h2.423c0.623,0,1.176-0.396,1.374-0.988l1.068-3.187 l1.927-0.802l3.017,1.504c0.561,0.279,1.234,0.168,1.674-0.275l1.706-1.717c0.438-0.441,0.547-1.113,0.269-1.669l-1.504-3.007 l0.795-1.926l3.193-1.066c0.592-0.197,0.989-0.751,0.989-1.374v-2.423c0-0.622-0.397-1.176-0.989-1.374l-3.193-1.065l-0.795-1.927 l1.504-3.007l-2.59-1.295l-1.8,3.596c-0.188,0.375-0.203,0.813-0.042,1.2l1.298,3.147c0.16,0.389,0.479,0.688,0.878,0.821 l2.833,0.946v0.337l-2.833,0.946c-0.398,0.133-0.718,0.432-0.878,0.822l-1.298,3.146c-0.161,0.387-0.146,0.825,0.042,1.199 l1.334,2.666l-0.235,0.238l-2.672-1.332c-0.376-0.187-0.814-0.203-1.201-0.041l-3.146,1.308c-0.388,0.159-0.687,0.479-0.819,0.877 l-0.945,2.825h-0.335l-0.938-2.822c-0.132-0.4-0.432-0.721-0.82-0.881l-3.157-1.307c-0.387-0.162-0.826-0.145-1.202,0.041 l-2.665,1.334l-0.237-0.236l1.333-2.67c0.186-0.377,0.201-0.813,0.042-1.199l-1.298-3.146c-0.168-0.408-0.516-0.711-0.926-0.834 l-2.787-0.934v-0.336l2.82-0.938c0.475-0.158,0.833-0.547,0.951-1.031c0.239-0.987,0.62-1.909,1.134-2.739 c0.263-0.429,0.286-0.96,0.062-1.409l-1.331-2.662l0.239-0.24l2.663,1.332c0.375,0.187,0.813,0.201,1.199,0.043l3.157-1.299'
/>
</svg>
Expand Down
6 changes: 3 additions & 3 deletions src/components/layout/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function Footer() {
const t = useTranslations('layout');
const year = new Date().getFullYear();
return (
<footer className='mx-auto w-full max-w-screen-2xl border-t border-border/40 bg-background/95 px-11 py-10 text-sm md:px-16 lg:px-24'>
<div className='grid grid-cols-1 gap-x-4 gap-y-12 xs:grid-cols-2 sm:grid-cols-3 lg:grid-cols-4'>
<footer className='mx-auto w-full max-w-screen-2xl border-border/40 border-t bg-background/95 px-11 py-10 text-sm md:px-16 lg:px-24'>
<div className='grid grid-cols-1 xs:grid-cols-2 gap-x-4 gap-y-12 sm:grid-cols-3 lg:grid-cols-4'>
<div>
<div className='flex'>
<LogoLink className='justify-start' />
Expand Down Expand Up @@ -115,7 +115,7 @@ function Footer() {
<div>
<h4>{t('links')}</h4>
<Nav
className='ml-2 mt-2 space-y-1.5'
className='mt-2 ml-2 space-y-1.5'
t={{
news: t('news'),
events: t('events'),
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ProfileMenu } from '@/components/settings/ProfileMenu';
function Header() {
const t = useTranslations('layout');
return (
<header className='sticky top-0 z-20 mx-auto flex min-h-14 w-full max-w-screen-2xl items-center justify-between border-b border-border/40 bg-background/95 px-4 backdrop-blur supports-[backdrop-filter]:bg-background/60 sm:px-11 md:px-16 lg:px-24'>
<header className='sticky top-0 z-20 mx-auto flex min-h-14 w-full max-w-screen-2xl items-center justify-between border-border/40 border-b bg-background/95 px-4 backdrop-blur supports-[backdrop-filter]:bg-background/60 sm:px-11 md:px-16 lg:px-24'>
<MobileSheet
className='flex md:hidden'
t={{
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/LogoLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function LogoLink({
>
<Link href='/' aria-label={t('hackerspaceHome')} onClick={onClick}>
<Logo className='h-6 w-6 md:h-8 md:w-8 xl:h-10 xl:w-10' />
<span className='text-md font-montserrat font-bold md:text-lg xl:text-2xl'>
<span className='font-bold font-montserrat text-md md:text-lg xl:text-2xl'>
HACKERSPACE
</span>
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Main({ children, className }: MainProps) {
return (
<main
className={cx(
'mx-auto w-full max-w-screen-2xl flex-grow px-4 duration-1000 animate-in fade-in max-md:slide-in-from-left-8 sm:px-11 md:px-16 md:slide-in-from-top-8 lg:px-24',
'fade-in max-md:slide-in-from-left-8 md:slide-in-from-top-8 mx-auto w-full max-w-screen-2xl flex-grow animate-in px-4 duration-1000 sm:px-11 md:px-16 lg:px-24',
className,
)}
>
Expand Down
13 changes: 7 additions & 6 deletions src/components/layout/PaginationCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ function PaginationCarousel({
pagesToDisplay = [page - 1, page, page + 1];
}

const lastPage = pagesToDisplay[pagesToDisplay.length - 1];

return (
<Pagination className={className}>
<PaginationContent>
Expand Down Expand Up @@ -107,12 +109,11 @@ function PaginationCarousel({
</PaginationItem>
),
)}
{pagesToDisplay[pagesToDisplay.length - 1] !== undefined &&
pagesToDisplay[pagesToDisplay.length - 1]! < totalPages && (
<PaginationItem>
<PaginationEllipsis morePages={t.morePages} />
</PaginationItem>
)}
{lastPage !== undefined && lastPage < totalPages && (
<PaginationItem>
<PaginationEllipsis morePages={t.morePages} />
</PaginationItem>
)}
<PaginationItem>
<PaginationNext
className={cx(
Expand Down
5 changes: 4 additions & 1 deletion src/components/layout/PaginationCarouselSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ function PaginationCarouselSkeleton({
/>
</PaginationItem>
{Array.from({ length: 4 }).map((_, index) => (
<PaginationItem className='cursor-not-allowed opacity-50' key={index}>
<PaginationItem
className='cursor-not-allowed opacity-50'
key={`Item ${index + 1}`}
>
<PaginationEllipsis morePages='' />
</PaginationItem>
))}
Expand Down
6 changes: 3 additions & 3 deletions src/components/news/CardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ type CardGridProps = {

function CardGrid({ topArticles }: CardGridProps) {
return (
<div className='grid h-192 grid-rows-4 gap-4 xs:h-96 xs:grid-cols-3 xs:grid-rows-2 md:grid-cols-4 lg:h-112'>
<div className='grid h-192 xs:h-96 xs:grid-cols-3 grid-rows-4 xs:grid-rows-2 gap-4 md:grid-cols-4 lg:h-112'>
{topArticles.map((data, index) => (
<ArticleCard
className={cx(
index === 0 && 'row-span-1 xs:col-span-2 md:row-span-2',
index === 0 && 'xs:col-span-2 row-span-1 md:row-span-2',
index === 1 && 'col-span-1 row-span-1 md:col-span-2',
index === 3 && 'row-span-1 xs:col-span-2 md:col-span-1',
index === 3 && 'xs:col-span-2 row-span-1 md:col-span-1',
)}
key={data.id}
id={data.id}
Expand Down
8 changes: 4 additions & 4 deletions src/components/news/CardGridSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { Skeleton } from '@/components/ui/Skeleton';

function CardGridSkeleton() {
return (
<div className='grid h-192 grid-rows-4 gap-4 xs:h-96 xs:grid-cols-3 xs:grid-rows-2 md:grid-cols-4 lg:h-112'>
<div className='grid h-192 xs:h-96 xs:grid-cols-3 grid-rows-4 xs:grid-rows-2 gap-4 md:grid-cols-4 lg:h-112'>
{Array.from({ length: 4 }).map((_, index) => (
<Skeleton
className={cx(
'h-full w-full',
index === 0 && 'row-span-1 xs:col-span-2 md:row-span-2',
index === 0 && 'xs:col-span-2 row-span-1 md:row-span-2',
index === 1 && 'col-span-1 row-span-1 md:col-span-2',
index === 3 && 'row-span-1 xs:col-span-2 md:col-span-1',
index === 3 && 'xs:col-span-2 row-span-1 md:col-span-1',
)}
key={index}
key={`Grid ${index + 1}`}
/>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/news/InternalBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function InternalBadge({ className, internal }: InternalBadgeProps) {
variant='ghost'
size='xs-icon'
>
<span tabIndex={0}>
<span>
<ShieldAlert />
</span>
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/news/ItemGridSkeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function ItemGridSkeleton() {
return (
<div className='grid min-h-[752px] grid-cols-1 gap-4 sm:min-h-[368px] sm:grid-cols-2 lg:min-h-[240px] lg:grid-cols-3'>
{Array.from({ length: 6 }).map((_, index) => (
<ArticleItemSkeleton key={index} />
<ArticleItemSkeleton key={`Item ${index + 1}`} />
))}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/DarkModeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function DarkModeMenu({ t }: DarkModeMenuProps) {
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant='ghost' size='icon'>
<Sun className='h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0' />
<Sun className='dark:-rotate-90 h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:scale-0' />
<Moon className='absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100' />
<span className='sr-only'>{t.toggleTheme}</span>
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import type * as React from 'react';

import { type VariantProps, cva, cx } from '@/lib/utils';

Expand Down
Loading

0 comments on commit 49a5745

Please sign in to comment.