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

Fix tsconfig.json and Lint errors #290

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added @todo here for someone to double check the types

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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@todo here because clientID and callbackURL do not exist on type GitHubStrategyOptions, so we either need to figure out what type we should be using, or potentially update the code here

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
46 changes: 22 additions & 24 deletions heat-stack/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
{
"include": ["**/*.ts", "**/*.tsx"],
"extends": ["@epic-web/config/typescript"],
"extends": ["@epic-web/config/typescript"], // Uses a shared TypeScript configuration provided by the @epic-web package as the base.
"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,
"paths": {
"#*": ["./*"],
"#app/*": ["./app/*"],
"#tests/*": ["./tests/*"],
"@/icon-name": [
"./app/components/ui/icons/name.d.ts",
"./types/icon-name.d.ts"
"target": "ES2018", // Compile TypeScript code to ECMAScript 2018.
"lib": ["DOM", "DOM.Iterable", "ESNext"], // Includes type definitions for the DOM, DOM iterables, and modern ECMAScript features.
"allowJs": true, // Enables the inclusion of .js files in the project.
"skipLibCheck": true, // Skip type checking of all declaration files (*.d.ts).
"esModuleInterop": true, // Enables compatibility with CommonJS modules.
"allowSyntheticDefaultImports": true, // Allows default imports from modules with no default export.
"strict": true, // Enables all strict type-checking options.
"forceConsistentCasingInFileNames": true, // Enforces a consistent casing in file names.
"module": "NodeNext", // Uses Node.js-style ES Module resolution for compatibility with modern Node.js versions.
"moduleResolution": "nodenext", // Uses Node.js ES Module resolution logic.
"resolveJsonModule": true, // Allows importing JSON files as modules.
"isolatedModules": true, // Disallows the use of global modules and global side-effects.
"noEmit": true, // Disables emitting output files.
"jsx": "react-jsx", // Enables JSX support with React JSX.
"paths": { // Maps paths to different directories or files.
"#*": ["./*"], // Maps all paths starting with # to the root directory.
"#app/*": ["./app/*"], // Maps all paths starting with #app to the app directory.
"#tests/*": ["./tests/*"], // Maps all paths starting with #tests to the tests directory.
"@/icon-name": [ // Maps the @/icon-name path to the icon-name.d.ts file.
"./app/components/ui/icons/name.d.ts", // Maps the @/icon-name path to the
"./types/icon-name.d.ts" // icon-name.d.ts file in the types directory.
]
}
// ,"skipLibCheck": true,
// "allowImportingTsExtensions": true,
// "noEmit": true,
}
}
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';