-
-
Notifications
You must be signed in to change notification settings - Fork 763
feat(linter/plugins): pass env from Rust to JS
#17291
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
feat(linter/plugins): pass env from Rust to JS
#17291
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for passing environment (env) configuration from Rust to JavaScript plugins, allowing JS plugins to access environment information alongside globals. The implementation serializes both globals and envs together in a new GlobalsAndEnvs struct.
Key changes:
- Created
GlobalsAndEnvsstruct in Rust to serialize globals and envs together as JSON - Added
env()accessor method toContextHost - Extended JS plugin API to expose
languageOptions.envproperty containing enabled environments - Updated
RuleTesterto supportenvin test case configurations
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
crates/oxc_linter/src/external_linter.rs |
Adds GlobalsAndEnvs struct with custom serialization that only includes enabled environments |
crates/oxc_linter/src/lib.rs |
Uses new GlobalsAndEnvs struct when serializing data for JS plugins |
crates/oxc_linter/src/context/host.rs |
Adds env() method to expose environment configuration |
apps/oxlint/src-js/plugins/globals.ts |
Adds Envs type and tracks envs alongside globals with lazy deserialization |
apps/oxlint/src-js/plugins/context.ts |
Exposes env property on languageOptions for plugin access |
apps/oxlint/src-js/package/rule_tester.ts |
Adds support for env in test case language options with proper normalization |
apps/oxlint/src-js/index.ts |
Exports Envs type for public API |
apps/oxlint/src-js/utils/globals.ts |
Adds ObjectEntries export for TSDown transformation |
apps/oxlint/test/fixtures/languageOptions/plugin.ts |
Updates test plugin to output env information |
apps/oxlint/test/fixtures/languageOptions/output.snap.md |
Updates expected output to include env in diagnostics |
apps/oxlint/test/fixtures/globals/plugin.ts |
Updates globals test plugin to output both globals and env |
apps/oxlint/test/fixtures/globals/output.snap.md |
Updates expected output with env information for various configurations |
apps/oxlint/test/fixtures/globals/files/nested/1.js |
New test file for environment override testing |
apps/oxlint/test/fixtures/globals/files/nested/2.js |
New test file for multiple environment override testing |
apps/oxlint/test/fixtures/globals/.oxlintrc.json |
Adds environment configurations to test overrides with multiple files |
Comments suppressed due to low confidence (1)
apps/oxlint/src-js/plugins/globals.ts:36
- The documentation comment should be updated to reflect that this function now handles both globals and envs, not just globals. Consider changing to "Updates the globals and envs for the file" and updating the parameter description to "Globals and envs for the file as JSON".
/**
* Updates the globals for the file.
*
* TODO(perf): Globals are deserialized once per file to accommodate folder level settings,
* even if the globals haven't changed.
*
* @param globalsJSONInput - Globals for the file as JSON
*/
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1945761 to
61a792c
Compare
61a792c to
d1cbc59
Compare
6d1b1d2 to
1dc371e
Compare
d1cbc59 to
0e0b237
Compare
Merge activity
|
Pass `env` to JS plugins. JS plugins don't do anything with it yet, except allow the user to see it. But they will in a following PR.
0e0b237 to
5cc7c90
Compare

Pass
envto JS plugins. JS plugins don't do anything with it yet, except allow the user to see it. But they will in a following PR.