Skip to content

Eslint let const#1435

Merged
demiankatz merged 4 commits intoUniversalViewer:devfrom
LlGC-jop:eslint-let-const
May 21, 2025
Merged

Eslint let const#1435
demiankatz merged 4 commits intoUniversalViewer:devfrom
LlGC-jop:eslint-let-const

Conversation

@LlGC-jop
Copy link
Copy Markdown
Contributor

@LlGC-jop LlGC-jop commented May 20, 2025

Resolves #1429.

Updates the eslint config to error when let could/should be const

Runs that config over the src directory

Manually changes canvas and uv vars to be const because ESLint was unable to do it automatically.

@LlGC-jop LlGC-jop requested a review from demiankatz May 20, 2025 15:19
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
universalviewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2025 8:10am

Copy link
Copy Markdown
Contributor

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @LlGC-jop -- looks good overall, but I have one question below.

Comment thread src/Init.ts
const uvDiv = document.createElement("div");
parent.appendChild(uvDiv);

const uv = new UniversalViewer({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the only change here that might potentially change behavior. It looks like previously, we intentionally registered the resize handler before initializing the UV. I'm not sure why that was, or how significant it is. If this change is safe, then we should remove the if (uv) check inside the resize method below, since it should be safe to assume the variable is always defined... but is it possible there's some reason it's not safe? Did you do any investigation? Do you think we should look into this a little more deeply before merging?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had a similar concern after I moved that line, but it seems fine.

The resize handler only runs when the window triggers it or when the uv variable itself triggers it via an event.

I put a couple of console logs in and they fire when expected and uv is defined as expected.

I think we should keep the if() however, just in case, as I assume we don't want to make changes to parent's width/height if uv isn't defined.

I have however changed it to a guard clause because it makes the code a little cleaner.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think there's any harm in doing this, but I'm not sure if it's necessary -- if we assign const uv to an object prior to setting the event handler, I'm not sure how it's possible for uv to ever evaluate to a false-y value.

I also wonder, if a uv check is needed at all, if it would actually make more sense to put that around the uv.resize call instead of blocking the non-uv-related behavior.

In any case, happy to accept this as-is in the interest of getting this done... but I still have a feeling that this may be more complicated than necessary.

Copy link
Copy Markdown
Contributor

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Giving this an approval so it can be merged -- but let's discuss at today's stand-up first.

@demiankatz demiankatz merged commit 9f9f71b into UniversalViewer:dev May 21, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: COMPLETED

Development

Successfully merging this pull request may close these issues.

Update Const. Configuration for ESLint

2 participants