Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade eslint and prettier packages including formatting fixes #2540

Merged
merged 4 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/api-server/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import express from 'express'
import type { Response, Request, Application } from 'express'
import morgan from 'morgan'

import type { Response, Request, Application } from 'express'

// Base express app, with common config
const createApp = (): Application => {
const app = express()
Expand Down
2 changes: 1 addition & 1 deletion packages/api-server/src/error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Youch from 'youch'
import forTerminal from 'youch-terminal'
import Youch from 'youch'

/**
* This function will print a pretty version of an error in the terminal.
Expand Down
4 changes: 2 additions & 2 deletions packages/api-server/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import withApiProxy from './middleware/withApiProxy'
import withFunctions from './middleware/withFunctions'
import withWebServer from './middleware/withWebServer'
import { startServer } from './server'

import type { HttpServerParams } from './server'

/*
Expand Down Expand Up @@ -35,8 +36,7 @@ export const webCliOptions = {
apiHost: {
alias: 'api-host',
type: 'string',
desc:
'Forward requests from the apiProxyPath, defined in redwood.toml to this host',
desc: 'Forward requests from the apiProxyPath, defined in redwood.toml to this host',
},
} as const

Expand Down
3 changes: 2 additions & 1 deletion packages/api-server/src/middleware/withApiProxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Application } from 'express'
import { createProxyMiddleware } from 'http-proxy-middleware'

import type { Application } from 'express'

interface ApiProxyOptions {
apiProxyPath: string
apiHost?: string
Expand Down
5 changes: 3 additions & 2 deletions packages/api-server/src/middleware/withFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import path from 'path'

import type { Handler } from 'aws-lambda'
import bodyParser from 'body-parser'
import type { Application, Request, Response } from 'express'
import glob from 'glob'
import escape from 'lodash.escape'

import { getPaths } from '@redwoodjs/internal'

import { requestHandler } from '../requestHandlers/awsLambda'

import type { Handler } from 'aws-lambda'
import type { Application, Request, Response } from 'express'

export type Lambdas = Record<string, Handler>
const LAMBDA_FUNCTIONS: Lambdas = {}

Expand Down
3 changes: 2 additions & 1 deletion packages/api-server/src/middleware/withWebServer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import fs from 'fs'
import path from 'path'

import type { Application } from 'express'
import express from 'express'

import { getPaths } from '@redwoodjs/internal'

import type { Application } from 'express'

const withWebServer = (app: Application) => {
const indexContent = fs.readFileSync(
path.join(getPaths().web.dist, '/index.html'),
Expand Down
26 changes: 13 additions & 13 deletions packages/api-server/src/requestHandlers/awsLambda.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import qs from 'qs'

import { handleError } from '../error'

import type {
APIGatewayProxyResult,
APIGatewayProxyEvent,
Handler,
} from 'aws-lambda'
import type { Response, Request } from 'express'
import qs from 'qs'

import { handleError } from '../error'

export const parseBody = (rawBody: string | Buffer) => {
if (typeof rawBody === 'string') {
Expand Down Expand Up @@ -91,17 +92,16 @@ export const requestHandler = async (
// We take the express request object and convert it into a lambda function event.
const event = lambdaEventForExpressRequest(req)

const handlerCallback = (expressResFn: Response) => (
error: Error,
lambdaResult: APIGatewayProxyResult
) => {
if (error) {
expressResponseForLambdaError(expressResFn, error)
return
}
const handlerCallback =
(expressResFn: Response) =>
(error: Error, lambdaResult: APIGatewayProxyResult) => {
if (error) {
expressResponseForLambdaError(expressResFn, error)
return
}

expressResponseForLambdaResult(expressResFn, lambdaResult)
}
expressResponseForLambdaResult(expressResFn, lambdaResult)
}

// Execute the lambda function.
// https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/auth/decoders/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import type { GlobalContext } from 'src/globalContext'
Expand All @@ -10,6 +8,8 @@ import { ethereum } from './ethereum'
import { netlify } from './netlify'
import { nhost } from './nhost'
import { supabase } from './supabase'

import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'
const noop = (token: string) => token

interface Req {
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/auth/decoders/netlify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Context as LambdaContext, ClientContext } from 'aws-lambda'
import jwt, { TokenExpiredError } from 'jsonwebtoken'

import type { Context as LambdaContext, ClientContext } from 'aws-lambda'
// import type { TokenExpiredError } from 'jsonwebtoken'

type NetlifyContext = ClientContext & {
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import type { GlobalContext } from 'src/globalContext'

import { decodeToken } from './decoders'

import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

// This is shared by `@redwoodjs/web`
const AUTH_PROVIDER_HEADER = 'auth-provider'

Expand Down
11 changes: 6 additions & 5 deletions packages/api/src/auth/verifiers/common.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import jwtVerifier from './jwtVerifier'
import type { JwtVerifier } from './jwtVerifier'
import secretKeyVerifier from './secretKeyVerifier'
import type { SecretKeyVerifier } from './secretKeyVerifier'
import sha1Verifier from './sha1Verifier'
import type { Sha1Verifier } from './sha1Verifier'
import sha256Verifier from './sha256Verifier'
import type { Sha256Verifier } from './sha256Verifier'
import skipVerifier from './skipVerifier'
import type { SkipVerifier } from './skipVerifier'
import timestampSchemeVerifier from './timestampSchemeVerifier'

import type { JwtVerifier } from './jwtVerifier'
import type { SecretKeyVerifier } from './secretKeyVerifier'
import type { Sha1Verifier } from './sha1Verifier'
import type { Sha256Verifier } from './sha256Verifier'
import type { SkipVerifier } from './skipVerifier'
import type { TimestampSchemeVerifier } from './timestampSchemeVerifier'

export const verifierLookup = {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/auth/verifiers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { verifierLookup } from './common'

import type {
SupportedVerifierTypes,
VerifyOptions,
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/auth/verifiers/jwtVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
WebhookVerificationError,
DEFAULT_WEBHOOK_SECRET,
} from './common'

import type { WebhookVerifier, VerifyOptions } from './common'

export interface JwtVerifier extends WebhookVerifier {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/auth/verifiers/secretKeyVerifier.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WebhookVerificationError, DEFAULT_WEBHOOK_SECRET } from './common'

import type { WebhookVerifier, VerifyOptions } from './common'

export interface SecretKeyVerifier extends WebhookVerifier {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/auth/verifiers/sha1Verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
VERIFICATION_ERROR_MESSAGE,
DEFAULT_WEBHOOK_SECRET,
} from './common'

import type { WebhookVerifier, VerifyOptions } from './common'

export interface Sha1Verifier extends WebhookVerifier {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/auth/verifiers/sha256Verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
VERIFICATION_ERROR_MESSAGE,
DEFAULT_WEBHOOK_SECRET,
} from './common'

import type { WebhookVerifier, VerifyOptions } from './common'

export interface Sha256Verifier extends WebhookVerifier {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/auth/verifiers/timestampSchemeVerifier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createHmac } from 'crypto'

import { WebhookVerificationError, DEFAULT_WEBHOOK_SECRET } from './common'

import type { WebhookVerifier, VerifyOptions } from './common'

export interface TimestampSchemeVerifier extends WebhookVerifier {
Expand Down
7 changes: 4 additions & 3 deletions packages/api/src/functions/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import type { Context, ContextFunction } from 'apollo-server-core'
import type { Config, CreateHandlerOptions } from 'apollo-server-lambda'
import { ApolloServer } from 'apollo-server-lambda'
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { AuthContextPayload } from 'src/auth'
import { getAuthenticationContext } from 'src/auth'
Expand All @@ -12,6 +9,10 @@ import {
usePerRequestContext,
} from 'src/globalContext'

import type { Context, ContextFunction } from 'apollo-server-core'
import type { Config, CreateHandlerOptions } from 'apollo-server-lambda'
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

export type GetCurrentUser = (
decoded: AuthContextPayload[0],
raw: AuthContextPayload[1],
Expand Down
3 changes: 1 addition & 2 deletions packages/api/src/global.api-auto-imports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable no-redeclare, no-undef */
import type _gql from 'graphql-tag'

import type { GlobalContext } from './globalContext'
import type _gql from 'graphql-tag'

declare global {
const gql: typeof _gql
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PrismaClient } from '@prisma/client'
import * as prettyPrint from 'pino-pretty'
import pino, {
BaseLogger,
DestinationStream,
Expand All @@ -7,7 +8,6 @@ import pino, {
PrettyOptions,
redactOptions,
} from 'pino'
import * as prettyPrint from 'pino-pretty'

export type LogLevel = 'info' | 'query' | 'warn' | 'error'

Expand Down
3 changes: 1 addition & 2 deletions packages/api/src/logger/logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ describe('logger', () => {

logger.info(
{
jwt:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
},
'test of a redacted JWT'
)
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/makeMergedSchema/makeMergedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import {
IResolvers,
IExecutableSchemaDefinition,
} from 'apollo-server-lambda'
import type { GraphQLSchema, GraphQLFieldMap } from 'graphql'
import merge from 'lodash.merge'
import omitBy from 'lodash.omitby'

import { Services, GraphQLTypeWithFields } from 'src/types'

import * as rootSchema from './rootSchema'

import type { GraphQLSchema, GraphQLFieldMap } from 'graphql'

const mapFieldsToService = ({
fields = {},
resolvers: unmappedResolvers,
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/webhooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { APIGatewayProxyEvent } from 'aws-lambda'

import {
createVerifier,
VerifyOptions,
Expand All @@ -8,6 +6,8 @@ import {
SupportedVerifierTypes,
} from 'src/auth/verifiers'

import type { APIGatewayProxyEvent } from 'aws-lambda'

export {
VerifyOptions,
WebhookVerificationError,
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/webhooks/webhooks.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { APIGatewayProxyEvent } from 'aws-lambda'

import {
signPayload,
verifyEvent,
Expand All @@ -8,6 +6,8 @@ import {
DEFAULT_WEBHOOK_SIGNATURE_HEADER,
} from './index'

import type { APIGatewayProxyEvent } from 'aws-lambda'

const payload = 'No more secrets, Marty.'
const secret = 'MY_VOICE_IS_MY_PASSPORT_VERIFY_ME'

Expand Down
3 changes: 2 additions & 1 deletion packages/auth/src/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react'

import { createAuthClient } from './authClients'

import type {
AuthClient,
SupportedAuthTypes,
SupportedAuthClients,
SupportedUserMetadata,
} from './authClients'
import { createAuthClient } from './authClients'

export interface CurrentUser {
roles?: Array<string>
Expand Down
3 changes: 2 additions & 1 deletion packages/auth/src/__tests__/AuthProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import '@testing-library/jest-dom/extend-expect'
import { graphql } from 'msw'
import { setupServer } from 'msw/node'

import type { AuthClient } from '../authClients'
import { AuthProvider } from '../AuthProvider'
import { useAuth } from '../useAuth'

import type { AuthClient } from '../authClients'

let CURRENT_USER_DATA: { name: string; email: string; roles?: string[] } = {
name: 'Peter Pistorius',
email: 'nospam@example.net',
Expand Down
3 changes: 1 addition & 2 deletions packages/auth/src/authClients/auth0.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Auth0Client as Auth0 } from '@auth0/auth0-spa-js'

import type { AuthClient } from './'
import type { Auth0Client as Auth0 } from '@auth0/auth0-spa-js'

export type AuthClientAuth0 = AuthClient

Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/authClients/azureActiveDirectory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AuthClient } from './'
import type { UserAgentApplication as AzureActiveDirectory } from 'msal'
thedavidprice marked this conversation as resolved.
Show resolved Hide resolved

export type { AzureActiveDirectory }
import type { AuthClient } from './'

export type AzureActiveDirectoryClient = AzureActiveDirectory
export interface AzureActiveDirectoryUser {}
Expand Down
5 changes: 3 additions & 2 deletions packages/auth/src/authClients/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { AuthClient } from './'

import type FirebaseNamespace from 'firebase/app'
thedavidprice marked this conversation as resolved.
Show resolved Hide resolved
export type Firebase = typeof FirebaseNamespace

import { AuthClient } from './'
export type Firebase = typeof FirebaseNamespace

// @TODO: Firebase doesn't export a list of providerIds they use
// But I found them here: https://github.com/firebase/firebase-js-sdk/blob/a5768b0aa7d7ce732279931aa436e988c9f36487/packages/rules-unit-testing/src/api/index.ts
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/authClients/goTrue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AuthClient } from './index'
import type { default as GoTrue } from 'gotrue-js'
import type { User } from 'gotrue-js'

import type { AuthClient } from './index'
export type GoTrueUser = User
export type { GoTrue }

Expand Down
Loading