Skip to content

Commit

Permalink
fixed all ts errors and lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
derekvmcintire committed Dec 21, 2024
1 parent 98edbe0 commit 7337558
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { tr } from '@faker-js/faker'
import { useState, useEffect } from 'react'
import { type z } from 'zod'
import { type UsageDataSchema, type BillingRecordsSchema } from '#/types/types.ts'
Expand All @@ -17,8 +18,6 @@ import HelpCircle from './assets/help-circle.svg'
import NonHeatingUsage from './assets/NonHeatingUsage.svg'
import NotAllowedInCalculations from './assets/NotAllowedInCalculations.svg'

import { tr } from '@faker-js/faker'

// type NaturalGasBillRecord = z.infer<typeof NaturalGasBillRecordZod>
// const naturalGasBillRecord01: NaturalGasBillRecord = {
// periodStartDate: new Date('12/08/2017'),
Expand Down
3 changes: 2 additions & 1 deletion heat-stack/app/components/ui/table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { cva, type VariantProps } from 'class-variance-authority'
import * as React from 'react'

import { cn } from '#app/utils/misc.tsx'
import { cva, VariantProps } from 'class-variance-authority'


const Table = React.forwardRef<
HTMLTableElement,
Expand Down
4 changes: 2 additions & 2 deletions heat-stack/app/routes/_auth+/onboarding_.$provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ import {
signupWithConnection,
requireAnonymous,
} from '#app/utils/auth.server.ts'
import { connectionSessionStorage } from '#app/utils/connections.server'
import { connectionSessionStorage } from '#app/utils/connections.server.ts'
import { ProviderNameSchema } from '#app/utils/connections.tsx'
import { prisma } from '#app/utils/db.server.ts'
import { useIsPending } from '#app/utils/misc.tsx'
import { authSessionStorage } from '#app/utils/session.server.ts'
import { redirectWithToast } from '#app/utils/toast.server.ts'
import { NameSchema, UsernameSchema } from '#app/utils/user-validation.ts'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { onboardingEmailSessionKey } from './onboarding'
import { onboardingEmailSessionKey } from './onboarding.tsx'

export const providerIdKey = 'providerId'
export const prefilledProfileKey = 'prefilledProfile'
Expand Down
4 changes: 2 additions & 2 deletions heat-stack/app/routes/_heat+/single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import * as pyodideModule from 'pyodide'
import { type z } from 'zod'
import { Button } from '#/app/components/ui/button.tsx'
import { ErrorList } from '#app/components/ui/heat/CaseSummaryComponents/ErrorList.tsx'
import GeocodeUtil from '#app/utils/GeocodeUtil'
import WeatherUtil from '#app/utils/WeatherUtil'
import GeocodeUtil from '#app/utils/GeocodeUtil.ts'
import WeatherUtil from '#app/utils/WeatherUtil.ts'



Expand Down
2 changes: 1 addition & 1 deletion heat-stack/app/routes/admin+/cache.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useSearchParams,
useSubmit,
} from '@remix-run/react'
import { GeneralErrorBoundary } from '#app/components/error-boundary'
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
import { Field } from '#app/components/forms.tsx'
import { Spacer } from '#app/components/spacer.tsx'
import { Button } from '#app/components/ui/button.tsx'
Expand Down
2 changes: 1 addition & 1 deletion heat-stack/app/routes/admin+/cache_.sqlite.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { cache } from '#app/utils/cache.server.ts'
import {
getInstanceInfo,
getInternalInstanceDomain,
} from '#app/utils/litefs.server'
} from '#app/utils/litefs.server.ts'

