Skip to content

Comments

fix: improve global/env translation and cleaning up of overrides#245

Merged
Sysix merged 17 commits intooxc-project:mainfrom
connorshea:globals2
Nov 23, 2025
Merged

fix: improve global/env translation and cleaning up of overrides#245
Sysix merged 17 commits intooxc-project:mainfrom
connorshea:globals2

Conversation

@connorshea
Copy link
Member

@connorshea connorshea commented Nov 15, 2025

Now we treat worker and serviceworker as special envs in the same way as we do with browser and node.

We also remove duplicative envs which are subsets of another enabled env. Right now the supersets are hardcoded, but we should maybe determine the supersets dynamically at runtime so globals updates are accounted for automatically? That can be done as a separate PR, though.

Also add astro, svelte, and vue to the globals list, as those were added to the rust crate.

And de-duplicate identical overrides when they come up and are right next to one another.

We also merge overrides if the only difference is the sets of files, by merging the override objects and combining the file lists.

Assisted by GitHub Copilot + Claude Sonnet 4.5 for parts, but tested with a few complex eslint configs and the existing snapshots and tests.

This ensures that we aren't providing unnecessary extra values for the `env` key.

I wrote a script to confirm these values were the ones that are supersets, but theoretically we could also just update this to use the `globals` package directly and determine supersets at runtime?
This is showing a current problem where multiple extends are not being merged properly, and so we end up with exact-duplicate overrides.
Saw this from the mastodon config file after trying to migrate it, so now it's fixed :)
@connorshea connorshea marked this pull request as ready for review November 22, 2025 07:00
@connorshea connorshea requested a review from Sysix November 22, 2025 07:00
@connorshea
Copy link
Member Author

@Sysix Alright, I fixed another bug and this is ready to go now :) I think the mastodon eslint config now ports over pretty cleanly.

This was heavily helped by AI, but looking through the tests and running it on the snapshots, it looks like it works correctly for all the cases I can come up with.
@connorshea connorshea changed the title Improve global/env translation a bit more fix: improve global/env translation and cleaning up of overrides Nov 22, 2025
connorshea and others added 6 commits November 22, 2025 14:12
…",` overrides being emitted (albeit with differing sets of files).

Will fix this with the next commit.
If the only difference is the set of files, merge the override objects and combine the file lists.
Copy link
Member

@Sysix Sysix left a comment

Choose a reason for hiding this comment

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

@connorshea added a commit to simplify some code. override.files is always an array, no need to check for it. :)

@Sysix Sysix merged commit 51ffd89 into oxc-project:main Nov 23, 2025
3 checks passed
@connorshea
Copy link
Member Author

Thanks!

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.

2 participants