Skip to content

Commit

Permalink
feat: add new eslint rules (#22)
Browse files Browse the repository at this point in the history
* feat: add new eslint rules

* feat: add providers props

* fix: error build
  • Loading branch information
fahmiidris authored Feb 13, 2024
1 parent 0da1adc commit 919d76b
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 28 deletions.
14 changes: 9 additions & 5 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ env:
browser: true
node: true

globals:
React: true
JSX: true

plugins:
- '@typescript-eslint'

Expand All @@ -15,12 +19,12 @@ parser: '@typescript-eslint/parser'

rules:
'no-console': 'warn'
'no-nested-ternary': 'warn'
'no-use-before-define': 'warn'
'@typescript-eslint/array-type':
- 'warn'
- 'default': 'array-simple'
'@typescript-eslint/consistent-indexed-object-style': 'warn'
'@typescript-eslint/no-explicit-any': 'warn'

globals:
JSX: true
React: true
'@typescript-eslint/consistent-type-imports': 'warn'
'@typescript-eslint/consistent-type-definitions': 'warn'
'@typescript-eslint/consistent-indexed-object-style': 'warn'
23 changes: 12 additions & 11 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,8 @@ import Providers from '@/app/providers';
import { cn } from '@/utils/cn';

import type { Metadata } from 'next';
import type { TLayoutProps } from '@/types/layout.type';

const DEFAULT_TITLE = 'Next.js App Dir Template';
const DEFAULT_DESCRIPTION = 'Next.js app directory template, built with Next.js (TypeScript) and Tailwind CSS.';

export const metadata: Metadata = {
title: {
template: `%s - ${DEFAULT_TITLE}`,
default: DEFAULT_TITLE,
},
description: DEFAULT_DESCRIPTION,
};
import type { TLayoutProps } from '@/types/layout';

export default async function Layout({ children }: TLayoutProps) {
return (
Expand All @@ -30,3 +20,14 @@ export default async function Layout({ children }: TLayoutProps) {
</html>
);
}

const DEFAULT_TITLE = 'Next.js App Dir Template';
const DEFAULT_DESCRIPTION = 'Next.js app directory template, built with Next.js (TypeScript) and Tailwind CSS.';

export const metadata: Metadata = {
title: {
template: `%s - ${DEFAULT_TITLE}`,
default: DEFAULT_TITLE,
},
description: DEFAULT_DESCRIPTION,
};
2 changes: 1 addition & 1 deletion src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ThemeProvider } from 'next-themes';
import { ThemeWatcher } from '@/app/_components/theme-watcher';
import { TRPCReactProvider } from '@/trpc/client/react';

type TProvidersProps = React.PropsWithChildren;
import type { TProvidersProps } from '@/types/providers';

export default function Providers({ children }: TProvidersProps) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/server/db/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import {
text,
primaryKey,
integer,
PgTableFn,
PgDatabase,
serial,
varchar,
index,
type PgTableFn,
type PgDatabase,
} from 'drizzle-orm/pg-core';

import type { Adapter, AdapterAccount } from 'next-auth/adapters';
Expand Down
10 changes: 10 additions & 0 deletions src/types/layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PropsWithChildren } from 'react';

// import type { TParams, TSearchParams } from '@/types/params';

// export type TLayoutProps<P = TParams, SP = TSearchParams> = PropsWithChildren<{
// params: P;
// searchParams: SP;
// }>;

export type TLayoutProps<T = unknown> = PropsWithChildren<T>;
3 changes: 0 additions & 3 deletions src/types/layout.type.ts

This file was deleted.

6 changes: 6 additions & 0 deletions src/types/page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { TParams, TSearchParams } from '@/types/params';

export interface TPageProps<P = TParams, SP = TSearchParams> {
params: P;
searchParams: SP;
}
6 changes: 0 additions & 6 deletions src/types/page.type.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/types/params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type TParams = Record<string, string | string[] | undefined>;

export type TSearchParams = Record<string, string | string[] | undefined>;
3 changes: 3 additions & 0 deletions src/types/providers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { PropsWithChildren } from 'react';

export type TProvidersProps<T = unknown> = PropsWithChildren<T>;

0 comments on commit 919d76b

Please sign in to comment.