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(ordered-collection): Updated eslint to use recommended config #23335

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

WayneFerrao
Copy link
Contributor

Description

This PR updates the eslint config for dds/ordered-collection to use the recommended config

@WayneFerrao WayneFerrao requested review from a team and Copilot December 16, 2024 21:58
@github-actions github-actions bot added area: dds Issues related to distributed data structures base: main PRs targeted against main branch labels Dec 16, 2024

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • packages/dds/ordered-collection/src/snapshotableArray.ts: Evaluated as low risk
  • packages/dds/ordered-collection/src/consensusQueue.ts: Evaluated as low risk
Comments suppressed due to low confidence (1)

packages/dds/ordered-collection/src/consensusOrderedCollection.ts:416

  • The return type of the deserializeValue method is marked as unknown, which might cause issues if the deserialized value is used without proper type checks. Consider updating the return type to a more specific type if possible.
private deserializeValue(content: string, serializer: IFluidSerializer): unknown {
@@ -108,6 +108,8 @@ export interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvent
* @legacy
* @alpha
*/

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this extra blank line would break the connection between the TSDoc block above and the interface?

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 don't believe it does. TSDoc comments are associated with the first valid code that follows them, regardless of blank lines or directives like eslint-disable. You can verify this by hovering over the interface showing the related comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Still probably best to remove the blank line though

@@ -61,30 +61,31 @@ function createCollectionForReconnection(
}

describe("ConsensusOrderedCollection", () => {
/* eslint-disable @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.

Did we try to use unknown[] here? It's not public API so it should be a safe change to make.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could also make this function generic, assuming tests are doing anything other than equality comparisons with the input/output entries.

let testCollection: ConsensusOrderedCollection;

async function removeItem() {
async function removeItem(): Promise<any> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not introduce new uses of any. Same below.

Suggested change
async function removeItem(): Promise<any> {
async function removeItem(): Promise<unknown> {

@@ -211,6 +213,7 @@ describe("ConsensusOrderedCollection", () => {
await addItem(obj);
const result = await removeItem();
assert.notStrictEqual(result, obj);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
Copy link
Contributor

Choose a reason for hiding this comment

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

With a change I suggest above, removeItem() would start returning Promise<unknown> and we can address the issue of accessing .x by giving an explicit type to the unknown thing, something like const result: { x: number } = await removeItem();.

@@ -392,37 +398,37 @@ describe("ConsensusOrderedCollection", () => {
this.containerRuntimeFactory,
);
}

private async addItem(item: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to another comment, since this is all private code, let's move to unknown.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to remove the eslint disable now :) and same on line 408.

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.

One last thing below but I think it looks good otherwise

@@ -392,37 +398,37 @@ describe("ConsensusOrderedCollection", () => {
this.containerRuntimeFactory,
);
}

private async addItem(item: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be able to remove the eslint disable now :) and same on line 408.

@@ -72,4 +72,5 @@ export const ConsensusQueue = createSharedObjectKind(ConsensusQueueFactory);
* @legacy
* @alpha
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO with work item number?

@@ -35,6 +35,7 @@ class SnapshotableQueue<T> extends SnapshotableArray<T> implements IOrderedColle
* @legacy
* @alpha
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO with work item number?

@@ -108,6 +108,7 @@ export interface IConsensusOrderedCollectionEvents<T> extends ISharedObjectEvent
* @legacy
* @alpha
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO with work item number? And below

Copy link
Contributor

@Josmithr Josmithr left a comment

Choose a reason for hiding this comment

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

Left a couple more comments. Otherwise looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds Issues related to distributed data structures base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants