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

Enforce @ts-expect-error via eslint #19198

Merged
merged 11 commits into from
Sep 21, 2022

Conversation

JReinhold
Copy link
Contributor

@JReinhold JReinhold commented Sep 15, 2022

What I did

This PR continues work from #19122 and #19168 and changes the ESLint rule @typescript-eslint/ban-ts-comment from warn to error to reduce the number of @ts-ignores in the future.

To achieve this, a few TypeScript errors had to be fixed all over the code base. Some where missing types that got added or ignored while other places I fixed the actual errors that TypeScript reported.

How to test

  • Run ./bootstrap.sh --prep successfully.
  • Run ./bootstrap.sh --build successfully.
  • Run cd code && yarn lint:js successfully.

@JReinhold JReinhold added cleanup Minor cleanup style change that won't show up in release changelog dependencies maintenance User-facing maintenance tasks typescript labels Sep 15, 2022
@JReinhold JReinhold requested a review from shilman September 15, 2022 12:01
@JReinhold JReinhold removed dependencies cleanup Minor cleanup style change that won't show up in release changelog labels Sep 15, 2022
Comment on lines +1 to 2
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like ts-nocheck is actually valid here because of the decorators, so I've allowed it.

@@ -134,7 +133,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({
router.use(webpackHotMiddleware(compiler as any));

const stats = await new Promise<Stats>((ready, stop) => {
compilation.waitUntilValid(ready as any);
compilation?.waitUntilValid(ready as any);
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 changes the behavior a little since the original would throw if compilation was undefined while this fails silently. But since compilation is being defined above I think that's okay.

@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"strict": true
"strict": true,
"skipLibCheck": true
Copy link
Contributor Author

@JReinhold JReinhold Sep 15, 2022

Choose a reason for hiding this comment

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

case-sensitive-paths-webpack-plugin has transitive types issues with webpack5 which we want to ignore because we can't do anything about it. Reading the issues in the repo makes it seem like there might actually be some issues with it and webpack5.

@JReinhold JReinhold marked this pull request as ready for review September 15, 2022 12:26
@JReinhold JReinhold self-assigned this Sep 15, 2022
@JReinhold JReinhold requested a review from a team September 18, 2022 14:05
Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

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

Nice cleanup!

code/lib/api/src/typings.d.ts Show resolved Hide resolved
@IanVS
Copy link
Member

IanVS commented Sep 20, 2022

The Vite sandbox failures here are not related to this PR, FWIW.

Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Great first PR @JReinhold 💯

@shilman shilman closed this Sep 21, 2022
@shilman shilman reopened this Sep 21, 2022
@shilman shilman merged commit 6aaa3cb into next Sep 21, 2022
@shilman shilman deleted the jeppe/sb-734-add-eslint-rule-to-enforce-ts-expect branch September 21, 2022 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants