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

chore: setup typescript-eslint #90

Merged
merged 5 commits into from
Aug 7, 2024
Merged

Conversation

snitin315
Copy link
Contributor

@snitin315 snitin315 commented Jul 19, 2024

Prerequisites checklist

What is the purpose of this pull request?

Enable linting for typescript files.

What changes did you make? (Give an overview)

  • Enable typescript-eslint for all ts files.
  • Fixed lint errors for no-use-before-define rule.
  • Disabled @typescript-eslint/no-explicit-any for some generic types.

Related Issues

Fix #69

Is there anything you'd like reviewers to focus on?

Currently 8.0.0-alpha.45 supports ESLint v9, we will need to update it later once a stable version is released.

@nzakas
Copy link
Member

nzakas commented Jul 22, 2024

@snitin315 there are some conflicts now

Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Great timing! I'd been hoping to get to the typescript-eslint task soon. Reviewing a PR is even better. 😄

Most of my comments here are on existing code, so it's understandable if they're out of scope for this PR. I'd expect them to be. So for anything that can't be done here I'm requesting updating the comment to reference a filed TODO to refactor the types.

The one blocker is I'm requesting changes on is using the recommended teslint.config with extends to simplify the eslint.config.js block.

Exciting!

eslint.config.js Outdated Show resolved Hide resolved
packages/core/src/types.ts Outdated Show resolved Hide resolved
packages/core/src/types.ts Outdated Show resolved Hide resolved
packages/core/src/types.ts Outdated Show resolved Hide resolved
eslint.config.js Outdated Show resolved Hide resolved
@snitin315 snitin315 force-pushed the chore/setup-typescript-eslint branch from d534a1c to 541d614 Compare August 3, 2024 20:24
@snitin315
Copy link
Contributor Author

@JoshuaKGoldberg I've addressed your comments. PTAL

eslint.config.js Outdated
@@ -53,4 +54,10 @@ export default [
},
},
},

// Typescript
Copy link
Contributor

Choose a reason for hiding this comment

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

[Typo]

Suggested change
// Typescript
// TypeScript

package.json Outdated
@@ -33,6 +33,8 @@
"got": "^14.4.1",
"lint-staged": "^15.2.0",
"prettier": "^3.1.1",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.0-alpha.45",
Copy link
Contributor

Choose a reason for hiding this comment

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

We've released 8 as stable since last review! 🚀

Suggested change
"typescript-eslint": "^8.0.0-alpha.45",
"typescript-eslint": "^8.0.0",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated 🚀

validate: BuiltInValidationStrategy | ((value: any) => void);

/**
* The schema for the object value of this property.
*/
// eslint-disable-next-line no-use-before-define -- Ignore for recursive type
Copy link
Contributor

Choose a reason for hiding this comment

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

[Bug] As a general ideology, if a core ESLint rule is acting poorly on TypeScript syntax, it's likely there's a typescript-eslint rule corresponding to it. @typescript-eslint/no-use-before-define is what you'd want to use in this case.

It's not enabled in any of typescript-eslint's recommended configs because it mostly acts as a stylistic rule when you already have TypeScript type checking enabled. My recommendation would be to turn off no-use-before-define and leave it at that. But if you really want to have a lint rule, you'll want to go with https://typescript-eslint.io/rules/no-use-before-define/#how-to-use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've disabled the no-use-before-define rule.

packages/object-schema/src/types.ts Outdated Show resolved Hide resolved
packages/object-schema/src/types.ts Outdated Show resolved Hide resolved
@nzakas
Copy link
Member

nzakas commented Aug 5, 2024

For this PR, let's focus on getting typescript-eslint enabled and working without modifying too much code. We can address my naive approaches to typing in follow-up PRs. :)

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@nzakas nzakas merged commit e976d60 into main Aug 7, 2024
14 checks passed
@nzakas nzakas deleted the chore/setup-typescript-eslint branch August 7, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Change Request: Set up typescript-eslint
4 participants