Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 23, 2025

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.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins C-enhancement Category - New feature or request labels Dec 23, 2025
Copy link
Member Author

overlookmotel commented Dec 23, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copy link
Contributor

Copilot AI left a 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 GlobalsAndEnvs struct in Rust to serialize globals and envs together as JSON
  • Added env() accessor method to ContextHost
  • Extended JS plugin API to expose languageOptions.env property containing enabled environments
  • Updated RuleTester to support env in 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.

@overlookmotel overlookmotel force-pushed the om/12-22-feat_linter_plugins_pass_env_from_rust_to_js branch from 1945761 to 61a792c Compare December 23, 2025 02:27
@graphite-app graphite-app bot changed the base branch from om/12-22-refactor_linter_plugins_rename_var_in_ruletester_ to graphite-base/17291 December 23, 2025 10:39
@graphite-app graphite-app bot force-pushed the om/12-22-feat_linter_plugins_pass_env_from_rust_to_js branch from 61a792c to d1cbc59 Compare December 23, 2025 10:46
@graphite-app graphite-app bot force-pushed the graphite-base/17291 branch from 6d1b1d2 to 1dc371e Compare December 23, 2025 10:46
@graphite-app graphite-app bot changed the base branch from graphite-base/17291 to main December 23, 2025 10:47
@graphite-app graphite-app bot force-pushed the om/12-22-feat_linter_plugins_pass_env_from_rust_to_js branch from d1cbc59 to 0e0b237 Compare December 23, 2025 10:47
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Dec 23, 2025
Copy link
Contributor

camc314 commented Dec 23, 2025

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.
@graphite-app graphite-app bot force-pushed the om/12-22-feat_linter_plugins_pass_env_from_rust_to_js branch from 0e0b237 to 5cc7c90 Compare December 23, 2025 10:53
@graphite-app graphite-app bot merged commit 5cc7c90 into main Dec 23, 2025
20 checks passed
@graphite-app graphite-app bot deleted the om/12-22-feat_linter_plugins_pass_env_from_rust_to_js branch December 23, 2025 10:59
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants