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

refactor(container-runtime): Enable any-related eslint rules and fix violations #23570

Merged
merged 37 commits into from
Jan 16, 2025

Conversation

Josmithr
Copy link
Contributor

@Josmithr Josmithr commented Jan 15, 2025

Enables any-related rules from the recommended eslint config and fixes violations. Specifically,

  • @typescript-eslint/no-explicit-any
  • @typescript-eslint/no-unsafe-assignment
  • @typescript-eslint/no-unsafe-call
  • @typescript-eslint/no-unsafe-member-access
  • @typescript-eslint/no-unsafe-return

This PR is one piece of a multi-PR process to migrate the container-runtime package to our recommended eslint config.

AB#3027

@Josmithr Josmithr requested review from a team and Copilot January 15, 2025 23:12
@github-actions github-actions bot added area: runtime Runtime related issues base: main PRs targeted against main branch labels Jan 15, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 22 out of 37 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • packages/runtime/container-runtime/src/test/containerRuntime.spec.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/deltaManagerProxies.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/test/channelCollection.spec.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/test/dataStoreContext.spec.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/opLifecycle/opGroupingManager.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/opLifecycle/opCompressor.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/test/batching.spec.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/dataStore.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/summary/summarizer.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/test/createChildDataStoreSync.spec.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/summary/summaryManager.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/opLifecycle/outbox.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/containerRuntime.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/channelCollection.ts: Evaluated as low risk
  • packages/runtime/container-runtime/src/opLifecycle/opSplitter.ts: Evaluated as low risk
@github-actions github-actions bot added area: build Build related issues dependencies Pull requests that update a dependency file labels Jan 16, 2025
@@ -203,6 +203,7 @@
"@fluidframework/test-runtime-utils": "workspace:~",
"@microsoft/api-extractor": "7.47.8",
"@types/double-ended-queue": "^2.1.0",
"@types/lz4js": "^0.2.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.

Missing types dep

packages/runtime/container-runtime/src/dataStoreContext.ts Outdated Show resolved Hide resolved
@@ -215,6 +216,7 @@ export class OpSplitter {
// back-compat with 1.x builds
// This is only required / present for non-compressed, chunked ops
// For compressed ops, we have op grouping enabled, and type of each op is preserved within compressed content.
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
Copy link
Contributor

Choose a reason for hiding this comment

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

Seeing this originalType used in two places but requiring the cast makes me very suspicious of the typing here 🤔 .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. This was odd enough that I erred on the side of leaving it alone.

Comment on lines +80 to +81
// TODO: better typing here
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to work: const errorObj = Error as unknown as { stackTraceLimit: number };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair. But I wasn't sure if there was a real type we were working around here. I think I would rather leave this alone (with the TODO) so someone with more familiarity could update with the right type.

Copy link
Contributor

@alexvy86 alexvy86 Jan 16, 2025

Choose a reason for hiding this comment

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

As far as I could tell, the issue is just that stackTraceLimit is non-standard according to the docs, so it's not present on the Error type. But fair enough, can be left alone for now.

@Josmithr Josmithr requested a review from alexvy86 January 16, 2025 19:13
Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

This package is going to end up with more comments than lines of code 🤣

@Josmithr Josmithr enabled auto-merge (squash) January 16, 2025 21:15
@Josmithr
Copy link
Contributor Author

This package is going to end up with more comments than lines of code 🤣

Generally speaking, I'm good with that. Eslint-disable comments, maybe less so 😜

@Josmithr Josmithr changed the title refactor(container-runtime): Enable no-explicit-any eslint rule and fix violations refactor(container-runtime): Enable any-related eslint rules and fix violations Jan 16, 2025
@Josmithr Josmithr merged commit 6b35040 into microsoft:main Jan 16, 2025
34 checks passed
@Josmithr Josmithr deleted the container-runtime/eslint/any-rules branch January 16, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build Build related issues area: runtime Runtime related issues base: main PRs targeted against main branch dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants