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

eslint(container-loader): Prefix container-loader before enabling no-unchecked-record-access #23423

Merged
merged 4 commits into from
Jan 6, 2025

Conversation

RishhiB
Copy link
Contributor

@RishhiB RishhiB commented Jan 2, 2025

Prefix container-loader before enabling no-unchecked-record-access
AB#26471

@github-actions github-actions bot added area: loader Loader related issues base: main PRs targeted against main branch and removed area: loader Loader related issues labels Jan 2, 2025
@github-actions github-actions bot added the area: loader Loader related issues label Jan 2, 2025
@RishhiB RishhiB marked this pull request as ready for review January 3, 2025 16:57
@Copilot Copilot bot review requested due to automatic review settings January 3, 2025 16:57

Choose a reason for hiding this comment

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

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

@RishhiB RishhiB merged commit 34d2982 into microsoft:main Jan 6, 2025
28 checks passed
Comment on lines -95 to +97
baseSnapshot.trees.default.trees.root.unreferenced,
baseSnapshot.trees.default?.trees.root?.unreferenced,
Copy link
Contributor

Choose a reason for hiding this comment

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

@RishhiB, what do this and other ? additions have to do with no-unchecked-record-access rule?

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 believe its because baseSnapshot.trees is of type [path: string]: ISnapshotTree, so default or root record access may not exist

Comment on lines -157 to 160
const attributesId = pendingState.baseSnapshot.trees[".protocol"].blobs.attributes;
const attributes = pendingState.snapshotBlobs[attributesId];
const attributesId: string | undefined =
pendingState.baseSnapshot.trees[".protocol"]?.blobs.attributes;
const attributes: string | undefined = pendingState.snapshotBlobs[attributesId];
return JSON.parse(attributes) as IDocumentAttributes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this pattern isn't actually working for us.
JSON.parse does not accept undefined. It only accepts string.
If you hover on attributes on line 160 in VS Code, it will say the type is string. TypeScript appears to ignore the explicit type when it thinks it can successfully narrow the type to something more specific.
It doesn't look like we can use this pattern to be safe. (It might be okay if the linter followed the uses of the variables to double check typing. I would guess that is pretty hard.)

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

Successfully merging this pull request may close these issues.

3 participants