Skip to content

fix(repo): Fix ESLint errors and use ESLint in lint-staged#1756

Merged
LekoArts merged 15 commits intomainfrom
lekoarts/general-cleanup
Sep 22, 2023
Merged

fix(repo): Fix ESLint errors and use ESLint in lint-staged#1756
LekoArts merged 15 commits intomainfrom
lekoarts/general-cleanup

Conversation

@LekoArts
Copy link
Copy Markdown
Contributor

@LekoArts LekoArts commented Sep 21, 2023

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 lint at the root. Here and there I fixed some other things that I noticed, too.

  • Adjust .eslintignore and .gitignore to properly ignore our desired dirs
  • Add ESLint to our lint-staged
  • Rename LICENCE (which is wrong) to LICENSE
  • Add FORCE_COLOR=1 to Turborepo scripts because for whatever reason they don't retain color output?! (see Support colored output from original CLI vercel/turborepo#223)
  • Change the lint scripts to not lint the whole package but only the src folders. This speeds up the checks and encourages to not put stuff somewhere else
  • Didn't touch some code paths and instead added a TODO. See the commit that only contains the TODO changes: 0c74bef
  • Update ESLint and other deps

Important: 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 test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

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-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Sep 21, 2023

🦋 Changeset detected

Latest commit: 27a2cd5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

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

Copy link
Copy Markdown
Contributor Author

@LekoArts LekoArts left a comment

Choose a reason for hiding this comment

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

Comments to make review easier

'@clerk/clerk-js': patch
---

Some minor TypeScript type fixes to internal components. Also applying some ESLint recommendations.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread .lintstagedrc.json
Comment on lines +2 to +3
"*.{js,jsx,ts,tsx}": ["npx prettier --write", "npx eslint --fix"],
"*.{json,md,mdx}": ["npx prettier --write"]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lint-staged runs things concurrently. With this setup prettier and ESLint run after each other for js/jsx/ts/tsx files

Comment thread package.json
"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",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

With FORCE_COLOR=1 Turborepo outputs the logs with their colors. Makes it easier to read them

backupCodes?: string[];
} & UserMetadataParams &
(UserPasswordHashingParams | {});
(UserPasswordHashingParams | object);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread packages/clerk-js/src/ui/common/PrintableComponent.tsx
@LekoArts LekoArts marked this pull request as ready for review September 21, 2023 08:44
@LekoArts LekoArts requested review from a team and dimkl as code owners September 21, 2023 08:44
Comment thread packages/clerk-js/src/ui/common/PrintableComponent.tsx
align='center'
>
{values.map((value, index) => (
{values.map((value, index: number) => (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❓ Why do we need the type annotation here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For some reason ESLint/TypeScript didn't infer it correctly. I don't know 🤷

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I get the correct type locally, but eslint complaints with:
image

No blocker in any way so I'm going to resolve this as well.

Copy link
Copy Markdown
Contributor Author

@LekoArts LekoArts Sep 22, 2023

Choose a reason for hiding this comment

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

Yeah, I got the same. Rather than type casting that instance of index I chose to explicitly type it in the map

Comment thread packages/clerk-js/src/utils/querystring.ts Outdated
Comment thread packages/eslint-config-custom/index.js
Comment thread packages/eslint-config-custom/index.js
Comment thread packages/fastify/src/constants.ts
Comment thread packages/gatsby-plugin-clerk/src/ssr/authenticateRequest.ts Outdated
Comment thread packages/gatsby-plugin-clerk/src/ssr/types.ts
Comment thread packages/remix/src/ssr/types.ts
Copy link
Copy Markdown
Member

@nikosdouvlis nikosdouvlis left a comment

Choose a reason for hiding this comment

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

Excellent work

align='center'
>
{values.map((value, index) => (
{values.map((value, index: number) => (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I get the correct type locally, but eslint complaints with:
image

No blocker in any way so I'm going to resolve this as well.

@LekoArts LekoArts merged commit 3ceb2a7 into main Sep 22, 2023
@LekoArts LekoArts deleted the lekoarts/general-cleanup branch September 22, 2023 12:58
@clerk-cookie clerk-cookie mentioned this pull request Sep 22, 2023
@clerk-cookie
Copy link
Copy Markdown
Collaborator

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.

@clerk clerk locked as resolved and limited conversation to collaborators Sep 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants