chore(eslint): curly [skip-lint] (#7959)
Now enforcing curly brackets on all if statements. Includes auto-fixer. ```ts // ❌ Bad if (foo) foo++; // ✅ Good if (foo) { foo++; } ``` Note: this did not lint the `drizzle` package or any `db-*` packages. This will be done in the future.
This commit is contained in:
@@ -6,8 +6,12 @@ import type { Context } from '../types.js'
|
||||
|
||||
export function resetPassword(collection: Collection): any {
|
||||
async function resolver(_, args, context: Context) {
|
||||
if (args.locale) context.req.locale = args.locale
|
||||
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
|
||||
if (args.locale) {
|
||||
context.req.locale = args.locale
|
||||
}
|
||||
if (args.fallbackLocale) {
|
||||
context.req.fallbackLocale = args.fallbackLocale
|
||||
}
|
||||
|
||||
const options = {
|
||||
api: 'GraphQL',
|
||||
|
||||
@@ -6,8 +6,12 @@ import type { Context } from '../types.js'
|
||||
|
||||
export function verifyEmail(collection: Collection) {
|
||||
async function resolver(_, args, context: Context) {
|
||||
if (args.locale) context.req.locale = args.locale
|
||||
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
|
||||
if (args.locale) {
|
||||
context.req.locale = args.locale
|
||||
}
|
||||
if (args.fallbackLocale) {
|
||||
context.req.fallbackLocale = args.fallbackLocale
|
||||
}
|
||||
|
||||
const options = {
|
||||
api: 'GraphQL',
|
||||
|
||||
@@ -28,7 +28,9 @@ export function getDeleteResolver<TSlug extends CollectionSlug>(
|
||||
req = isolateObjectProperty(req, 'fallbackLocale')
|
||||
req.locale = args.locale || locale
|
||||
req.fallbackLocale = args.fallbackLocale || fallbackLocale
|
||||
if (!req.query) req.query = {}
|
||||
if (!req.query) {
|
||||
req.query = {}
|
||||
}
|
||||
|
||||
const draft: boolean =
|
||||
args.draft ?? req.query?.draft === 'false'
|
||||
@@ -36,7 +38,9 @@ export function getDeleteResolver<TSlug extends CollectionSlug>(
|
||||
: req.query?.draft === 'true'
|
||||
? true
|
||||
: undefined
|
||||
if (typeof draft === 'boolean') req.query.draft = String(draft)
|
||||
if (typeof draft === 'boolean') {
|
||||
req.query.draft = String(draft)
|
||||
}
|
||||
|
||||
context.req = req
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ export function findResolver(collection: Collection): Resolver {
|
||||
req = isolateObjectProperty(req, ['locale', 'fallbackLocale', 'transactionID'])
|
||||
req.locale = args.locale || locale
|
||||
req.fallbackLocale = args.fallbackLocale || fallbackLocale
|
||||
if (!req.query) req.query = {}
|
||||
if (!req.query) {
|
||||
req.query = {}
|
||||
}
|
||||
|
||||
const draft: boolean =
|
||||
args.draft ?? req.query?.draft === 'false'
|
||||
@@ -39,7 +41,9 @@ export function findResolver(collection: Collection): Resolver {
|
||||
: req.query?.draft === 'true'
|
||||
? true
|
||||
: undefined
|
||||
if (typeof draft === 'boolean') req.query.draft = String(draft)
|
||||
if (typeof draft === 'boolean') {
|
||||
req.query.draft = String(draft)
|
||||
}
|
||||
|
||||
context.req = req
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ export function findByIDResolver<TSlug extends CollectionSlug>(
|
||||
req = isolateObjectProperty(req, 'fallbackLocale')
|
||||
req.locale = args.locale || locale
|
||||
req.fallbackLocale = args.fallbackLocale || fallbackLocale
|
||||
if (!req.query) req.query = {}
|
||||
if (!req.query) {
|
||||
req.query = {}
|
||||
}
|
||||
|
||||
const draft: boolean =
|
||||
args.draft ?? req.query?.draft === 'false'
|
||||
@@ -36,7 +38,9 @@ export function findByIDResolver<TSlug extends CollectionSlug>(
|
||||
: req.query?.draft === 'true'
|
||||
? true
|
||||
: undefined
|
||||
if (typeof draft === 'boolean') req.query.draft = String(draft)
|
||||
if (typeof draft === 'boolean') {
|
||||
req.query.draft = String(draft)
|
||||
}
|
||||
|
||||
context.req = req
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@ export function findVersionsResolver(collection: Collection): Resolver {
|
||||
req = isolateObjectProperty(req, 'fallbackLocale')
|
||||
req.locale = args.locale || locale
|
||||
req.fallbackLocale = args.fallbackLocale || fallbackLocale
|
||||
if (!req.query) req.query = {}
|
||||
if (!req.query) {
|
||||
req.query = {}
|
||||
}
|
||||
|
||||
const draft: boolean =
|
||||
args.draft ?? req.query?.draft === 'false'
|
||||
@@ -37,7 +39,9 @@ export function findVersionsResolver(collection: Collection): Resolver {
|
||||
: req.query?.draft === 'true'
|
||||
? true
|
||||
: undefined
|
||||
if (typeof draft === 'boolean') req.query.draft = String(draft)
|
||||
if (typeof draft === 'boolean') {
|
||||
req.query.draft = String(draft)
|
||||
}
|
||||
|
||||
context.req = req
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ export function updateResolver<TSlug extends CollectionSlug>(
|
||||
req = isolateObjectProperty(req, 'fallbackLocale')
|
||||
req.locale = args.locale || locale
|
||||
req.fallbackLocale = args.fallbackLocale || fallbackLocale
|
||||
if (!req.query) req.query = {}
|
||||
if (!req.query) {
|
||||
req.query = {}
|
||||
}
|
||||
|
||||
const draft: boolean =
|
||||
args.draft ?? req.query?.draft === 'false'
|
||||
@@ -38,7 +40,9 @@ export function updateResolver<TSlug extends CollectionSlug>(
|
||||
: req.query?.draft === 'true'
|
||||
? true
|
||||
: undefined
|
||||
if (typeof draft === 'boolean') req.query.draft = String(draft)
|
||||
if (typeof draft === 'boolean') {
|
||||
req.query.draft = String(draft)
|
||||
}
|
||||
|
||||
context.req = req
|
||||
|
||||
|
||||
@@ -6,8 +6,12 @@ import type { Context } from '../types.js'
|
||||
|
||||
export function findOne(globalConfig: SanitizedGlobalConfig): Document {
|
||||
return async function resolver(_, args, context: Context) {
|
||||
if (args.locale) context.req.locale = args.locale
|
||||
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
|
||||
if (args.locale) {
|
||||
context.req.locale = args.locale
|
||||
}
|
||||
if (args.fallbackLocale) {
|
||||
context.req.fallbackLocale = args.fallbackLocale
|
||||
}
|
||||
|
||||
const { slug } = globalConfig
|
||||
|
||||
|
||||
@@ -19,8 +19,12 @@ export type Resolver = (
|
||||
|
||||
export function findVersionByID(globalConfig: SanitizedGlobalConfig): Resolver {
|
||||
return async function resolver(_, args, context: Context) {
|
||||
if (args.locale) context.req.locale = args.locale
|
||||
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
|
||||
if (args.locale) {
|
||||
context.req.locale = args.locale
|
||||
}
|
||||
if (args.fallbackLocale) {
|
||||
context.req.fallbackLocale = args.fallbackLocale
|
||||
}
|
||||
|
||||
const options = {
|
||||
id: args.id,
|
||||
|
||||
@@ -22,8 +22,12 @@ export function update<TSlug extends GlobalSlug>(
|
||||
globalConfig: SanitizedGlobalConfig,
|
||||
): Resolver<TSlug> {
|
||||
return async function resolver(_, args, context: Context) {
|
||||
if (args.locale) context.req.locale = args.locale
|
||||
if (args.fallbackLocale) context.req.fallbackLocale = args.fallbackLocale
|
||||
if (args.locale) {
|
||||
context.req.locale = args.locale
|
||||
}
|
||||
if (args.fallbackLocale) {
|
||||
context.req.fallbackLocale = args.fallbackLocale
|
||||
}
|
||||
|
||||
const { slug } = globalConfig
|
||||
|
||||
|
||||
@@ -97,7 +97,9 @@ export function buildMutationInputType({
|
||||
parentName: fullName,
|
||||
})
|
||||
|
||||
if (!type) return inputObjectTypeConfig
|
||||
if (!type) {
|
||||
return inputObjectTypeConfig
|
||||
}
|
||||
|
||||
type = new GraphQLList(withNullableType(field, type, forceNullable))
|
||||
return {
|
||||
@@ -120,7 +122,9 @@ export function buildMutationInputType({
|
||||
collapsible: (inputObjectTypeConfig: InputObjectTypeConfig, field: CollapsibleField) =>
|
||||
field.fields.reduce((acc, subField: CollapsibleField) => {
|
||||
const addSubField = fieldToSchemaMap[subField.type]
|
||||
if (addSubField) return addSubField(acc, subField)
|
||||
if (addSubField) {
|
||||
return addSubField(acc, subField)
|
||||
}
|
||||
return acc
|
||||
}, inputObjectTypeConfig),
|
||||
date: (inputObjectTypeConfig: InputObjectTypeConfig, field: DateField) => ({
|
||||
@@ -142,9 +146,13 @@ export function buildMutationInputType({
|
||||
parentName: fullName,
|
||||
})
|
||||
|
||||
if (!type) return inputObjectTypeConfig
|
||||
if (!type) {
|
||||
return inputObjectTypeConfig
|
||||
}
|
||||
|
||||
if (requiresAtLeastOneField) type = new GraphQLNonNull(type)
|
||||
if (requiresAtLeastOneField) {
|
||||
type = new GraphQLNonNull(type)
|
||||
}
|
||||
return {
|
||||
...inputObjectTypeConfig,
|
||||
[field.name]: { type },
|
||||
@@ -227,7 +235,9 @@ export function buildMutationInputType({
|
||||
row: (inputObjectTypeConfig: InputObjectTypeConfig, field: RowField) =>
|
||||
field.fields.reduce((acc, subField: Field) => {
|
||||
const addSubField = fieldToSchemaMap[subField.type]
|
||||
if (addSubField) return addSubField(acc, subField)
|
||||
if (addSubField) {
|
||||
return addSubField(acc, subField)
|
||||
}
|
||||
return acc
|
||||
}, inputObjectTypeConfig),
|
||||
select: (inputObjectTypeConfig: InputObjectTypeConfig, field: SelectField) => {
|
||||
@@ -274,9 +284,13 @@ export function buildMutationInputType({
|
||||
parentName: fullName,
|
||||
})
|
||||
|
||||
if (!type) return acc
|
||||
if (!type) {
|
||||
return acc
|
||||
}
|
||||
|
||||
if (requiresAtLeastOneField) type = new GraphQLNonNull(type)
|
||||
if (requiresAtLeastOneField) {
|
||||
type = new GraphQLNonNull(type)
|
||||
}
|
||||
return {
|
||||
...acc,
|
||||
[tab.name]: { type },
|
||||
@@ -287,7 +301,9 @@ export function buildMutationInputType({
|
||||
...acc,
|
||||
...tab.fields.reduce((subFieldSchema, subField) => {
|
||||
const addSubField = fieldToSchemaMap[subField.type]
|
||||
if (addSubField) return addSubField(subFieldSchema, subField)
|
||||
if (addSubField) {
|
||||
return addSubField(subFieldSchema, subField)
|
||||
}
|
||||
return subFieldSchema
|
||||
}, acc),
|
||||
}
|
||||
|
||||
@@ -171,7 +171,9 @@ export function buildObjectType({
|
||||
collapsible: (objectTypeConfig: ObjectTypeConfig, field: CollapsibleField) =>
|
||||
field.fields.reduce((objectTypeConfigWithCollapsibleFields, subField) => {
|
||||
const addSubField = fieldToSchemaMap[subField.type]
|
||||
if (addSubField) return addSubField(objectTypeConfigWithCollapsibleFields, subField)
|
||||
if (addSubField) {
|
||||
return addSubField(objectTypeConfigWithCollapsibleFields, subField)
|
||||
}
|
||||
return objectTypeConfigWithCollapsibleFields
|
||||
}, objectTypeConfig),
|
||||
date: (objectTypeConfig: ObjectTypeConfig, field: DateField) => ({
|
||||
@@ -459,7 +461,9 @@ export function buildObjectType({
|
||||
},
|
||||
async resolve(parent, args, context: Context) {
|
||||
let depth = config.defaultDepth
|
||||
if (typeof args.depth !== 'undefined') depth = args.depth
|
||||
if (typeof args.depth !== 'undefined') {
|
||||
depth = args.depth
|
||||
}
|
||||
if (!field?.editor) {
|
||||
throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor
|
||||
}
|
||||
@@ -506,7 +510,9 @@ export function buildObjectType({
|
||||
row: (objectTypeConfig: ObjectTypeConfig, field: RowField) =>
|
||||
field.fields.reduce((objectTypeConfigWithRowFields, subField) => {
|
||||
const addSubField = fieldToSchemaMap[subField.type]
|
||||
if (addSubField) return addSubField(objectTypeConfigWithRowFields, subField)
|
||||
if (addSubField) {
|
||||
return addSubField(objectTypeConfigWithRowFields, subField)
|
||||
}
|
||||
return objectTypeConfigWithRowFields
|
||||
}, objectTypeConfig),
|
||||
select: (objectTypeConfig: ObjectTypeConfig, field: SelectField) => {
|
||||
@@ -560,7 +566,9 @@ export function buildObjectType({
|
||||
...tabSchema,
|
||||
...tab.fields.reduce((subFieldSchema, subField) => {
|
||||
const addSubField = fieldToSchemaMap[subField.type]
|
||||
if (addSubField) return addSubField(subFieldSchema, subField)
|
||||
if (addSubField) {
|
||||
return addSubField(subFieldSchema, subField)
|
||||
}
|
||||
return subFieldSchema
|
||||
}, tabSchema),
|
||||
}
|
||||
|
||||
@@ -148,7 +148,9 @@ export function buildPolicyType(args: BuildPolicyType): GraphQLObjectType {
|
||||
|
||||
let operations = []
|
||||
|
||||
if (graphQL === false) return null
|
||||
if (graphQL === false) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (type === 'collection') {
|
||||
operations = ['create', 'read', 'update', 'delete']
|
||||
|
||||
@@ -57,7 +57,9 @@ export function initCollections({ config, graphqlResult }: InitCollectionsGraphQ
|
||||
config: { fields, graphQL = {} as SanitizedCollectionConfig['graphQL'], versions },
|
||||
} = collection
|
||||
|
||||
if (!graphQL) return
|
||||
if (!graphQL) {
|
||||
return
|
||||
}
|
||||
|
||||
let singularName
|
||||
let pluralName
|
||||
|
||||
@@ -36,7 +36,9 @@ export function initGlobals({ config, graphqlResult }: InitGlobalsGraphQLArgs):
|
||||
|
||||
const forceNullableObjectType = Boolean(versions?.drafts)
|
||||
|
||||
if (!graphqlResult.globals.graphQL) graphqlResult.globals.graphQL = {}
|
||||
if (!graphqlResult.globals.graphQL) {
|
||||
graphqlResult.globals.graphQL = {}
|
||||
}
|
||||
|
||||
const updateMutationInputType = buildMutationInputType({
|
||||
name: formattedName,
|
||||
|
||||
@@ -263,7 +263,9 @@ export const withOperators = (
|
||||
field: FieldAffectingData,
|
||||
parentName: string,
|
||||
): GraphQLInputObjectType => {
|
||||
if (!defaults?.[field.type]) throw new Error(`Error: ${field.type} has no defaults configured.`)
|
||||
if (!defaults?.[field.type]) {
|
||||
throw new Error(`Error: ${field.type} has no defaults configured.`)
|
||||
}
|
||||
|
||||
const name = `${combineParentName(parentName, field.name)}_operator`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user