Skip to content

Commit

Permalink
Merge pull request #19 from dmytro-komlyk/development
Browse files Browse the repository at this point in the history
refactor: updated eslint conf and fix lint errors
  • Loading branch information
dmytro-komlyk authored Jun 11, 2024
2 parents dc92a81 + be87b83 commit f3381d7
Show file tree
Hide file tree
Showing 29 changed files with 192 additions and 139 deletions.
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
"source.fixAll": "explicit"
},
"eslint.workingDirectories": [
{
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions apps/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "pnpm lint --fix"
},
"dependencies": {
"@nextui-org/react": "^2.1.13",
"@nextui-org/react": "^2.4.1",
"@nextui-org/system": "^2.0.10",
"@nextui-org/theme": "^2.1.9",
"@prisma/nextjs-monorepo-workaround-plugin": "^5.13.0",
Expand All @@ -24,7 +24,7 @@
"@trpc/server": "^10.43.6",
"cross-env": "^7.0.3",
"formik": "^2.4.5",
"framer-motion": "^10.16.4",
"framer-motion": "^10.18.0",
"http-browserify": "^1.7.0",
"https-browserify": "^1.0.0",
"next": "^14.0.2",
Expand Down
10 changes: 10 additions & 0 deletions apps/client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
root: true,
extends: ['next', 'next/core-web-vitals', '@repo/eslint-config/next.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
project: true,
},
};
3 changes: 0 additions & 3 deletions apps/client/.eslintrc.json

This file was deleted.

13 changes: 7 additions & 6 deletions apps/client/app/(components)/LocaleSwitcher.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { locales } from "@client/config";
import { useLocale, useTranslations } from "next-intl";
import LocaleSwitcherSelect from "./LocaleSwitcherSelect";
import { locales } from '@client/config';
import { useLocale, useTranslations } from 'next-intl';

import LocaleSwitcherSelect from './LocaleSwitcherSelect';

export default function LocaleSwitcher() {
const t = useTranslations("LocaleSwitcher");
const t = useTranslations('LocaleSwitcher');
const locale = useLocale();

return (
<LocaleSwitcherSelect defaultValue={locale} label={t("label")}>
<LocaleSwitcherSelect defaultValue={locale} label={t('label')}>
{locales.map((cur) => (
<option key={cur} value={cur}>
{t("locale", { locale: cur })}
{t('locale', { locale: cur })}
</option>
))}
</LocaleSwitcherSelect>
Expand Down
13 changes: 7 additions & 6 deletions apps/client/app/(components)/LocaleSwitcherSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use client";
'use client';

import { usePathname, useRouter } from "@client/navigation";
import clsx from "clsx";
import { ChangeEvent, ReactNode, useTransition } from "react";
import { usePathname, useRouter } from '@client/navigation';
import clsx from 'clsx';
import type { ChangeEvent, ReactNode } from 'react';
import { useTransition } from 'react';

type Props = {
children: ReactNode;
Expand All @@ -29,8 +30,8 @@ export default function LocaleSwitcherSelect({
return (
<label
className={clsx(
"relative text-black dark:text-white",
isPending && "transition-opacity [&:disabled]:opacity-30"
'relative text-black dark:text-white',
isPending && 'transition-opacity [&:disabled]:opacity-30',
)}
>
<p className="sr-only">{label}</p>
Expand Down
18 changes: 9 additions & 9 deletions apps/client/app/(components)/ThemeToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";
'use client';

import { Switch } from "@nextui-org/react";
import { useEffect, useState } from "react";
import { Switch } from '@nextui-org/react';
import { useEffect, useState } from 'react';

type Theme = "light" | "dark";
type Theme = 'light' | 'dark';

export const MoonIcon = (props: any) => (
<svg
Expand Down Expand Up @@ -45,12 +45,12 @@ function ThemeToggle({ initialValue }: { initialValue: Theme }) {
useEffect(() => {
if (theme) {
document.cookie = `theme=${theme};path=/;`;
document.querySelector("html")?.classList.toggle("dark");
document.querySelector('html')?.classList.toggle('dark');
} else {
setTheme(
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light"
window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light',
);
}
}, [theme]);
Expand All @@ -61,7 +61,7 @@ function ThemeToggle({ initialValue }: { initialValue: Theme }) {
size="lg"
color="success"
onClick={() => {
setTheme(theme === "dark" ? "light" : "dark");
setTheme(theme === 'dark' ? 'light' : 'dark');
}}
startContent={<SunIcon />}
endContent={<MoonIcon />}
Expand Down
2 changes: 2 additions & 0 deletions apps/client/app/(utils)/trpc/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use client';

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { httpBatchLink } from '@trpc/client';
import React, { useState } from 'react';

import { SERVER_TRPC_URL } from '../../(lib)/constants';
import { trpc } from './client';

Expand Down
5 changes: 2 additions & 3 deletions apps/client/app/(utils)/trpc/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createTRPCReact } from "@trpc/react-query";

import type { AppRouter } from "@server/domain/trpc/trpc.router";
import type { AppRouter } from '@server/domain/trpc/trpc.router';
import { createTRPCReact } from '@trpc/react-query';

export const trpc = createTRPCReact<AppRouter>({});
2 changes: 1 addition & 1 deletion apps/client/app/[locale]/[...rest]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { notFound } from "next/navigation";
import { notFound } from 'next/navigation';

export default function CatchAllPage() {
notFound();
Expand Down
10 changes: 5 additions & 5 deletions apps/client/app/[locale]/error.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"use client";
'use client';

import { useTranslations } from "next-intl";
import { useEffect } from "react";
import { useTranslations } from 'next-intl';
import { useEffect } from 'react';

type Props = {
error: Error;
reset(): void;
};

export default function Error({ error, reset }: Props) {
const t = useTranslations("Error");
const t = useTranslations('Error');

useEffect(() => {
console.error(error);
}, [error]);

return (
<div>
{t.rich("description", {
{t.rich('description', {
p: (chunks) => <p className="mt-4">{chunks}</p>,
retry: (chunks) => (
<button
Expand Down
28 changes: 16 additions & 12 deletions apps/client/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { locales } from "@client/config";
import clsx from "clsx";
import { getTranslations, unstable_setRequestLocale } from "next-intl/server";
import { Inter } from "next/font/google";
import { notFound } from "next/navigation";
import { Providers } from "./providers";
import { locales } from '@client/config';
import clsx from 'clsx';
import { Inter } from 'next/font/google';
import { notFound } from 'next/navigation';
import {
getTranslations,
unstable_setRequestLocale as setRequestLocale,
} from 'next-intl/server';

const inter = Inter({ subsets: ["latin"] });
import { Providers } from './providers';

const inter = Inter({ subsets: ['latin'] });

type Props = {
children: React.ReactNode;
Expand All @@ -18,23 +22,23 @@ export function generateStaticParams() {

export async function generateMetadata({
params: { locale },
}: Omit<Props, "children">) {
const t = await getTranslations({ locale, namespace: "LocaleLayout" });
}: Omit<Props, 'children'>) {
const t = await getTranslations({ locale, namespace: 'LocaleLayout' });

return {
title: t("title"),
title: t('title'),
};
}

export default function LocaleLayout({ children, params: { locale } }: Props) {
if (!locales.includes(locale as any)) notFound();

// Enable static rendering
unstable_setRequestLocale(locale);
setRequestLocale(locale);

return (
<html lang={locale} className="light">
<body className={clsx(inter.className, "flex h-full flex-col")}>
<body className={clsx(inter.className, 'flex h-full flex-col')}>
<Providers>{children}</Providers>
</body>
</html>
Expand Down
6 changes: 3 additions & 3 deletions apps/client/app/[locale]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useTranslations } from "next-intl";
import { useTranslations } from 'next-intl';

// Note that `app/[locale]/[...rest]/page.tsx`
// is necessary for this page to render.

export default function NotFoundPage() {
const t = useTranslations("NotFoundPage");
const t = useTranslations('NotFoundPage');

return <p className="max-w-[460px]">{t("description")}</p>;
return <p className="max-w-[460px]">{t('description')}</p>;
}
Loading

0 comments on commit f3381d7

Please sign in to comment.