Skip to content

Commit

Permalink
chore: apply code cleanups from typescript-eslint@v8's stylistic pres…
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg authored Jul 8, 2024
1 parent aa90b09 commit b520142
Show file tree
Hide file tree
Showing 48 changed files with 90 additions and 79 deletions.
2 changes: 1 addition & 1 deletion packages/adapters/fastify/web/src/resolveOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function isFullyQualifiedUrl(url: string) {
// eslint-disable-next-line no-new
new URL(url)
return true
} catch (e) {
} catch {
return false
}
}
12 changes: 6 additions & 6 deletions packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ export class DbAuthHandler<
user = await this.dbAccessor.findUnique({
where: { [this.options.authFields.username]: username },
})
} catch (e) {
} catch {
throw new DbAuthError.GenericError()
}

Expand Down Expand Up @@ -607,7 +607,7 @@ export class DbAuthHandler<
[this.options.authFields.resetTokenExpiresAt]: tokenExpires,
},
})
} catch (e) {
} catch {
throw new DbAuthError.GenericError()
}

Expand Down Expand Up @@ -738,7 +738,7 @@ export class DbAuthHandler<
[this.options.authFields.hashedPassword]: hashedPassword,
},
})
} catch (e) {
} catch {
throw new DbAuthError.GenericError()
}

Expand Down Expand Up @@ -1319,7 +1319,7 @@ export class DbAuthHandler<
[this.options.authFields.resetTokenExpiresAt]: null,
},
})
} catch (e) {
} catch {
throw new DbAuthError.GenericError()
}
}
Expand Down Expand Up @@ -1354,7 +1354,7 @@ export class DbAuthHandler<
user = await this.dbAccessor.findFirst({
where: findUniqueUserMatchCriteriaOptions,
})
} catch (e) {
} catch {
throw new DbAuthError.GenericError()
}

