chore(eslint): lint:fix on all packages (#7941)

- Run `lint:fix` on all packages to fix anything that may have slipped
through without being autofixed
- A few manual fixes as well.
This commit is contained in:
Elliot DeNolf
2024-08-28 22:35:17 -04:00
committed by GitHub
parent 657326b528
commit ec9d1cda2d
22 changed files with 36 additions and 56 deletions

View File

@@ -12,11 +12,11 @@ type BuildFindQueryArgs = {
tableName: string
}
export type Result = DBQueryConfig<'many', true, any, any> & {
with?: DBQueryConfig<'many', true, any, any> & {
export type Result = {
with?: {
_locales?: DBQueryConfig<'many', true, any, any>
}
}
} & DBQueryConfig<'many', true, any, any>
} & DBQueryConfig<'many', true, any, any>
// Generate the Drizzle query for findMany based on
// a collection field structure

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-syntax, no-await-in-loop */
import type { PayloadRequest } from 'payload'
import {

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-syntax, no-await-in-loop */
import type { PayloadRequest } from 'payload'
import {

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-restricted-syntax, no-await-in-loop */
import type { PayloadRequest } from 'payload'
import {

View File

@@ -30,7 +30,7 @@ export async function migrateStatus(this: DrizzleAdapter): Promise<void> {
const existingMigration = existingMigrations.find((m) => m.name === migration.name)
return {
Name: migration.name,
// eslint-disable-next-line perfectionist/sort-objects
Batch: existingMigration?.batch,
Ran: existingMigration ? 'Yes' : 'No',
}

View File

@@ -28,11 +28,10 @@ export async function buildAndOrConditions({
const completedConditions = []
// Loop over all AND / OR operations and add them to the AND / OR query param
// Operations should come through as an array
// eslint-disable-next-line no-restricted-syntax
for (const condition of where) {
// If the operation is properly formatted as an object
if (typeof condition === 'object') {
// eslint-disable-next-line no-await-in-loop
const result = await parseParams({
adapter,
fields,

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-await-in-loop */
import type { SQL } from 'drizzle-orm'
import type { Field, Operator, Where } from 'payload'

View File

@@ -5,6 +5,7 @@ import type { ChainedMethods } from '../find/chainMethods.js'
import type {
DrizzleAdapter,
DrizzleTransaction,
GenericColumn,
GenericPgColumn,
TransactionPg,
TransactionSQLite,
@@ -12,7 +13,6 @@ import type {
import type { BuildQueryJoinAliases } from './buildQuery.js'
import { chainMethods } from '../find/chainMethods.js'
import { type GenericColumn } from '../types.js'
type Args = {
adapter: DrizzleAdapter
@@ -35,7 +35,7 @@ export const selectDistinct = ({
selectFields,
tableName,
where,
}: Args): QueryPromise<Record<string, GenericColumn> & { id: number | string }[]> => {
}: Args): QueryPromise<{ id: number | string }[] & Record<string, GenericColumn>> => {
if (Object.keys(joins).length > 0) {
if (where) {
chainedMethods.push({ args: [where], method: 'where' })

View File

@@ -35,7 +35,6 @@ export const queryDrafts: QueryDrafts = async function queryDrafts(
return {
...result,
docs: result.docs.map((doc) => {
// eslint-disable-next-line no-param-reassign
doc = {
id: doc.parent,
...doc.version,

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import type { Field, SanitizedConfig, TypeWithID } from 'payload'
import type { DrizzleAdapter } from '../../types.js'

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import type { Field } from 'payload'
import type { DrizzleAdapter } from '../../types.js'

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js'
type Args = {

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import type { ArrayRowToInsert } from '../transform/write/types.js'
import type { DrizzleAdapter, DrizzleTransaction } from '../types.js'

View File

@@ -18,18 +18,18 @@ type BaseArgs = {
tableName: string
}
type CreateArgs = BaseArgs & {
type CreateArgs = {
id?: never
operation: 'create'
upsertTarget?: never
where?: never
}
} & BaseArgs
type UpdateArgs = BaseArgs & {
type UpdateArgs = {
id?: number | string
operation: 'update'
upsertTarget?: GenericColumn
where?: SQL<unknown>
}
} & BaseArgs
export type Args = CreateArgs | UpdateArgs

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
export type BlocksMap = {
[path: string]: Record<string, unknown>[]
}

View File

@@ -1,7 +1,11 @@
import { jest } from '@jest/globals'
import type { Transporter } from 'nodemailer'
import nodemailer, { Transporter } from 'nodemailer'
import { nodemailerAdapter, NodemailerAdapterArgs } from './index.js'
import { jest } from '@jest/globals'
import nodemailer from 'nodemailer'
import type { NodemailerAdapterArgs } from './index.js'
import { nodemailerAdapter } from './index.js'
const defaultArgs: NodemailerAdapterArgs = {
defaultFromAddress: 'test@test.com',
@@ -9,7 +13,6 @@ const defaultArgs: NodemailerAdapterArgs = {
}
describe('email-nodemailer', () => {
describe('transport verification', () => {
let mockedVerify: jest.Mock<Transporter['verify']>
let mockTransport: Transporter
@@ -18,20 +21,21 @@ describe('email-nodemailer', () => {
mockedVerify = jest.fn<Transporter['verify']>()
mockTransport = nodemailer.createTransport({
name: 'existing-transport',
// eslint-disable-next-line @typescript-eslint/require-await
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-misused-promises
send: async (mail) => {
// eslint-disable-next-line no-console
console.log('mock send', mail)
},
version: '0.0.1',
verify: mockedVerify,
version: '0.0.1',
})
})
it('should be invoked when skipVerify = false', async () => {
await nodemailerAdapter({
...defaultArgs,
transport: mockTransport,
skipVerify: false,
transport: mockTransport,
})
expect(mockedVerify.mock.calls).toHaveLength(1)
@@ -40,8 +44,8 @@ describe('email-nodemailer', () => {
it('should be invoked when skipVerify is undefined', async () => {
await nodemailerAdapter({
...defaultArgs,
transport: mockTransport,
skipVerify: false,
transport: mockTransport,
})
expect(mockedVerify.mock.calls).toHaveLength(1)
@@ -50,8 +54,8 @@ describe('email-nodemailer', () => {
it('should not be invoked when skipVerify = true', async () => {
await nodemailerAdapter({
...defaultArgs,
transport: mockTransport,
skipVerify: true,
transport: mockTransport,
})
expect(mockedVerify.mock.calls).toHaveLength(0)

View File

@@ -704,7 +704,7 @@ export function buildObjectType({
const result = await context.req.payloadDataLoader.load(
createDataloaderCacheKey({
collectionSlug: collectionSlug as string,
collectionSlug,
currentDepth: 0,
depth: 0,
docID: id,
@@ -751,7 +751,7 @@ export function buildObjectType({
if (id) {
const relatedDocument = await context.req.payloadDataLoader.load(
createDataloaderCacheKey({
collectionSlug: relatedCollectionSlug as string,
collectionSlug: relatedCollectionSlug,
currentDepth: 0,
depth: 0,
docID: id,

View File

@@ -137,7 +137,7 @@ export const RootLayout = async ({
)?.docs?.[0]
: null
const isNavOpen = (navPreferences?.value as any)?.open ?? true
const isNavOpen = navPreferences?.value?.open ?? true
return (
<html data-theme={theme} dir={dir} lang={languageCode}>

View File

@@ -77,12 +77,12 @@ describe('reservedFieldNames - collections -', () => {
describe('auth -', () => {
const collectionWithAuth: CollectionConfig = {
slug: 'collection-with-auth',
fields: [],
auth: {
verify: true,
useAPIKey: true,
loginWithUsername: true,
useAPIKey: true,
verify: true,
},
fields: [],
}
it('should throw on hash', async () => {

View File

@@ -276,7 +276,7 @@ export const promise = async <T>({
if (typeof siblingData[field.name] === 'undefined') {
// If no incoming data, but existing document data is found, merge it in
if (typeof siblingDoc[field.name] !== 'undefined') {
siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name] as any)
siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])
// Otherwise compute default value
} else if (typeof field.defaultValue !== 'undefined') {

View File

@@ -1,7 +1,6 @@
import type { Config, Payload } from 'payload'
import { jest } from '@jest/globals'
import nodemailer from 'nodemailer'
import { defaults } from 'payload'
import { payloadCloudEmail } from './email.js'
@@ -11,24 +10,11 @@ describe('email', () => {
const skipVerify = true
const defaultDomain = 'test.com'
const apiKey = 'test'
let createTransportSpy: jest.Spied<any>
const mockedPayload: Payload = jest.fn() as unknown as Payload
beforeEach(() => {
defaultConfig = defaults as Config
createTransportSpy = jest.spyOn(nodemailer, 'createTransport').mockImplementation(() => {
return {
verify: jest.fn(),
} as unknown as ReturnType<typeof nodemailer.createTransport>
})
const createTestAccountSpy = jest.spyOn(nodemailer, 'createTestAccount').mockResolvedValue({
pass: 'password',
user: 'user',
web: 'ethereal.email',
} as unknown as nodemailer.TestAccount)
})
describe('not in Payload Cloud', () => {
@@ -76,8 +62,8 @@ describe('email', () => {
const initializedEmail = email({ payload: mockedPayload })
expect(initializedEmail.defaultFromName).toEqual(defaultFromName)
expect(initializedEmail.defaultFromAddress).toEqual(defaultFromAddress)
expect(initializedEmail.defaultFromName).toStrictEqual(defaultFromName)
expect(initializedEmail.defaultFromAddress).toStrictEqual(defaultFromAddress)
})
})
})

View File

@@ -100,8 +100,9 @@ describe('plugin', () => {
const existingTransport = nodemailer.createTransport({
name: 'existing-transport',
// eslint-disable-next-line @typescript-eslint/require-await
// eslint-disable-next-line @typescript-eslint/require-await, @typescript-eslint/no-misused-promises
send: async (mail) => {
// eslint-disable-next-line no-console
console.log('mock send', mail)
},
version: '0.0.1',