export async function updatePrimaryCacheValue({
key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { prisma } from '#app/utils/db.server.ts'
import { sendEmail } from '#app/utils/email.server.ts'
import { redirectWithToast } from '#app/utils/toast.server.ts'
import { verifySessionStorage } from '#app/utils/verification.server.ts'
import { newEmailAddressSessionKey } from './profile.change-email'
import { newEmailAddressSessionKey } from './profile.change-email.tsx'

export async function handleVerification({
request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
MAX_UPLOAD_SIZE,
NoteEditorSchema,
type ImageFieldset,
} from './__note-editor'
} from './__note-editor.tsx'

function imageHasFile(
image: ImageFieldset,
Expand Down
2 changes: 1 addition & 1 deletion heat-stack/app/routes/users+/$username_+/__note-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Label } from '#app/components/ui/label.tsx'
import { StatusButton } from '#app/components/ui/status-button.tsx'
import { Textarea } from '#app/components/ui/textarea.tsx'
import { cn, getNoteImgSrc, useIsPending } from '#app/utils/misc.tsx'
import { type action } from './__note-editor.server'
import { type action } from './__note-editor.server.tsx'

const titleMinLength = 1
const titleMaxLength = 100
Expand Down
28 changes: 14 additions & 14 deletions heat-stack/app/utils/misc.use-double-check.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ test('prevents default on the first click, and does not on the second', async ()
const status = screen.getByRole('status')
const button = screen.getByRole('button')

expect(status).toHaveTextContent('Default Prevented: idle')
expect(button).toHaveTextContent('Click me')
expect(status.textContent).toBe('Default Prevented: idle')
expect(button.textContent).toBe('Click me')

await user.click(button)
expect(button).toHaveTextContent('You sure?')
expect(status).toHaveTextContent('Default Prevented: yes')
expect(button.textContent).toBe('You sure?')
expect(status.textContent).toBe('Default Prevented: yes')

await user.click(button)
expect(button).toHaveTextContent('You sure?')
expect(status).toHaveTextContent('Default Prevented: no')
expect(button.textContent).toBe('You sure?')
expect(status.textContent).toBe('Default Prevented: no')
})

test('blurring the button starts things over', async () => {
Expand All @@ -54,14 +54,14 @@ test('blurring the button starts things over', async () => {
const button = screen.getByRole('button')

await user.click(button)
expect(button).toHaveTextContent('You sure?')
expect(status).toHaveTextContent('Default Prevented: yes')
expect(button.textContent).toBe('You sure?')
expect(status.textContent).toBe('Default Prevented: yes')

await user.click(document.body)
// button goes back to click me
expect(button).toHaveTextContent('Click me')
expect(button.textContent).toBe('Click me')
// our callback wasn't called, so the status doesn't change
expect(status).toHaveTextContent('Default Prevented: yes')
expect(status.textContent).toBe('Default Prevented: yes')
})

test('hitting "escape" on the input starts things over', async () => {
Expand All @@ -72,12 +72,12 @@ test('hitting "escape" on the input starts things over', async () => {
const button = screen.getByRole('button')

await user.click(button)
expect(button).toHaveTextContent('You sure?')
expect(status).toHaveTextContent('Default Prevented: yes')
expect(button.textContent).toBe('You sure?')
expect(status.textContent).toBe('Default Prevented: yes')

await user.keyboard('{Escape}')
// button goes back to click me
expect(button).toHaveTextContent('Click me')
expect(button.textContent).toBe('Click me')
// our callback wasn't called, so the status doesn't change
expect(status).toHaveTextContent('Default Prevented: yes')
expect(status.textContent).toBe('Default Prevented: yes')
})
11 changes: 6 additions & 5 deletions heat-stack/app/utils/providers/github.server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { createId as cuid } from '@paralleldrive/cuid2'
import { redirect } from '@remix-run/node'
import { GitHubStrategy } from 'remix-auth-github'
import { type Strategy } from 'remix-auth'
import { GitHubStrategy, type GitHubStrategyOptions } from 'remix-auth-github'
import { z } from 'zod'
import { cache, cachified } from '../cache.server.ts'
import { connectionSessionStorage } from '../connections.server.ts'
import { type Timings } from '../timing.server.ts'
import { MOCK_CODE_GITHUB_HEADER, MOCK_CODE_GITHUB } from './constants.ts'
import { type AuthProvider } from './provider.ts'
import { type ProviderUser, type AuthProvider } from './provider.ts'

const GitHubUserSchema = z.object({ login: z.string() })
const GitHubUserParseResult = z
Expand All @@ -25,20 +26,20 @@ const shouldMock =
process.env.NODE_ENV === 'test'

export class GitHubProvider implements AuthProvider {
getAuthStrategy() {
getAuthStrategy(): Strategy<ProviderUser, any> { // @TODO double check the types here
return new GitHubStrategy(
{
clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL: '/auth/github/callback',
},
} as unknown as GitHubStrategyOptions, // @TODO fix types here, clientID and callbackURL do not exist on GitHubStrategyOptions
async ({ profile }) => {
const email = profile.emails[0]?.value.trim().toLowerCase()
if (!email) {
throw new Error('Email not found')
}
const username = profile.displayName
const imageUrl = profile.photos[0].value
const imageUrl = profile.photos?.[0]?.value || '';
return {
email,
id: profile.id,
Expand Down
4 changes: 2 additions & 2 deletions heat-stack/app/utils/pyodide.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as pyodideModule from 'pyodide'
import { expect, test, beforeEach } from 'vitest'
import GeocodeUtil from "#app/utils/GeocodeUtil";
import WeatherUtil from "#app/utils/WeatherUtil";
import GeocodeUtil from "#app/utils/GeocodeUtil.ts";
import WeatherUtil from "#app/utils/WeatherUtil.ts";
// import PyodideUtil from "#app/utils/pyodide.util.js";


Expand Down
2 changes: 1 addition & 1 deletion heat-stack/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faker } from '@faker-js/faker'
import { promiseHash } from 'remix-utils/promise'
import { prisma } from '#app/utils/db.server.ts'
import { MOCK_CODE_GITHUB } from '#app/utils/providers/constants'
import { MOCK_CODE_GITHUB } from '#app/utils/providers/constants.ts'
import {
cleanupDb,
createPassword,
Expand Down
6 changes: 3 additions & 3 deletions heat-stack/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ app.use(
MODE === 'development' ? 'ws:' : null,
process.env.SENTRY_DSN ? '*.sentry.io' : null,
"'self'",
].filter(Boolean),
].filter(Boolean) as string[],
'font-src': ["'self'"],
'frame-src': ["'self'"],
'img-src': ["'self'", 'data:'],
Expand Down Expand Up @@ -201,8 +201,8 @@ async function getBuild() {
try {
const build = viteDevServer
? await viteDevServer.ssrLoadModule('virtual:remix/server-build')
: // @ts-expect-error - the file might not exist yet but it will
// eslint-disable-next-line import/no-unresolved
: // @ ts-expect-error - the file might not exist yet but it will
// e slint-disable-next-line import/no-unresolved
await import('../build/server/index.js')

return { build: build as unknown as ServerBuild, error: null }
Expand Down
2 changes: 1 addition & 1 deletion heat-stack/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Config } from 'tailwindcss'
import animatePlugin from 'tailwindcss-animate'
import radixPlugin from 'tailwindcss-radix'
import { marketingPreset } from './app/routes/_marketing+/tailwind-preset'
import { marketingPreset } from './app/routes/_marketing+/tailwind-preset.ts'
import { extendedTheme } from './app/utils/extended-theme.ts'

export default {
Expand Down
4 changes: 2 additions & 2 deletions heat-stack/tests/e2e/onboarding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { prisma } from '#app/utils/db.server.ts'
import {
normalizeEmail,
normalizeUsername,
} from '#app/utils/providers/provider'
} from '#app/utils/providers/provider.ts'
import {
USERNAME_MAX_LENGTH,
USERNAME_MIN_LENGTH,
} from '#app/utils/user-validation'
} from '#app/utils/user-validation.ts'
import { readEmail } from '#tests/mocks/utils.ts'
import { createUser, expect, test as base } from '#tests/playwright-utils.ts'

Expand Down
26 changes: 14 additions & 12 deletions heat-stack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
"include": ["**/*.ts", "**/*.tsx"],
"extends": ["@epic-web/config/typescript"],
"compilerOptions": {
// "lib": ["DOM", "DOM.Iterable", "ES2022"],
// "isolatedModules": true,
// "esModuleInterop": true,
// "jsx": "react-jsx",
// "module": "ES2022",
// "target": "ES2022",
// "moduleResolution": "bundler",
// "resolveJsonModule": true,
// "strict": true,
// "noImplicitAny": true,
// "allowJs": true,
// "forceConsistentCasingInFileNames": true,
"target": "ES2018",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "NodeNext",
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"#*": ["./*"],
"#app/*": ["./app/*"],
Expand Down
1 change: 1 addition & 0 deletions heat-stack/types/vite-env-only.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'vite-env-only';

0 comments on commit 7337558

Please sign in to comment.