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

feat(remix-eslint-config): extend from typescript-eslint/recommended #6248

Conversation

JoshuaKGoldberg
Copy link
Contributor

Wipes out most of the existing typescript.js lint rules, in favor of directly extending plugin:@typescript-eslint/recommended. Remaining rule configurations are grouped with comments:

  • Rules that Remix explicitly configures differently from the default
  • Rules enabled by rules/core.js that aren't needed for TypeScript code
  • Rules that enforce a style point not agreed upon by Remix ✳️
  • Ones that could eventually be investigated for enabling

Addresses: #6126

  • Docs - ... where would I document this? Should I continue to hold off until this is reviewed?
  • [ ] Tests: yarn lint still passes, yes?

Testing Strategy: I'd encourage folks to try this out on any large Remix repository written with TypeScript. And let me know what those are so I can test them out too? 😄

Note that this does not (yet?) tackle two good next steps:

Any code changes are commented inline.

@changeset-bot
Copy link

changeset-bot bot commented Apr 29, 2023

⚠️ No Changeset found

Latest commit: ee91e22

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -1,4 +1,3 @@
/* eslint-disable no-unreachable */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This rule is explicitly turned off in typescript-eslint configs because it's covered by TypeScript.

ecmaFeatures: {
jsx: true,
},
warnOnUnsupportedTypeScriptVersion: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

warnOnUnsupportedTypeScriptVersion is enabled by default: https://typescript-eslint.io/architecture/parser/#warnonunsupportedtypescriptversion

parser: "@typescript-eslint/parser",
parserOptions: {
sourceType: "module",
ecmaVersion: 2019,
ecmaFeatures: {
jsx: true,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ecmaFeatures.jsx is enabled by default for .tsx files.

@@ -21,17 +21,14 @@ export type DeferFunction = <Data extends Record<string, unknown>>(
init?: number | ResponseInit
) => TypedDeferredData<Data>;

export type JsonFunction = <Data extends unknown>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://typescript-eslint.io/rules/no-unnecessary-type-constraint - extends unknown is redundant for these type parameters.

Copy link
Member

Choose a reason for hiding this comment

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

The docs are talking about any only, but this had unknown
Does the same apply?
If so, I guess it would be a good idea to update the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point 😄 thanks! Filed typescript-eslint/typescript-eslint#6973.

@ngbrown
Copy link
Contributor

ngbrown commented May 6, 2023

@JoshuaKGoldberg What would it take to enable plugin:@typescript-eslint/recommended-requiring-type-checking? I attempted to do that in #6325, but was closed in favor of this pull request. There doesn't seem to be a extensive conflict between the two changes, so could be cribbed for adding to this pull request.

@JoshuaKGoldberg
Copy link
Contributor Author

JoshuaKGoldberg commented May 6, 2023

Yeah enabling plugin:@typescript-eslint/recommended-requiring-type-checking would be a very good next step after this. If the powers-that-be are particularly interested, it could certainly be done either as a followup or as part of this PR.

The main reason I didn't add type checked rules in this PR was type aware rule performance.

I'd want (someone or myself) to investigate how to improve that specifically for Remix's setup. E.g. typescript-eslint/typescript-eslint#6754

Copy link
Contributor

@brophdawg11 brophdawg11 left a comment

Choose a reason for hiding this comment

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

Thanks Josh! Just a few questions on some existing rules and if we're losing them

@JoshuaKGoldberg
Copy link
Contributor Author

Sorry for taking a couple weeks to respond to your comments @brophdawg11! I lost track of this while traveling 😅. But I'm glad you're looking at it!

I responded to each thread inline - for each, let me know and I'm happy to make the change.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review June 10, 2023 00:46
@MichaelDeBoey
Copy link
Member

@JoshuaKGoldberg It seems like you missed something that causes an ESLint error
https://github.com/remix-run/remix/actions/runs/5227221637/jobs/9438647396?pr=6248#step:7:9

Do you want to fix that one please?
If you don't have time, I'm happy to do so as well

@JoshuaKGoldberg
Copy link
Contributor Author

Aha, introduced merging from main - just pushed a fix now. Thanks!

@brophdawg11 brophdawg11 changed the base branch from main to dev June 15, 2023 17:05
@brophdawg11 brophdawg11 changed the base branch from dev to main June 15, 2023 17:05
@brophdawg11 brophdawg11 changed the base branch from main to brophdawg11/typescript-eslint-recommended June 15, 2023 17:26
@brophdawg11
Copy link
Contributor

This should go to dev since it changes a deployed package, so going to squash-merge to my branch and then will rebase onto dev there and get it in. Thanks!

@brophdawg11 brophdawg11 merged commit 4a617f6 into remix-run:brophdawg11/typescript-eslint-recommended Jun 15, 2023
8 of 9 checks passed
brophdawg11 added a commit that referenced this pull request Jun 15, 2023
@JoshuaKGoldberg JoshuaKGoldberg deleted the typescript-eslint-recommended branch June 15, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants