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 tableName: string
} }
export type Result = DBQueryConfig<'many', true, any, any> & { export type Result = {
with?: DBQueryConfig<'many', true, any, any> & { with?: {
_locales?: DBQueryConfig<'many', true, any, any> _locales?: DBQueryConfig<'many', true, any, any>
} } & DBQueryConfig<'many', true, any, any>
} } & DBQueryConfig<'many', true, any, any>
// Generate the Drizzle query for findMany based on // Generate the Drizzle query for findMany based on
// a collection field structure // 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 type { PayloadRequest } from 'payload'
import { import {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
import type { Config, Payload } from 'payload' import type { Config, Payload } from 'payload'
import { jest } from '@jest/globals' import { jest } from '@jest/globals'
import nodemailer from 'nodemailer'
import { defaults } from 'payload' import { defaults } from 'payload'
import { payloadCloudEmail } from './email.js' import { payloadCloudEmail } from './email.js'
@@ -11,24 +10,11 @@ describe('email', () => {
const skipVerify = true const skipVerify = true
const defaultDomain = 'test.com' const defaultDomain = 'test.com'
const apiKey = 'test' const apiKey = 'test'
let createTransportSpy: jest.Spied<any>
const mockedPayload: Payload = jest.fn() as unknown as Payload const mockedPayload: Payload = jest.fn() as unknown as Payload
beforeEach(() => { beforeEach(() => {
defaultConfig = defaults as Config 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', () => { describe('not in Payload Cloud', () => {
@@ -76,8 +62,8 @@ describe('email', () => {
const initializedEmail = email({ payload: mockedPayload }) const initializedEmail = email({ payload: mockedPayload })
expect(initializedEmail.defaultFromName).toEqual(defaultFromName) expect(initializedEmail.defaultFromName).toStrictEqual(defaultFromName)
expect(initializedEmail.defaultFromAddress).toEqual(defaultFromAddress) expect(initializedEmail.defaultFromAddress).toStrictEqual(defaultFromAddress)
}) })
}) })
}) })

View File

@@ -100,8 +100,9 @@ describe('plugin', () => {
const existingTransport = nodemailer.createTransport({ const existingTransport = nodemailer.createTransport({
name: 'existing-transport', 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) => { send: async (mail) => {
// eslint-disable-next-line no-console
console.log('mock send', mail) console.log('mock send', mail)
}, },
version: '0.0.1', version: '0.0.1',