chore: run lint and prettier on entire codebase

This commit is contained in:
Alessio Gravili
2024-07-11 15:27:01 -04:00
parent f8ab5a9f1e
commit 83fd4c6622
364 changed files with 2578 additions and 2658 deletions

View File

@@ -21,6 +21,7 @@ const openAccess = {
const collectionWithName = (collectionSlug: string): CollectionConfig => {
return {
slug: collectionSlug,
access: openAccess,
fields: [
{
@@ -28,7 +29,6 @@ const collectionWithName = (collectionSlug: string): CollectionConfig => {
type: 'text',
},
],
slug: collectionSlug,
}
}
@@ -40,18 +40,15 @@ export const pointSlug = 'point'
export const errorOnHookSlug = 'error-on-hooks'
export default buildConfigWithDefaults({
localization: {
defaultLocale: 'en',
locales: ['en', 'es'],
},
collections: [
{
slug: 'users',
access: openAccess,
auth: true,
fields: [],
slug: 'users',
},
{
slug: pointSlug,
access: openAccess,
fields: [
{
@@ -59,9 +56,9 @@ export default buildConfigWithDefaults({
type: 'point',
},
],
slug: pointSlug,
},
{
slug,
access: openAccess,
fields: [
{
@@ -78,85 +75,91 @@ export default buildConfigWithDefaults({
},
{
name: 'min',
min: 10,
type: 'number',
min: 10,
},
// Relationship
{
name: 'relationField',
relationTo: relationSlug,
type: 'relationship',
relationTo: relationSlug,
},
{
name: 'relationToCustomID',
relationTo: 'custom-ids',
type: 'relationship',
relationTo: 'custom-ids',
},
// Relation hasMany
{
name: 'relationHasManyField',
type: 'relationship',
hasMany: true,
relationTo: relationSlug,
type: 'relationship',
},
// Relation multiple relationTo
{
name: 'relationMultiRelationTo',
relationTo: [relationSlug, 'dummy'],
type: 'relationship',
relationTo: [relationSlug, 'dummy'],
},
// Relation multiple relationTo hasMany
{
name: 'relationMultiRelationToHasMany',
type: 'relationship',
hasMany: true,
relationTo: [relationSlug, 'dummy'],
type: 'relationship',
},
{
name: 'A1',
type: 'group',
fields: [
{
name: 'A2',
defaultValue: 'textInRowInGroup',
type: 'text',
defaultValue: 'textInRowInGroup',
},
],
type: 'group',
},
{
name: 'B1',
type: 'group',
fields: [
{
type: 'collapsible',
fields: [
{
name: 'B2',
defaultValue: 'textInRowInGroup',
type: 'text',
defaultValue: 'textInRowInGroup',
},
],
label: 'Collapsible',
type: 'collapsible',
},
],
type: 'group',
},
{
name: 'C1',
type: 'group',
fields: [
{
name: 'C2Text',
type: 'text',
},
{
type: 'row',
fields: [
{
type: 'collapsible',
fields: [
{
name: 'C2',
type: 'group',
fields: [
{
type: 'row',
fields: [
{
type: 'collapsible',
fields: [
{
name: 'C3',
@@ -164,46 +167,48 @@ export default buildConfigWithDefaults({
},
],
label: 'Collapsible2',
type: 'collapsible',
},
],
type: 'row',
},
],
type: 'group',
},
],
label: 'Collapsible2',
type: 'collapsible',
},
],
type: 'row',
},
],
type: 'group',
},
{
type: 'tabs',
tabs: [
{
name: 'D1',
fields: [
{
name: 'D2',
type: 'group',
fields: [
{
type: 'row',
fields: [
{
type: 'collapsible',
fields: [
{
type: 'tabs',
tabs: [
{
fields: [
{
name: 'D3',
type: 'group',
fields: [
{
type: 'row',
fields: [
{
type: 'collapsible',
fields: [
{
name: 'D4',
@@ -211,40 +216,32 @@ export default buildConfigWithDefaults({
},
],
label: 'Collapsible2',
type: 'collapsible',
},
],
type: 'row',
},
],
type: 'group',
},
],
label: 'Tab1',
},
],
type: 'tabs',
},
],
label: 'Collapsible2',
type: 'collapsible',
},
],
type: 'row',
},
],
type: 'group',
},
],
label: 'Tab1',
},
],
type: 'tabs',
},
],
slug,
},
{
slug: 'custom-ids',
access: {
read: () => true,
},
@@ -258,7 +255,6 @@ export default buildConfigWithDefaults({
type: 'text',
},
],
slug: 'custom-ids',
},
collectionWithName(relationSlug),
collectionWithName('dummy'),
@@ -299,10 +295,10 @@ export default buildConfigWithDefaults({
fields: [
{
name: 'payloadAPI',
type: 'text',
hooks: {
afterRead: [({ req }) => req.payloadAPI],
},
type: 'text',
},
],
},
@@ -314,32 +310,32 @@ export default buildConfigWithDefaults({
fields: [
{
name: 'payloadAPI',
type: 'text',
hooks: {
afterRead: [({ req }) => req.payloadAPI],
},
type: 'text',
},
{
name: 'relation',
relationTo: 'payload-api-test-ones',
type: 'relationship',
relationTo: 'payload-api-test-ones',
},
],
},
{
slug: 'content-type',
access: {
read: () => true,
},
fields: [
{
name: 'contentType',
type: 'text',
hooks: {
afterRead: [({ req }) => req.headers?.get('content-type')],
},
type: 'text',
},
],
slug: 'content-type',
},
{
slug: 'cyclical-relationship',
@@ -356,8 +352,8 @@ export default buildConfigWithDefaults({
relationTo: 'cyclical-relationship',
},
{
type: 'upload',
name: 'media',
type: 'upload',
relationTo: 'media',
},
],
@@ -368,23 +364,19 @@ export default buildConfigWithDefaults({
{
slug: 'media',
access: openAccess,
upload: true,
fields: [
{
name: 'title',
type: 'text',
},
],
upload: true,
},
],
graphQL: {
queries: (GraphQL) => {
return {
QueryWithInternalError: {
resolve: () => {
// Throwing an internal error with potentially sensitive data
throw new Error('Lost connection to the Pentagon. Secret data: ******')
},
type: new GraphQL.GraphQLObjectType({
name: 'QueryWithInternalError',
fields: {
@@ -393,10 +385,18 @@ export default buildConfigWithDefaults({
},
},
}),
resolve: () => {
// Throwing an internal error with potentially sensitive data
throw new Error('Lost connection to the Pentagon. Secret data: ******')
},
},
}
},
},
localization: {
defaultLocale: 'en',
locales: ['en', 'es'],
},
onInit: async (payload) => {
await payload.create({
collection: 'users',

View File

@@ -1,11 +1,12 @@
import { rootEslintConfig, rootParserOptions } from '../../eslint.config.js'
import { rootParserOptions } from '../../eslint.config.js'
import testEslintConfig from '../eslint.config.js'
/** @typedef {import('eslint').Linter.FlatConfig} */
let FlatConfig
/** @type {FlatConfig[]} */
export const index = [
...rootEslintConfig,
...testEslintConfig,
{
languageOptions: {
parserOptions: {

View File

@@ -979,8 +979,8 @@ describe('collections-graphql', () => {
})
await payload.update({
collection: 'cyclical-relationship',
id: newDoc.id,
collection: 'cyclical-relationship',
data: {
relationToSelf: newDoc.id,
},
@@ -1013,16 +1013,16 @@ describe('collections-graphql', () => {
// publish doc
const newDoc = await payload.create({
collection: 'cyclical-relationship',
draft: false,
data: {
title: publishValue,
},
draft: false,
})
// create cyclical relationship
await payload.update({
collection: 'cyclical-relationship',
id: newDoc.id,
collection: 'cyclical-relationship',
data: {
relationToSelf: newDoc.id,
},
@@ -1030,12 +1030,12 @@ describe('collections-graphql', () => {
// save new version
await payload.update({
collection: 'cyclical-relationship',
id: newDoc.id,
draft: true,
collection: 'cyclical-relationship',
data: {
title: draftValue,
},
draft: true,
})
const draftParentPublishedChild = `{
@@ -1084,10 +1084,10 @@ describe('collections-graphql', () => {
const mediaDoc = await payload.create({
collection: 'media',
file,
data: {
title: 'example',
},
file,
})
// doc with upload relation