Expand Down Expand Up @@ -1503,7 +1503,7 @@ export class DbAuthHandler<
// try getting it from the body in JSON: { method: [methodName] }
try {
methodName = this.normalizedRequest.jsonBody.method
} catch (e) {
} catch {
// there's no body, or it's not JSON, `handler` will return a 404
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/api/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const decryptSession = (text: string | null) => {
const json = JSON.parse(data)

return [json, csrf]
} catch (e) {
} catch {
throw new DbAuthError.SessionDecryptionError()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const defaultGetRoles = (decoded: Record<string, any>): string[] => {
} else {
return roles ? [roles] : []
}
} catch (e) {
} catch {
return []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ jest.mock('@redwoodjs/cli-helpers', () => {
// jest.requireActual(@redwoodjs/cli-helpers) here, but I couldn't because
// jest doesn't support ESM
standardAuthHandler: async (args: AuthHandlerArgs) => {
args.notes && console.log(`\n ${args.notes.join('\n ')}\n`)
if (args.notes) {
console.log(`\n ${args.notes.join('\n ')}\n`)
}
},
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ jest.mock('@redwoodjs/cli-helpers', () => {
}
}

args.notes && console.log(`\n ${args.notes.join('\n ')}\n`)
if (args.notes) {
console.log(`\n ${args.notes.join('\n ')}\n`)
}
},
}
})
Expand Down
4 changes: 3 additions & 1 deletion packages/auth-providers/netlify/web/src/netlify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ function createAuthImplementation(netlifyIdentity: NetlifyIdentity) {
return resolve(user)
})
netlifyIdentity.on('close', () => {
!autoClosedModal && resolve(null)
if (!autoClosedModal) {
resolve(null)
}
})
netlifyIdentity.on('error', reject)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const defaultGetRoles = (decoded: PartialSupabaseDecoded): string[] => {
} else {
return roles ? [roles] : []
}
} catch (e) {
} catch {
return []
}
}
6 changes: 5 additions & 1 deletion packages/auth/src/__tests__/AuthProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ describe('Custom auth provider', () => {
<>
<button
onClick={() => {
isAuthenticated ? logOut() : logIn()
if (isAuthenticated) {
logOut()
} else {
logIn()
}
}}
>
{isAuthenticated ? 'Log Out' : 'Log In'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function ({ types: t }: { types: typeof types }): PluginObj {
// CONTINUE...
}

const newPath = getNewPath(value, <string>filename)
const newPath = getNewPath(value, filename as string)
if (!newPath) {
return
}
Expand Down Expand Up @@ -72,7 +72,7 @@ export default function ({ types: t }: { types: typeof types }): PluginObj {
// CONTINUE...
}

const newPath = getNewPath(value, <string>filename)
const newPath = getNewPath(value, filename as string)
if (!newPath) {
return
}
Expand Down
4 changes: 3 additions & 1 deletion packages/cli-helpers/src/auth/setupHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ export const standardAuthHandler = async ({

try {
await tasks.run()
notes && console.log(`\n ${notes.join('\n ')}\n`)
if (notes) {
console.log(`\n ${notes.join('\n ')}\n`)
}
} catch (e) {
if (isErrorWithMessage(e)) {
errorTelemetry(process.argv, e.message)
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-helpers/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const getPrettierOptions = async () => {
}

return options
} catch (e) {
} catch {
return undefined
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-helpers/src/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const getInstalledRedwoodVersion = () => {
try {
const packageJson = require('../../package.json')
return packageJson.version
} catch (e) {
} catch {
console.error(colors.error('Could not find installed redwood version'))
process.exit(1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export async function handler({
if (counters.error) {
process.exitCode = 1
}
} catch (e) {
} catch {
process.exitCode = 1
await db.$disconnect()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function handler({ force }: { force: boolean }) {
})

fs.writeFileSync(prettifyPath, prettifiedApp, 'utf-8')
} catch (error) {
} catch {
task.output =
"Couldn't prettify the changes. Please reformat the files manually if needed."
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/testHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function isInGitRepository() {
try {
execa.commandSync('git rev-parse --is-inside-work-tree')
return true
} catch (e) {
} catch {
return false
}
}
Expand All @@ -25,7 +25,7 @@ function isInMercurialRepository() {
try {
execa.commandSync('hg --cwd . root')
return true
} catch (e) {
} catch {
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/testLib/getFilesWithPattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getFilesWithPattern = ({
* Return an array of files that contain the pattern
*/
return stdout.toString().split('\n')
} catch (e) {
} catch {
return []
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/testUtils/matchTransformSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const matchTransformSnapshot: MatchTransformSnapshotFunction = async (
for (const extension of ['ts', 'tsx', 'js', 'jsx']) {
try {
fixturePath = require.resolve(`${maybeFixturePath}.${extension}`)
} catch (e) {
} catch {
continue
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function detectEmptyCells(taskContext: TaskInnerAPI) {

try {
fields = parseGqlQueryToAst(cellQuery)[0].fields
} catch (e) {
} catch {
warnings.push(cellPath)
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/codemods/src/lib/getFilesWithPattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getFilesWithPattern = ({
* Return an array of files that contain the pattern
*/
return stdout.toString().split('\n')
} catch (e) {
} catch {
return []
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/codemods/src/lib/prettify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getPrettierConfig = async () => {
`file://${path.join(getPaths().base, 'prettier.config.js')}`
)
return prettierConfig
} catch (e) {
} catch {
return undefined
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/codemods/src/testUtils/matchTransformSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const matchTransformSnapshot: MatchTransformSnapshotFunction = async (
for (const extension of ['ts', 'tsx', 'js', 'jsx']) {
try {
fixturePath = require.resolve(`${maybeFixturePath}.${extension}`)
} catch (e) {
} catch {
continue
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/forms/src/coercion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const SET_VALUE_AS_FUNCTIONS: Record<
}
try {
return JSON.parse(val)
} catch (e) {
} catch {
return NaN // represents invalid JSON parse to JSONValidation function
}
},
Expand All @@ -80,7 +80,7 @@ const SET_VALUE_AS_FUNCTIONS: Record<
}
try {
return JSON.parse(val)
} catch (e) {
} catch {
return NaN // represents invalid JSON parse to JSONValidation function
}
},
Expand All @@ -90,7 +90,7 @@ const SET_VALUE_AS_FUNCTIONS: Record<
}
try {
return JSON.parse(val)
} catch (e) {
} catch {
return NaN // represents invalid JSON parse to JSONValidation function
}
},
Expand All @@ -100,7 +100,7 @@ const SET_VALUE_AS_FUNCTIONS: Record<
}
try {
return JSON.parse(val)
} catch (e) {
} catch {
return NaN // represents invalid JSON parse to JSONValidation function
}
},
Expand Down
8 changes: 6 additions & 2 deletions packages/graphql-server/src/createGraphQLYoga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export const createGraphQLYoga = ({
} catch (e) {
logger.fatal(e as Error, '\n ⚠️ GraphQL server crashed \n')

onException && onException()
if (onException) {
onException()
}

// Forcefully crash the graphql server
// so users know that a misconfiguration has happened
Expand Down Expand Up @@ -210,7 +212,9 @@ export const createGraphQLYoga = ({

return { yoga, logger }
} catch (e) {
onException && onException()
if (onException) {
onException()
}
throw e
}
}
8 changes: 6 additions & 2 deletions packages/graphql-server/src/functions/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export const createGraphQLHandler = ({
}
} catch (e: any) {
logger.error(e)
onException && onException()
if (onException) {
onException()
}

lambdaResponse = {
body: JSON.stringify({ error: 'GraphQL execution failed' }),
Expand Down Expand Up @@ -159,7 +161,9 @@ export const createGraphQLHandler = ({
try {
return await handlerFn(event, context)
} catch (e) {
onException && onException()
if (onException) {
onException()
}

throw e
}
Expand Down
4 changes: 3 additions & 1 deletion packages/graphql-server/src/plugins/useRedwoodLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ export const useRedwoodLogger = (

return ({ result }) => {
result.forEach((item) => {
item.message && envelopLogger.error(item.message)
if (item.message) {
envelopLogger.error(item.message)
}
})
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/src/ts2js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const getPrettierConfig = async () => {
`file://${path.join(getPaths().base, 'prettier.config.js')}`
)
return prettierConfig
} catch (e) {
} catch {
return undefined
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/mailer/core/src/mailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Mailer<
this.logger.warn(
"Automatically loaded the '@redwoodjs/mailer-handler-in-memory' handler, this will be used to process mail in test mode",
)
} catch (_error) {
} catch {
this.logger.warn(
"No test handler specified and could not load the '@redwoodjs/mailer-handler-in-memory' handler automatically, this will prevent mail from being processed in test mode",
)
Expand All @@ -97,7 +97,7 @@ export class Mailer<
this.logger.warn(
"Automatically loaded the '@redwoodjs/mailer-handler-studio' handler, this will be used to process mail in development mode",
)
} catch (_error) {
} catch {
this.logger.warn(
"No development handler specified and could not load the '@redwoodjs/mailer-handler-studio' handler automatically, this will prevent mail from being processed in development mode",
)
Expand Down
2 changes: 1 addition & 1 deletion packages/prerender/src/babelPlugins/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function convertToDataUrl(assetPath: string) {
const base64AssetContents = fs.readFileSync(assetPath as string, 'base64')
const mimeType = mime.lookup(assetPath as string)
return `data:${mimeType};base64,${base64AssetContents}`
} catch (e) {
} catch {
console.warn(`Could not read file ${assetPath} for conversion to data uri`)
return ''
}
Expand Down
Loading

0 comments on commit b520142

Please sign in to comment.