chore(templates): fix eslint errors in website template (#10752)

This commit is contained in:
Germán Jabloñski
2025-01-23 15:30:20 -03:00
committed by GitHub
parent 2d8ff7218a
commit 5689c6527b
31 changed files with 49 additions and 96 deletions

View File

@@ -30,6 +30,9 @@ const eslintConfig = [
], ],
}, },
}, },
{
ignores: ['.next/'],
},
] ]
export default eslintConfig export default eslintConfig

View File

@@ -1,6 +1,8 @@
export default { const config = {
plugins: { plugins: {
tailwindcss: {}, tailwindcss: {},
autoprefixer: {}, autoprefixer: {},
}, },
} }
export default config

View File

@@ -2,7 +2,7 @@
import { Header } from '@/payload-types' import { Header } from '@/payload-types'
import { RowLabelProps, useRowLabel } from '@payloadcms/ui' import { RowLabelProps, useRowLabel } from '@payloadcms/ui'
export const RowLabel: React.FC<RowLabelProps> = (props) => { export const RowLabel: React.FC<RowLabelProps> = () => {
const data = useRowLabel<NonNullable<Header['navItems']>[number]>() const data = useRowLabel<NonNullable<Header['navItems']>[number]>()
const label = data?.data?.link?.label const label = data?.data?.link?.label

View File

@@ -2,7 +2,7 @@
import { Header } from '@/payload-types' import { Header } from '@/payload-types'
import { RowLabelProps, useRowLabel } from '@payloadcms/ui' import { RowLabelProps, useRowLabel } from '@payloadcms/ui'
export const RowLabel: React.FC<RowLabelProps> = (props) => { export const RowLabel: React.FC<RowLabelProps> = () => {
const data = useRowLabel<NonNullable<Header['navItems']>[number]>() const data = useRowLabel<NonNullable<Header['navItems']>[number]>()
const label = data?.data?.link?.label const label = data?.data?.link?.label

View File

@@ -4,8 +4,6 @@ import { getPayload, type PayloadRequest } from 'payload'
import configPromise from '@payload-config' import configPromise from '@payload-config'
import { CollectionSlug } from 'payload' import { CollectionSlug } from 'payload'
const payloadToken = 'payload-token'
export async function GET( export async function GET(
req: Request & { req: Request & {
cookies: { cookies: {
@@ -16,7 +14,6 @@ export async function GET(
}, },
): Promise<Response> { ): Promise<Response> {
const payload = await getPayload({ config: configPromise }) const payload = await getPayload({ config: configPromise })
const token = req.cookies.get(payloadToken)?.value
const { searchParams } = new URL(req.url) const { searchParams } = new URL(req.url)
const path = searchParams.get('path') const path = searchParams.get('path')
const collection = searchParams.get('collection') as CollectionSlug const collection = searchParams.get('collection') as CollectionSlug

View File

@@ -5,15 +5,7 @@ import { headers } from 'next/headers'
export const maxDuration = 60 // This function can run for a maximum of 60 seconds export const maxDuration = 60 // This function can run for a maximum of 60 seconds
export async function POST( export async function POST(): Promise<Response> {
req: Request & {
cookies: {
get: (name: string) => {
value: string
}
}
},
): Promise<Response> {
const payload = await getPayload({ config }) const payload = await getPayload({ config })
const requestHeaders = await headers() const requestHeaders = await headers()

View File

@@ -4,7 +4,6 @@ import { CollectionArchive } from '@/components/CollectionArchive'
import configPromise from '@payload-config' import configPromise from '@payload-config'
import { getPayload } from 'payload' import { getPayload } from 'payload'
import React from 'react' import React from 'react'
import { Post } from '@/payload-types'
import { Search } from '@/search/Component' import { Search } from '@/search/Component'
import PageClient from './page.client' import PageClient from './page.client'
import { CardPostData } from '@/components/Card' import { CardPostData } from '@/components/Card'

View File

@@ -12,14 +12,8 @@ import { Width } from '../Width'
export const Checkbox: React.FC< export const Checkbox: React.FC<
CheckboxField & { CheckboxField & {
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
getValues: any
register: UseFormRegister<FieldValues> register: UseFormRegister<FieldValues>
setValue: any
} }
> = ({ name, defaultValue, errors, label, register, required, width }) => { > = ({ name, defaultValue, errors, label, register, required, width }) => {
const props = register(name, { required: required }) const props = register(name, { required: required })

View File

@@ -142,6 +142,7 @@ export const FormBlock: React.FC<
{formFromProps && {formFromProps &&
formFromProps.fields && formFromProps.fields &&
formFromProps.fields?.map((field, index) => { formFromProps.fields?.map((field, index) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const Field: React.FC<any> = fields?.[field.blockType as keyof typeof fields] const Field: React.FC<any> = fields?.[field.blockType as keyof typeof fields]
if (Field) { if (Field) {
return ( return (

View File

@@ -1,5 +1,5 @@
import type { CountryField } from '@payloadcms/plugin-form-builder/types' import type { CountryField } from '@payloadcms/plugin-form-builder/types'
import type { Control, FieldErrorsImpl, FieldValues } from 'react-hook-form' import type { Control, FieldErrorsImpl } from 'react-hook-form'
import { Label } from '@/components/ui/label' import { Label } from '@/components/ui/label'
import { import {
@@ -18,12 +18,8 @@ import { countryOptions } from './options'
export const Country: React.FC< export const Country: React.FC<
CountryField & { CountryField & {
control: Control<FieldValues, any> control: Control
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
} }
> = ({ name, control, errors, label, required, width }) => { > = ({ name, control, errors, label, required, width }) => {
return ( return (

View File

@@ -10,11 +10,7 @@ import { Width } from '../Width'
export const Email: React.FC< export const Email: React.FC<
EmailField & { EmailField & {
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
register: UseFormRegister<FieldValues> register: UseFormRegister<FieldValues>
} }
> = ({ name, defaultValue, errors, label, register, required, width }) => { > = ({ name, defaultValue, errors, label, register, required, width }) => {

View File

@@ -9,11 +9,7 @@ import { Error } from '../Error'
import { Width } from '../Width' import { Width } from '../Width'
export const Number: React.FC< export const Number: React.FC<
TextField & { TextField & {
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
register: UseFormRegister<FieldValues> register: UseFormRegister<FieldValues>
} }
> = ({ name, defaultValue, errors, label, register, required, width }) => { > = ({ name, defaultValue, errors, label, register, required, width }) => {

View File

@@ -1,5 +1,5 @@
import type { SelectField } from '@payloadcms/plugin-form-builder/types' import type { SelectField } from '@payloadcms/plugin-form-builder/types'
import type { Control, FieldErrorsImpl, FieldValues } from 'react-hook-form' import type { Control, FieldErrorsImpl } from 'react-hook-form'
import { Label } from '@/components/ui/label' import { Label } from '@/components/ui/label'
import { import {
@@ -17,12 +17,8 @@ import { Width } from '../Width'
export const Select: React.FC< export const Select: React.FC<
SelectField & { SelectField & {
control: Control<FieldValues, any> control: Control
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
} }
> = ({ name, control, errors, label, options, required, width }) => { > = ({ name, control, errors, label, options, required, width }) => {
return ( return (

View File

@@ -1,5 +1,5 @@
import type { StateField } from '@payloadcms/plugin-form-builder/types' import type { StateField } from '@payloadcms/plugin-form-builder/types'
import type { Control, FieldErrorsImpl, FieldValues } from 'react-hook-form' import type { Control, FieldErrorsImpl } from 'react-hook-form'
import { Label } from '@/components/ui/label' import { Label } from '@/components/ui/label'
import { import {
@@ -18,12 +18,8 @@ import { stateOptions } from './options'
export const State: React.FC< export const State: React.FC<
StateField & { StateField & {
control: Control<FieldValues, any> control: Control
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
} }
> = ({ name, control, errors, label, required, width }) => { > = ({ name, control, errors, label, required, width }) => {
return ( return (

View File

@@ -10,11 +10,7 @@ import { Width } from '../Width'
export const Text: React.FC< export const Text: React.FC<
TextField & { TextField & {
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
register: UseFormRegister<FieldValues> register: UseFormRegister<FieldValues>
} }
> = ({ name, defaultValue, errors, label, register, required, width }) => { > = ({ name, defaultValue, errors, label, register, required, width }) => {

View File

@@ -10,11 +10,7 @@ import { Width } from '../Width'
export const Textarea: React.FC< export const Textarea: React.FC<
TextField & { TextField & {
errors: Partial< errors: Partial<FieldErrorsImpl>
FieldErrorsImpl<{
[x: string]: any
}>
>
register: UseFormRegister<FieldValues> register: UseFormRegister<FieldValues>
rows?: number rows?: number
} }

View File

@@ -5,11 +5,12 @@ import RichText from '@/components/RichText'
import type { Post } from '@/payload-types' import type { Post } from '@/payload-types'
import { Card } from '../../components/Card' import { Card } from '../../components/Card'
import { SerializedEditorState } from '@payloadcms/richtext-lexical/lexical'
export type RelatedPostsProps = { export type RelatedPostsProps = {
className?: string className?: string
docs?: Post[] docs?: Post[]
introContent?: any introContent?: SerializedEditorState
} }
export const RelatedPosts: React.FC<RelatedPostsProps> = (props) => { export const RelatedPosts: React.FC<RelatedPostsProps> = (props) => {

View File

@@ -1,4 +1,3 @@
import { cn } from '@/utilities/ui'
import React, { Fragment } from 'react' import React, { Fragment } from 'react'
import type { Page } from '@/payload-types' import type { Page } from '@/payload-types'

View File

@@ -1,8 +1,6 @@
import { cn } from '@/utilities/ui' import { cn } from '@/utilities/ui'
import React from 'react' import React from 'react'
import type { Post } from '@/payload-types'
import { Card, CardPostData } from '@/components/Card' import { Card, CardPostData } from '@/components/Card'
export type Props = { export type Props = {

View File

@@ -35,13 +35,7 @@ export const ImageMedia: React.FC<MediaProps> = (props) => {
let src: StaticImageData | string = srcFromProps || '' let src: StaticImageData | string = srcFromProps || ''
if (!src && resource && typeof resource === 'object') { if (!src && resource && typeof resource === 'object') {
const { const { alt: altFromResource, height: fullHeight, url, width: fullWidth } = resource
alt: altFromResource,
filename: fullFilename,
height: fullHeight,
url,
width: fullWidth,
} = resource
width = fullWidth! width = fullWidth!
height = fullHeight! height = fullHeight!

View File

@@ -9,7 +9,7 @@ export const Media: React.FC<Props> = (props) => {
const { className, htmlElement = 'div', resource } = props const { className, htmlElement = 'div', resource } = props
const isVideo = typeof resource === 'object' && resource?.mimeType?.includes('video') const isVideo = typeof resource === 'object' && resource?.mimeType?.includes('video')
const Tag = (htmlElement as any) || Fragment const Tag = htmlElement || Fragment
return ( return (
<Tag <Tag

View File

@@ -10,7 +10,6 @@ export const contact: Partial<Page> = {
{ {
blockType: 'formBlock', blockType: 'formBlock',
enableIntro: true, enableIntro: true,
// @ts-ignore
form: '{{CONTACT_FORM_ID}}', form: '{{CONTACT_FORM_ID}}',
introContent: { introContent: {
root: { root: {

View File

@@ -1,7 +1,6 @@
import type { Page } from '@/payload-types' import type { Page } from '@/payload-types'
// Used for pre-seeded content so that the homepage is not empty // Used for pre-seeded content so that the homepage is not empty
// @ts-expect-error
export const homeStatic: Page = { export const homeStatic: Page = {
slug: 'home', slug: 'home',
_status: 'published', _status: 'published',
@@ -85,4 +84,8 @@ export const homeStatic: Page = {
title: 'Payload Website Template', title: 'Payload Website Template',
}, },
title: 'Home', title: 'Home',
id: '',
layout: [],
updatedAt: '',
createdAt: '',
} }

View File

@@ -23,7 +23,6 @@ export const home: RequiredDataFromCollectionSlug<'pages'> = {
}, },
}, },
], ],
// @ts-ignore
media: '{{IMAGE_1}}', media: '{{IMAGE_1}}',
richText: { richText: {
root: { root: {
@@ -502,7 +501,6 @@ export const home: RequiredDataFromCollectionSlug<'pages'> = {
{ {
blockName: 'Media Block', blockName: 'Media Block',
blockType: 'mediaBlock', blockType: 'mediaBlock',
// @ts-ignore
media: '{{IMAGE_2}}', media: '{{IMAGE_2}}',
}, },
{ {
@@ -659,7 +657,6 @@ export const home: RequiredDataFromCollectionSlug<'pages'> = {
], ],
meta: { meta: {
description: 'An open-source website built with Payload and Next.js.', description: 'An open-source website built with Payload and Next.js.',
// @ts-ignore
image: '{{IMAGE_1}}', image: '{{IMAGE_1}}',
title: 'Payload Website Template', title: 'Payload Website Template',
}, },

View File

@@ -104,9 +104,6 @@ export const seed = async ({
technologyCategory, technologyCategory,
newsCategory, newsCategory,
financeCategory, financeCategory,
designCategory,
softwareCategory,
engineeringCategory,
] = await Promise.all([ ] = await Promise.all([
payload.create({ payload.create({
collection: 'users', collection: 'users',

View File

@@ -8,7 +8,7 @@ export const formatSlug = (val: string): string =>
export const formatSlugHook = export const formatSlugHook =
(fallback: string): FieldHook => (fallback: string): FieldHook =>
({ data, operation, originalDoc, value }) => { ({ data, operation, value }) => {
if (typeof value === 'string') { if (typeof value === 'string') {
return formatSlug(value) return formatSlug(value)
} }

View File

@@ -23,8 +23,7 @@ export const slugField: Slug = (fieldToUse = 'title', overrides = {}) => {
...checkboxOverrides, ...checkboxOverrides,
} }
// Expect ts error here because of typescript mismatching Partial<TextField> with TextField // @ts-expect-error - ts mismatch Partial<TextField> with TextField
// @ts-expect-error
const slugField: TextField = { const slugField: TextField = {
name: 'slug', name: 'slug',
type: 'text', type: 'text',

View File

@@ -1645,4 +1645,4 @@ export interface Auth {
declare module 'payload' { declare module 'payload' {
export interface GeneratedTypes extends Config {} export interface GeneratedTypes extends Config {}
} }

View File

@@ -1,11 +1,11 @@
import { BeforeSync, DocToSync } from '@payloadcms/plugin-search/types' import { BeforeSync, DocToSync } from '@payloadcms/plugin-search/types'
export const beforeSyncWithSearch: BeforeSync = async ({ originalDoc, searchDoc, payload }) => { export const beforeSyncWithSearch: BeforeSync = async ({ originalDoc, searchDoc }) => {
const { const {
doc: { relationTo: collection }, doc: { relationTo: collection },
} = searchDoc } = searchDoc
const { slug, id, categories, title, meta, excerpt } = originalDoc const { slug, id, categories, title, meta } = originalDoc
const modifiedDoc: DocToSync = { const modifiedDoc: DocToSync = {
...searchDoc, ...searchDoc,
@@ -33,7 +33,7 @@ export const beforeSyncWithSearch: BeforeSync = async ({ originalDoc, searchDoc,
}) })
modifiedDoc.categories = mappedCategories modifiedDoc.categories = mappedCategories
} catch (err) { } catch (_err) {
console.error( console.error(
`Failed. Category not found when syncing collection '${collection}' with id: '${id}' to search.`, `Failed. Category not found when syncing collection '${collection}' with id: '${id}' to search.`,
) )

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck // @ts-nocheck
/** /**
@@ -5,8 +6,8 @@
* @param item * @param item
* @returns {boolean} * @returns {boolean}
*/ */
export function isObject(item: unknown): boolean { export function isObject(item: unknown): item is object {
return item && typeof item === 'object' && !Array.isArray(item) return typeof item === 'object' && !Array.isArray(item)
} }
/** /**

View File

@@ -1,5 +1,8 @@
import tailwindcssAnimate from 'tailwindcss-animate'
import typography from '@tailwindcss/typography'
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
export default { const config = {
content: [ content: [
'./pages/**/*.{ts,tsx}', './pages/**/*.{ts,tsx}',
'./components/**/*.{ts,tsx}', './components/**/*.{ts,tsx}',
@@ -7,7 +10,7 @@ export default {
'./src/**/*.{ts,tsx}', './src/**/*.{ts,tsx}',
], ],
darkMode: ['selector', '[data-theme="dark"]'], darkMode: ['selector', '[data-theme="dark"]'],
plugins: [require('tailwindcss-animate'), require('@tailwindcss/typography')], plugins: [tailwindcssAnimate, typography],
prefix: '', prefix: '',
safelist: [ safelist: [
'lg:col-span-4', 'lg:col-span-4',
@@ -104,7 +107,7 @@ export default {
to: { height: '0' }, to: { height: '0' },
}, },
}, },
typography: ({ theme }) => ({ typography: () => ({
DEFAULT: { DEFAULT: {
css: [ css: [
{ {
@@ -146,3 +149,5 @@ export default {
}, },
}, },
} }
export default config