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

Update eslint config in packages/runtime/runtime-utils to extend "recommended" base config #23956

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

Conversation

RishhiB
Copy link
Contributor

@RishhiB RishhiB commented Feb 28, 2025

The package currently uses our "minimal" config. This PR updates it to use "recommended" and fix the resulting linter violations.

AB#3022

@Copilot Copilot bot review requested due to automatic review settings February 28, 2025 20:08
@github-actions github-actions bot added area: loader Loader related issues area: runtime Runtime related issues base: main PRs targeted against main branch and removed area: runtime Runtime related issues area: loader Loader related issues labels Feb 28, 2025
@github-actions github-actions bot added area: loader Loader related issues area: runtime Runtime related issues labels Feb 28, 2025

Choose a reason for hiding this comment

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

PR Overview

This PR updates the ESLint configuration in packages/runtime/runtime-utils to extend the "recommended" base config and adjusts several files for improved type safety and consistency. Key changes include updating lint rules, standardizing UTF encoding strings from "utf-8" to "utf8", and adding explicit return types as well as minor refactoring throughout the codebase.

Reviewed Changes

File Description
packages/runtime/runtime-utils/.eslintrc.cjs Changed ESLint config from a deprecated minimal config to the recommended configuration.
packages/runtime/runtime-utils/src/dataStoreHelpers.ts Updated type definitions and error handling logic for improved type safety.
packages/runtime/runtime-utils/src/handles.ts Refactored type checking for serialized handles using unknown type.
packages/runtime/runtime-utils/src/unpackUsedRoutes.ts Minor refactoring of conditional logic in accumulating child routes.
packages/common/driver-definitions/src/protocol/storage.ts Standardized encoding strings from "utf-8" to "utf8".
packages/runtime/runtime-utils/src/summaryUtils.ts Added new functions with explicit return types and updated UTF‑8 byte length calculation logic.
packages/runtime/runtime-utils/src/requestParser.ts Refactored URL path extraction and added explicit return types.
packages/runtime/runtime-utils/src/runtimeFactoryHelper.ts Improved type annotations for factory helper class.
packages/runtime/runtime-utils/src/objectstorageutils.ts Updated string slicing and adjusted condition for path existence checking.
packages/loader/driver-utils/src/blob.ts Standardized encoding strings in blob constructor.
packages/loader/driver-utils/src/treeConversions.ts Standardized encoding strings and minor adjustments in tree conversion.
Various test files Updated import paths and added explicit typing for better clarity and Node.js compatibility.
packages/runtime/runtime-utils/src/utils.ts Added explicit return type and replaced fromCharCode with fromCodePoint for compact ID encoding.

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

Comments suppressed due to low confidence (1)

packages/runtime/runtime-utils/src/summaryUtils.ts:71

  • Verify that the iteration and index decrement logic correctly handles multi-code-unit characters after switching from charCodeAt to codePointAt to ensure the accurate calculation of UTF-8 byte length.
const code = str.codePointAt(i);
@RishhiB RishhiB requested a review from a team as a code owner February 28, 2025 20:42
@github-actions github-actions bot added area: driver Driver related issues public api change Changes to a public API labels Feb 28, 2025
@github-actions github-actions bot removed the area: loader Loader related issues label Mar 9, 2025
@github-actions github-actions bot removed the area: driver Driver related issues label Mar 9, 2025
@RishhiB RishhiB requested a review from a team March 10, 2025 16:29
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.

Still have a few files to go through but leaving some comments for now.

@@ -406,7 +406,7 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
const attachMessage = contents as InboundAttachMessage;
// We need to process the GC Data for both local and remote attach messages
const foundGCData = processAttachMessageGCData(
attachMessage.snapshot,
attachMessage.snapshot ?? undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did it complain about this? The snapshot property matches the types expected by the function parameter...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

processAttachMessageGCData takes param snapshot of type ITree or undefined but attachMessage.snapshot is type ITree or null

function processAttachMessageGCData(snapshot: ITree | undefined, addedGCOutboundRoute: (fromNodeId: string, toPath: string) => void): boolean
export type InboundAttachMessage = Omit<IAttachMessage, "snapshot"> & {
	// eslint-disable-next-line @rushstack/no-new-null -- TODO: breaking change; protocol might even explicitly use null
	snapshot: IAttachMessage["snapshot"] | null;
};```

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I hadn't gotten to the fact that this PR changes the function signature too 😄. The function changes seem fine since nothing inside the function has special casing for snapshot === null... so yeah, I think this is fine. Double checking, @agarwal-navin and @markfields, any concerns here?

Comment on lines +27 to +30
typeof value === "object" &&
value !== null &&
"type" in value &&
value.type === "__fluid_handle__";
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit torn here. Not sure that this is better than (value as { type: string | undefined }).type === "__fluid_handle__", because we're introducing runtime checks which don't change the function's behavior but add a bit of runtime cost. Maybe @jason-ha has thoughts?

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.

Mostly docs and similar. I'd like to hear back from the summarization crew before approving :)

@@ -455,15 +479,16 @@ export function processAttachMessageGCData(
}

assert(
// eslint-disable-next-line unicorn/text-encoding-identifier-case
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the one you mentioned where DDS use "utf-8" explicitly, right? If so let's add that to the all the disables in this file, since this is not a lint rule we'll be actively trying to remove, it'll probably stay for a while and we'll want to know why.

Copy link
Contributor

🔗 Found some broken links! 💔

Run a link check locally to find them. See
https://github.com/microsoft/FluidFramework/wiki/Checking-for-broken-links-in-the-documentation for more information.

linkcheck output


> [email protected] ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> [email protected] serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> [email protected] check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

http://localhost:3000/docs/data-structures/tree
- (36:97) 'the Shar..' => http://localhost:3000/docs/api/tree (HTTP 404)

http://localhost:3000/docs/data-structures/tree/
- (36:97) 'the Shar..' => http://localhost:3000/docs/api/tree (HTTP 404)

http://localhost:3000/docs/data-structures/tree/schema-definition
- (30:128) 'SharedTr..' => http://localhost:3000/docs/api/tree (HTTP 404)

http://localhost:3000/docs/start/tree-start
- (44:4) 'the API ..' => http://localhost:3000/docs/api/tree/schemafactory-class (HTTP 404)
- (61:7) 'the API' => http://localhost:3000/docs/api/tree/treechangeevents-interface (HTTP 404)


Stats:
  162477 links
    1326 destination URLs
    1558 URLs ignored
       0 warnings
       3 errors

 ELIFECYCLE  Command failed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtime Runtime related issues base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants