-
Notifications
You must be signed in to change notification settings - Fork 0
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: upgrade typescript + prettier + eslint with a single shared linting config #424
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
"ts-jest": "^29.1.4", | ||
"typescript": "5.3.3", | ||
"ts-jest": "^29.2.5", | ||
"typescript": "5.7.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumps Typescript to latest
@@ -1,6 +1,6 @@ | |||
// Inspired by Chatbot-UI and modified to fit the needs of this project | |||
// @see https://github.com/mckaywrigley/chatbot-ui/blob/main/components/Chat/ChatMessage.tsx | |||
import type { ReactNode } from "react"; | |||
import type { ReactNode, JSX } from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global JSX is now deprecated
@@ -21,7 +21,7 @@ export async function waitForStreamingStatusChange( | |||
await page.waitForFunction( | |||
([currentStatus, expectedStatus]) => { | |||
const statusElement = document.querySelector( | |||
// eslint-disable-next-line @typescript-eslint/quotes, quotes | |||
// eslint-disable-next-line quotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@typescript-eslint/quotes
is deprecated
@@ -9,11 +9,13 @@ | |||
"incremental": true, | |||
"esModuleInterop": true, | |||
"module": "esnext", | |||
"moduleResolution": "node", | |||
"moduleResolution": "bundler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move back to Bundler throughout
"type-check": "tsc --noEmit" | ||
}, | ||
"eslintConfig": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the per-project config (for now?) and replace with this config in the package.json for each package
}, | ||
"engines": { | ||
"node": ">=20.9.0", | ||
"pnpm": ">=8" | ||
} | ||
}, | ||
"type": "module" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set all packages as type module
@@ -3,7 +3,7 @@ import { createOpenAIClient } from "@oakai/core/src/llm/openai"; | |||
import { aiLogger } from "@oakai/logger"; | |||
import fs from "fs/promises"; | |||
import type OpenAI from "openai"; | |||
import type { ChatCompletionCreateParamsNonStreaming } from "openai/resources"; | |||
import type { ChatCompletionCreateParamsNonStreaming } from "openai/resources/index.mjs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why we have to do this now. This has changed a few times
isSidebarOpen: boolean; | ||
toggleSidebar: () => void; | ||
isLoading: boolean; | ||
} | ||
|
||
const SidebarContext = createContext<SidebarContext | undefined>(undefined); | ||
const SidebarContext = createContext<SidebarContextValue | undefined>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The eslint config no longer likes types named the same as code definitions
@@ -0,0 +1,42 @@ | |||
{ | |||
"name": "@oakai/eslint-config", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes a new package that matches the same naming convention as the prettier config
@@ -0,0 +1,140 @@ | |||
import eslint from '@eslint/js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the single source of truth for eslint config. ATM it has all rules for all packages in one file
@@ -0,0 +1,3 @@ | |||
declare module 'eslint-plugin-import'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't have types
@@ -0,0 +1,64 @@ | |||
import tsEslint from '@typescript-eslint/eslint-plugin'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate out the actual rule definitions
const typescript = tsEslint.configs.recommended; | ||
|
||
// @ts-check | ||
/** @type {Partial<Record<string, import('@typescript-eslint/utils/ts-eslint').SharedConfig.RuleEntry>>} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had this as a typescript file, but it would have meant having a build step, so this is the next best approach
@@ -78,7 +78,9 @@ export async function lpPartsEmbedStart({ | |||
await prisma.ingestLessonPlanPart.updateMany({ | |||
where: { | |||
id: { | |||
in: lessonPlanPartIds, | |||
in: lessonPlanPartIds.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes a linting error
"devDependencies": { | ||
"prettier": "^3.1.1" | ||
"@trivago/prettier-plugin-sort-imports": "^4.3.0", | ||
"prettier": "^3.4.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump prettier to latest
Playwright test resultsDetails Open report ↗︎ Skipped testsNo persona › tests/auth.test.ts › authenticate through Clerk UI |
Quality Gate passedIssues Measures |
@@ -1,7 +1,7 @@ | |||
const github = require("@actions/github"); | |||
|
|||
const prFromSha = require("../pr_from_sha"); | |||
const branchFromSha = require("../branch_from_sha"); | |||
const prFromSha = require("../pr_from_sha.cjs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially we could refactor this all to use ESM but this is the minimal change to get this to work with the new requirement to use .cjs extensions for commonjs code
"private": true, | ||
"scripts": { | ||
"build": "next build", | ||
"build:dev": "pnpm with-env next build", | ||
"check": "tsc --noEmit", | ||
"clean": "rm -rf .next .turbo node_modules", | ||
"dev": "FORCE_COLOR=1 SENTRY_SUPPRESS_TURBOPACK_WARNING=1 pnpm with-env node scripts/increase-listeners.js next dev --port 2525 --turbo | pino-pretty -C", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -1,26 +1,27 @@ | |||
{ | |||
"name": "@oakai/nextjs", | |||
"version": "0.1.0", | |||
"version": "1.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks great to me. I haven't tested it locally yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and it seems to work very well with Zed (my editor)
🎉 This PR is included in version 1.18.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
We primarily use Typescript, some ESM, and an occasional CommonJS file. So this makes TS the preferred format, ESM the secondary and CommonJS a tertiary format.
To write JS code, name your file with the .mjs extension.
To write code with CommonJS you will need to use the .cjs extension.
Linting rules will now apply to each type of file, and we can specify rules that apply generally, or specifically for certain types of file.
How to review