From c785c8d2f6482d60f5f502fd1cda445425f5ce8e Mon Sep 17 00:00:00 2001 From: Arthur Green Date: Sat, 9 Nov 2024 11:49:20 +0400 Subject: [PATCH] style: apply new rules --- .eslintrc.yml | 11 +++++++++-- src/app/error.tsx | 10 +++++----- src/app/layout.tsx | 10 +++++----- src/app/manufacturers/[id]/page.tsx | 2 +- src/app/not-found.tsx | 6 +++--- src/app/page.tsx | 4 ++-- src/components/loader/Loader.tsx | 14 ++++++++------ src/components/table/Table.tsx | 20 ++++++++++---------- 8 files changed, 43 insertions(+), 34 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 77b7e0e..d412a3b 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -4,9 +4,9 @@ env: node: true extends: # - love - - plugin:@typescript-eslint/recommended - - plugin:react/recommended + - plugin:@typescript-eslint/strict - plugin:react/jsx-runtime + - plugin:react/all - prettier parser: '@typescript-eslint/parser' parserOptions: @@ -16,5 +16,12 @@ plugins: - react - '@typescript-eslint' rules: + 'react/jsx-filename-extension': [2, { 'extensions': ['.tsx'] }] '@typescript-eslint/explicit-function-return-type': 'off' + 'react/react-in-jsx-scope': 'off' + 'react/jsx-uses-react': 'off' + 'react/jsx-curly-brace-presence': 'off' + 'react/jsx-max-depth': 'off' + 'react/jsx-no-bind': 'off' + # '@typescript-eslint/naming-convention': 'error' root: true diff --git a/src/app/error.tsx b/src/app/error.tsx index c253b4e..064a0d6 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -6,8 +6,8 @@ export default function Error({ error, reset, }: { - error: Error; - reset: () => void; + readonly error: Error; + readonly reset: () => void; }) { useEffect(() => { // TODO: Log the error to an error reporting service @@ -16,14 +16,14 @@ export default function Error({ return (
-

Something went wrong!

+

{'Something went wrong!'}

); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f1bf356..b6587a4 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -5,20 +5,20 @@ import './App.css'; export default function RootLayout({ children, }: { - children: React.ReactNode; + readonly children: React.ReactNode; }) { return ( - - - Auto Manufacturers + + + {'Auto Manufacturers'}

- Vehicle manufacturers + {'Vehicle manufacturers'}

{children} diff --git a/src/app/manufacturers/[id]/page.tsx b/src/app/manufacturers/[id]/page.tsx index 095cb33..fce40aa 100644 --- a/src/app/manufacturers/[id]/page.tsx +++ b/src/app/manufacturers/[id]/page.tsx @@ -16,7 +16,7 @@ export async function generateStaticParams() { export default async function Manufacturer({ params, }: { - params: Promise<{ id: string }>; + readonly params: Promise<{ id: string }>; }) { const { id } = await params; diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 279ec0f..2c52291 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -3,10 +3,10 @@ import Link from 'next/link'; export default function NotFound() { return (
-

Not Found

-

Could not find requested resource

+

{'Not Found'}

+

{'Could not find requested resource'}

- View main page + {'View'} {'main page'}

); diff --git a/src/app/page.tsx b/src/app/page.tsx index 0b3a6f6..85a818d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -4,7 +4,7 @@ import Table from '@/components/table'; import { getManufacturers } from '@/api/index'; -const HomePage = async () => { +async function HomePage() { const manufacturers = await getManufacturers().then((data) => data.Results); return ( @@ -12,6 +12,6 @@ const HomePage = async () => { ); -}; +} export default HomePage; diff --git a/src/components/loader/Loader.tsx b/src/components/loader/Loader.tsx index 9cfee5a..b64b013 100644 --- a/src/components/loader/Loader.tsx +++ b/src/components/loader/Loader.tsx @@ -1,10 +1,12 @@ import loader from './loader.module.css'; -const Loader = () => ( - <> -
-

Loading...

- -); +function Loader() { + return ( + <> +
+

{'Loading...'}

+ + ); +} export default Loader; diff --git a/src/components/table/Table.tsx b/src/components/table/Table.tsx index 7c035b4..5bc2e64 100644 --- a/src/components/table/Table.tsx +++ b/src/components/table/Table.tsx @@ -11,7 +11,7 @@ import '@/helpers/helpers.css'; import table from './table.module.css'; interface TableProps { - manufacturers: + readonly manufacturers: | [ { Mfr_ID: number; @@ -23,18 +23,18 @@ interface TableProps { | null; } -const Table = ({ manufacturers }: TableProps) => { +function Table({ manufacturers }: TableProps) { const router = useRouter(); return (
- + - + @@ -46,7 +46,7 @@ const Table = ({ manufacturers }: TableProps) => { Mfr_CommonName: name, Mfr_Name: legalName, }) => ( - + @@ -79,5 +79,5 @@ const Table = ({ manufacturers }: TableProps) => {
ID{'ID'} - Common name + {'Common name'} Country{'Country'}
{ { e.preventDefault(); router.push(`/manufacturers/${id}`); }} - href={`/manufacturers/${id}`} - className={table.cell__link} title="View Manufacturer Details" > - +
); -}; +} export default Table;