Skip to content

Update JS syntax to Baseline 2025 using esupgrade#2346

Draft
codingjoe wants to merge 6 commits intodjango-commons:mainfrom
codingjoe:esupgrade
Draft

Update JS syntax to Baseline 2025 using esupgrade#2346
codingjoe wants to merge 6 commits intodjango-commons:mainfrom
codingjoe:esupgrade

Conversation

@codingjoe
Copy link
Copy Markdown
Member

@codingjoe codingjoe commented Apr 18, 2026

Description

I was browsing through the JS code and stumbled upon dated syntax. Since I wrote a tool for it, I ran it. However, I added more commits to manually address some discrepancies.

Checklist:

  • I have added the relevant tests for this change.
  • I have added an item to the Pending section of docs/changes.rst.

AI/LLM Usage

  • This PR includes code generated with the help of an AI/LLM

I got some LLM powered autocomplete help while writing the tests.

@github-actions
Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

Copy link
Copy Markdown
Member

@matthiask matthiask left a comment

Choose a reason for hiding this comment

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

For the record: I mostly agree with the changes here.

I don't really know about the change in debounce though. I think the function should either use promises or async/await, not both (without spending a lot of time thinking about this). Maybe I'm misunderstanding why the change is actually good, but I think I'd prefer the non-async version with an explicit promise.

Comment thread .github/workflows/test.yml Fixed
Comment thread .github/workflows/test.yml Fixed
Comment thread .github/workflows/test.yml Fixed
Comment thread .github/workflows/test.yml Fixed
Comment thread .github/dependabot.yml Fixed
Comment thread .github/workflows/test.yml Fixed
Comment thread .github/workflows/test.yml Fixed
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 18, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@codingjoe
Copy link
Copy Markdown
Member Author

For the record: I mostly agree with the changes here.

Thank you; <3 I wasn't even done yet.

I don't really know about the change in debounce though. I think the function should either use promises or async/await, not both (without spending a lot of time thinking about this). Maybe I'm misunderstanding why the change is actually good, but I think I'd prefer the non-async version with an explicit promise.

Yeah, I can attest that it takes some getting used to. Both versions are fully identical, though. Same as in Python, an async function is a promise/coroutine. As always, syntax is debatable, and we don't have to add esupgrade as a dependency to leave more wiggle room. That being said, it's designed to use ECMAScript's more recent features with full browser support that they have borrowed from Python. So the resulting code "should" be more pleasing to a Pythonista's eye.

That being said, I don't love the debounce implementation. Ideally it could handle both async and synchronous functions. I will propose a more sophisticated solution.

@codingjoe codingjoe force-pushed the esupgrade branch 5 times, most recently from c1277c7 to 147c2a4 Compare April 18, 2026 18:58
Comment thread .github/workflows/test.yml Fixed
Comment thread .github/workflows/test.yml Fixed
vitest:
runs-on: macos-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Comment thread .github/workflows/test.yml Fixed
runs-on: macos-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
debounce didn't cancel the execution but only deplayed the resolution.
It then resolved multiple times with the same values casing the resulting
code to be called multiple times in direct succession on multiple threads.

This can not only resolve into multipe DOM updates but also to race conditions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants