fix(repo): Fix ESLint errors and use ESLint in lint-staged#1756
fix(repo): Fix ESLint errors and use ESLint in lint-staged#1756
Conversation
🦋 Changeset detectedLatest commit: 27a2cd5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
LekoArts
left a comment
There was a problem hiding this comment.
Comments to make review easier
| '@clerk/clerk-js': patch | ||
| --- | ||
|
|
||
| Some minor TypeScript type fixes to internal components. Also applying some ESLint recommendations. |
There was a problem hiding this comment.
I've only applied the changeset here because in those files I changed some runtime code (e.g. newSize + 'px' to ${newSize}px). Just to be safe.
In the rest only the TS types changed
| "*.{js,jsx,ts,tsx}": ["npx prettier --write", "npx eslint --fix"], | ||
| "*.{json,md,mdx}": ["npx prettier --write"] |
There was a problem hiding this comment.
lint-staged runs things concurrently. With this setup prettier and ESLint run after each other for js/jsx/ts/tsx files
| "build": "turbo build --concurrency=${TURBO_CONCURRENCY:-2}", | ||
| "test": "turbo test --concurrency=${TURBO_CONCURRENCY:-2}", | ||
| "test:ci": "turbo test --concurrency=${TURBO_CONCURRENCY:-2}", | ||
| "dev": "FORCE_COLOR=1 turbo dev --filter=@clerk/* --filter=!@clerk/expo", |
There was a problem hiding this comment.
With FORCE_COLOR=1 Turborepo outputs the logs with their colors. Makes it easier to read them
| backupCodes?: string[]; | ||
| } & UserMetadataParams & | ||
| (UserPasswordHashingParams | {}); | ||
| (UserPasswordHashingParams | object); |
There was a problem hiding this comment.
Here (and in other instances) {} was changed to object for now since that's what the author intended. Long-term it probably makes sense to convert this to Record<string, unknown> via ESLint rule
| align='center' | ||
| > | ||
| {values.map((value, index) => ( | ||
| {values.map((value, index: number) => ( |
There was a problem hiding this comment.
❓ Why do we need the type annotation here?
There was a problem hiding this comment.
For some reason ESLint/TypeScript didn't infer it correctly. I don't know 🤷
There was a problem hiding this comment.
Yeah, I got the same. Rather than type casting that instance of index I chose to explicitly type it in the map
| align='center' | ||
| > | ||
| {values.map((value, index) => ( | ||
| {values.map((value, index: number) => ( |
|
This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |

Description
So this is a PR with a lot of changed files but don't worry. The changes are not heavy handed, I reserved the bigger ESLint changes for sometime later 😅
Essentially, this PR fixes the errors that were thrown with the current ESLint setup when run
npm run lintat the root. Here and there I fixed some other things that I noticed, too..eslintignoreand.gitignoreto properly ignore our desired dirslint-stagedLICENCE(which is wrong) toLICENSEFORCE_COLOR=1to Turborepo scripts because for whatever reason they don't retain color output?! (see Support colored output from original CLI vercel/turborepo#223)lintscripts to not lint the whole package but only thesrcfolders. This speeds up the checks and encourages to not put stuff somewhere elseTODO. See the commit that only contains the TODO changes: 0c74befImportant: I purposefully not enabled ESLint in our CI yet as that can be a blocker for PRs. Locally you can get around the lint-staged check with
--no-verify. Long-term I want to enable ESLint in CI but I want to wait and see if we run into any problems.Fixes JS-752
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/clerk-js@clerk/clerk-react@clerk/nextjs@clerk/remix@clerk/types@clerk/themes@clerk/localizations@clerk/clerk-expo@clerk/backend@clerk/clerk-sdk-node@clerk/shared@clerk/fastify@clerk/chrome-extensiongatsby-plugin-clerkbuild/tooling/chore