Skip to content

Commit

Permalink
Ci/biome checks (#1092)
Browse files Browse the repository at this point in the history
Signed-off-by: suddenlyGiovanni <[email protected]>
  • Loading branch information
suddenlyGiovanni authored Dec 7, 2024
1 parent 42ca943 commit fd30f63
Show file tree
Hide file tree
Showing 58 changed files with 256 additions and 202 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/pull-request-checks-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,30 @@ jobs:
github_packages_token: ${{ secrets.GH_PACKAGES_TOKEN }}

- name: 💅 Format code
run: pnpm run format:ci
shell: sh
run: |
pnpm --recursive --shell-mode exec biome ci \
--max-diagnostics=none \
--vcs-enabled=true \
--vcs-use-ignore-file=true \
--vcs-root="../../" \
--formatter-enabled=true \
--linter-enabled=false \
--organize-imports-enabled=true \
--reporter=github
- name: 🚨 Lint code
run: pnpm run lint:ci
shell: sh
run: |
pnpm --recursive --shell-mode exec biome ci \
--max-diagnostics=none \
--vcs-enabled=true \
--vcs-use-ignore-file=true \
--vcs-root="../../" \
--formatter-enabled=false \
--linter-enabled=true \
--organize-imports-enabled=false \
--reporter=github .
- name: 🔍 Typecheck code
continue-on-error: true
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/push-checks-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,41 @@ jobs:
run: pnpm run typecheck

- name: 🚨 Lint code
run: pnpm run lint:ci:write
shell: sh
run: |
pnpm --recursive --shell-mode exec biome check \
--max-diagnostics=none \
--vcs-enabled=true \
--vcs-use-ignore-file=true \
--vcs-root="../../" \
--formatter-enabled=false \
--linter-enabled=true \
--organize-imports-enabled=true \
--no-errors-on-unmatched \
--reporter=github \
--changed \
--write
- name: 🚦 Git Auto Commit Lint fixes (with Biome)
uses: stefanzweifel/[email protected]
with:
commit_message: "chore: lint code with Biome [skip ci]"

- name: 💅 Format code
run: pnpm run format:ci:write
shell: sh
run: |
pnpm --recursive --shell-mode exec biome check \
--max-diagnostics=none \
--vcs-enabled=true \
--vcs-use-ignore-file=true \
--vcs-root="../../" \
--formatter-enabled=true \
--linter-enabled=false \
--organize-imports-enabled=true \
--reporter=github \
--changed \
--no-errors-on-unmatched \
--write
- name: 🚦 Git Auto Commit Format fixes (with Biome)
uses: stefanzweifel/[email protected]
Expand Down
3 changes: 3 additions & 0 deletions apps/web/app/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ type Socials = Record<SocialNetwork, SocialProfile>

export const config = {
socials: {
// biome-ignore lint/style/useNamingConvention: <explanation>
GitHub: {
url: 'https://github.com/suddenlyGiovanni/',
handle: 'suddenlyGiovanni',
},
// biome-ignore lint/style/useNamingConvention: <explanation>
Twitter: {
url: 'https://twitter.com/suddenlyGio/',
handle: 'suddenlyGio',
},
// biome-ignore lint/style/useNamingConvention: <explanation>
LinkedIn: {
url: 'https://www.linkedin.com/in/giovanni-ravalico/',
handle: 'giovanni-ravalico',
Expand Down
19 changes: 8 additions & 11 deletions apps/web/app/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function NavLink({
return (
<UnstyledNavLink
{...props}
className={({ isActive }) => calculateClassName({ isActive, className })}
className={({ isActive }): string => calculateClassName({ isActive, className })}
>
{children}
</UnstyledNavLink>
Expand All @@ -71,15 +71,13 @@ const routes = (

const PRIMARY_NAVIGATION = 'primary-navigation'

function computeNextThemeMode(mode: Theme): Theme {
const nextMode =
mode === 'system' //
? 'light'
: // biome-ignore lint/nursery/noNestedTernary: FIXME: convert it to a State Machine obj
mode === 'light'
? 'dark'
: 'system'
return nextMode
function computeNextThemeMode(currentTheme: Theme): Theme {
const nextTheme = {
light: 'dark',
dark: 'system',
system: 'light',
} as const
return nextTheme[currentTheme]
}

function ThemeSwitch({
Expand Down Expand Up @@ -219,7 +217,6 @@ export const Header = memo(function Header({
id={PRIMARY_NAVIGATION}
onClick={handleMobileNavigationClick}
onKeyDown={handleMobileNavigationClick}
role="menu"
>
{renderLi}
<ThemeSwitch
Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type Effect, type Layer, ManagedRuntime } from 'effect'
import type { LoaderFunction } from 'react-router'

// biome-ignore lint/nursery/useExplicitType: <explanation>
export const makeRemixRuntime = <R, E>(layer: Layer.Layer<R, E, never>) => {
const runtime = ManagedRuntime.make(layer)

Expand All @@ -11,6 +12,7 @@ export const makeRemixRuntime = <R, E>(layer: Layer.Layer<R, E, never>) => {
): (...args: Parameters<LoaderFunction>) => Promise<A>
} =
body =>
// biome-ignore lint/nursery/useExplicitType: <explanation>
(...args) =>
runtime.runPromise(body(...args))

Expand Down
9 changes: 7 additions & 2 deletions apps/web/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { clsx } from '@suddenlygiovanni/ui/lib/utils.ts'
import hero2800wAssetUrl from '~/assets/hero/giovanni_ravalico-profile_color_e4cily_c_scale,w_2800.webp'
import { config } from '~/config.ts'
import { getHints } from '~/utils/client-hints.tsx'
import { getEnv } from '~/utils/env.server.ts'
import { type Env, getEnv } from '~/utils/env.server.ts'
import { getDomainUrl } from '~/utils/misc.ts'
import { getTheme, setTheme } from '~/utils/theme.server.ts'
import { ThemeFormSchema, useTheme } from '~/utils/theme.tsx'
Expand All @@ -21,6 +21,7 @@ import { Main } from './main.tsx'

import tailwindStyleSheetUrl from './styles/tailwind.css?url'

// biome-ignore lint/nursery/useImportRestrictions: <explanation>
import type { Route } from './+types/root.ts'

export const links: Route.LinksFunction = () => {
Expand All @@ -34,6 +35,7 @@ export const links: Route.LinksFunction = () => {
]
}

// biome-ignore lint/nursery/useExplicitType: <explanation>
export function meta({ location }: Route.MetaArgs) {
const description = "@suddenlyGiovanni's personal website"
const title = config.siteName
Expand All @@ -55,6 +57,7 @@ export function meta({ location }: Route.MetaArgs) {
]
}

// biome-ignore lint/nursery/useExplicitType: <explanation>
export function loader({ request }: Route.LoaderArgs) {
return {
requestInfo: {
Expand All @@ -64,10 +67,12 @@ export function loader({ request }: Route.LoaderArgs) {
userPrefs: { theme: getTheme(request) },
},

// biome-ignore lint/style/useNamingConvention: <explanation>
ENV: getEnv(),
}
}

// biome-ignore lint/nursery/useExplicitType: <explanation>
export async function action({ request }: Route.ActionArgs) {
const formData = await request.formData()
const payload = Object.fromEntries(formData)
Expand Down Expand Up @@ -98,7 +103,7 @@ function Document({
}: {
children: ReactNode
theme?: 'light' | 'dark' | null // TODO: address this prop
env?: typeof ENV
env?: Env
}): ReactElement {
const colorScheme = theme ?? 'light dark'
return (
Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/routes/about-me.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import hero2670wAssetUrl from '~/assets/hero/giovanni_ravalico-profile_color_e4c
import hero2800wAssetUrl from '~/assets/hero/giovanni_ravalico-profile_color_e4cily_c_scale,w_2800.webp'
import { config } from '~/config.ts'
import { routesRecord } from '~/routes-record.ts'
// biome-ignore lint/nursery/useImportRestrictions: <explanation>
import type { Route } from './+types/about-me.ts'

// biome-ignore lint/nursery/useExplicitType: <explanation>
export function meta({ location }: Route.MetaArgs) {
const description = 'All about Giovanni Ravalico'
const title = `${config.siteName} | About me`
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/routes/motivations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link } from 'react-router'
import { clsx } from '@suddenlygiovanni/ui/lib/utils.ts'
import { config } from '~/config.ts'
import { routesRecord } from '~/routes-record.ts'
// biome-ignore lint/nursery/useImportRestrictions: <explanation>
import type { Route } from './+types/motivations.ts'

export const meta: Route.MetaFunction = () => {
Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/routes/reading-journal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { T } from '@suddenlygiovanni/ui/components/typography/typography.tsx'
import type { JSX } from 'react'

// biome-ignore lint/nursery/useImportRestrictions: <explanation>
import type { Route } from './+types/reading-journal.ts'

export const meta: Route.MetaFunction = () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/routes/resources/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Route } from './+types/healthcheck'
// biome-ignore lint/nursery/useImportRestrictions: <explanation>
import type { Route } from './+types/healthcheck.ts'

export function loader(_: Route.LoaderArgs): Response {
return new Response('OK', {
Expand Down
13 changes: 7 additions & 6 deletions apps/web/app/routes/resume/education.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as Either from 'effect/Either'
import { pipe } from 'effect/Function'
import { Either, pipe } from 'effect'
import { type ReactElement, memo, useCallback, useMemo, useState } from 'react'

import type * as Model from '@suddenlygiovanni/resume/schema-resume'
Expand Down Expand Up @@ -168,7 +167,7 @@ const EduHeader = memo(function EduHeader({
</h3>

<span
aria-label="institution"
// aria-label="institution"
className={clsx(styles.span, 'font-medium text-base not-italic')}
>
{institution}
Expand All @@ -189,7 +188,9 @@ const EduHeader = memo(function EduHeader({

<span className={clsx(styles.span, 'justify-between')}>
{startDate ? (
<span aria-label="start date / end date">
<span
// aria-label="start date / end date"
>
<time
className="mr-2"
dateTime={startDate}
Expand All @@ -212,7 +213,7 @@ const EduHeader = memo(function EduHeader({

{location ? (
<span
aria-label="location"
// aria-label="location"
className={styles.span}
>
{location}
Expand All @@ -222,7 +223,7 @@ const EduHeader = memo(function EduHeader({

{studyType ? (
<span
aria-label="description"
// aria-label="description"
className={styles.span}
>
{studyType}
Expand Down
26 changes: 18 additions & 8 deletions apps/web/app/routes/resume/experience.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ const ExperienceHeader = memo(function ExperienceHeader(work: {
</hgroup>

<span className={clsx(styles.span, 'justify-between')}>
<span aria-label="start date / end date">
<span
// aria-label="start date / end date"
>
<time
className="mr-1"
dateTime={startDate}
Expand All @@ -128,12 +130,18 @@ const ExperienceHeader = memo(function ExperienceHeader(work: {
) : null}
</span>

{work.location ? <span aria-label="location">{work.location}</span> : null}
{work.location ? (
<span
// aria-label="location"
>
{work.location}
</span>
) : null}
</span>

{work.description ? (
<span
aria-label="description"
// aria-label="description"
className={styles.span}
>
{work.description}
Expand Down Expand Up @@ -224,7 +232,9 @@ function Role(
</Card.Title>
{'startDate' in role && (
<Card.Description>
<span aria-label="start date / end date">
<span
// aria-label="start date / end date"
>
<time
className="mr-1"
dateTime={role.startDate}
Expand Down Expand Up @@ -256,7 +266,7 @@ function Role(
{role.responsibilities.map(resp => (
<dd
key={resp}
role="listitem"
// role="listitem"
className="text-gray-600 dark:text-gray-400"
>
{resp.split('\n').map(resP => (
Expand All @@ -277,7 +287,7 @@ function Role(
{role.highlights.map(highlight => (
<dd
key={highlight}
role="listitem"
// role="listitem"
className="text-gray-600 dark:text-gray-400"
>
{highlight.split('\n').map(hP => (
Expand Down Expand Up @@ -344,7 +354,7 @@ function Tech({

return maybeIcon.pipe(
Option.match({
onNone: () => (
onNone: (): ReactElement => (
<Badge
className={classname}
key={tech}
Expand All @@ -353,7 +363,7 @@ function Tech({
<span>{tech}</span>
</Badge>
),
onSome: Icon => (
onSome: (Icon): ReactElement => (
<Badge
className={classname}
key={tech}
Expand Down
8 changes: 6 additions & 2 deletions apps/web/app/routes/resume/format-date-locale-short.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import type { ParseError } from 'effect/ParseResult'
*/
export function formatDateLocaleShort(isoString: string): Either<string, ParseError> {
const schema = Schema.transform(Schema.Date, Schema.String, {
decode: fromDate => fromDate.toLocaleDateString('en-US', { month: 'short', year: 'numeric' }),
encode: fromLocaleDateString => new Date(fromLocaleDateString),
decode(fromDate): string {
return fromDate.toLocaleDateString('en-US', { month: 'short', year: 'numeric' })
},
encode(fromLocaleDateString): Date {
return new Date(fromLocaleDateString)
},
}).annotations({
title: 'localDate',
description: 'a short US locale date format',
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/routes/resume/resume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Experiences } from './experiences.tsx'
import { Interests } from './interests.tsx'
import { Skills } from './skills.tsx'

// biome-ignore lint/nursery/useImportRestrictions: <explanation>
import type { Route } from './+types/resume.ts'

// biome-ignore lint/nursery/useExplicitType: <explanation>
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/routes/second-brain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { T } from '@suddenlygiovanni/ui/components/typography/typography.tsx'
import { clsx } from '@suddenlygiovanni/ui/lib/utils.ts'
import type { JSX } from 'react'
import { routesRecord } from '~/routes-record.ts'
// biome-ignore lint/nursery/useImportRestrictions: <explanation>
import type { Route } from './+types/second-brain.ts'

export const meta: Route.MetaFunction = () => {
Expand Down
Loading

0 comments on commit fd30f63

Please sign in to comment.