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:
Elliot DeNolf
2024-08-29 10:15:36 -04:00
committed by GitHub
parent dd3d985091
commit 142616e6ad
267 changed files with 1681 additions and 611 deletions

View File

@@ -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',

View File

@@ -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',

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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,

View File

@@ -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

View File

@@ -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),
}

View File

@@ -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),
}

View File

@@ -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']

View File

@@ -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

View File

@@ -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,

View File

@@ -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`