Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 23, 2025

Generate a file defining the vars that each environment (env) provides.

This isn't used for anything yet, but it will be in next PR #17293.

Vars for each environment are stored in this form:

{
  readonly: ["var1", "var2", "var3"],
  writable: ["var4", "var5"],
}

instead of the more obvious:

{
  var1: false,
  var2: false,
  var3: false,
  var4: true,
  var5: true,
}

...because it's shorter code when there's lots of vars (which there usually are), and iterating through arrays I assume is faster than iterating through properties of objects (which are essentially hash maps when they're large).

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-ast-tools Area - AST tools A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior 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.

@overlookmotel overlookmotel marked this pull request as ready for review December 23, 2025 02:06
Copilot AI review requested due to automatic review settings December 23, 2025 02:06
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 a code generator that creates TypeScript environment definitions for Oxlint JS plugins. The generator reads JavaScript global variable definitions from the javascript-globals crate and outputs them in a structured format with readonly and writable arrays. These definitions are not yet used but will be integrated in a subsequent PR (#17293).

  • Adds OxlintEnvsGenerator in Rust to generate environment definitions from the javascript-globals crate
  • Generates apps/oxlint/src-js/generated/envs.ts containing environment presets with readonly/writable variable lists
  • Updates build infrastructure to include the new generator

Reviewed changes

Copilot reviewed 4 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tasks/ast_tools/src/generators/oxlint_envs.rs New generator that reads JavaScript globals from the javascript-globals crate and outputs TypeScript environment definitions with variables categorized as readonly or writable
tasks/ast_tools/src/generators/mod.rs Adds module declaration and public export for OxlintEnvsGenerator with conditional compilation for JS generation
tasks/ast_tools/src/main.rs Registers OxlintEnvsGenerator in the generators list with the generate-js feature flag
tasks/ast_tools/Cargo.toml Adds javascript-globals dependency to the ast_tools workspace
apps/oxlint/src-js/generated/envs.ts Generated TypeScript file containing environment definitions with interface and constants for each environment (e.g., browser, node, ES2015-ES2026, etc.)
Cargo.lock Updates dependency graph to include javascript-globals for oxc_ast_tools
.github/generated/ast_changes_watch_list.yml Adds the generated envs.ts file to the watch list for AST change detection

💡 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
@overlookmotel overlookmotel force-pushed the om/12-22-refactor_linter_plugins_add_environments_definitions branch from ba840df to 61868e3 Compare December 23, 2025 02:27
@graphite-app graphite-app bot force-pushed the om/12-22-feat_linter_plugins_pass_env_from_rust_to_js branch 2 times, most recently from d1cbc59 to 0e0b237 Compare December 23, 2025 10:47
@graphite-app graphite-app bot force-pushed the om/12-22-refactor_linter_plugins_add_environments_definitions branch from 61868e3 to 8dce152 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

Generate a file defining the vars that each environment (`env`) provides.

This isn't used for anything yet, but it will be in next PR #17293.

Vars for each environment are stored in this form:

```js
{
  readonly: ["var1", "var2", "var3"],
  writable: ["var4", "var5"],
}
```

instead of the more obvious:

```js
{
  var1: false,
  var2: false,
  var3: false,
  var4: true,
  var5: true,
}
```

...because it's shorter code when there's lots of vars (which there usually are), and iterating through arrays I assume is faster than iterating through properties of objects (which are essentially hash maps when they're large).
@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 force-pushed the om/12-22-refactor_linter_plugins_add_environments_definitions branch from 8dce152 to c9512a9 Compare December 23, 2025 10:54
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 23, 2025

CodSpeed Performance Report

Merging #17292 will not alter performance

Comparing om/12-22-refactor_linter_plugins_add_environments_definitions (8dce152) with main (ed79fca)1

Summary

✅ 29 untouched
⏩ 16 skipped2

Footnotes

  1. No successful run was found on om/12-22-feat_linter_plugins_pass_env_from_rust_to_js (1dc371e) during the generation of this report, so main (ed79fca) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 16 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Base automatically changed from om/12-22-feat_linter_plugins_pass_env_from_rust_to_js to main December 23, 2025 10:59
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 23, 2025
@graphite-app graphite-app bot merged commit c9512a9 into main Dec 23, 2025
22 checks passed
@graphite-app graphite-app bot deleted the om/12-22-refactor_linter_plugins_add_environments_definitions branch December 23, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast-tools Area - AST tools A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants