Skip to content

Conversation

@tt-a1i
Copy link
Contributor

@tt-a1i tt-a1i commented Dec 18, 2025

Summary

Closes #8494

  • Added support for bracket notation: process.env["VAR"], import.meta.env["VAR"]
  • Added support for Bun runtime: Bun.env.VAR, Bun.env["VAR"]
  • Dynamic property access (variables, template literals with interpolation, concatenation) is still skipped

Test plan

  • Added test cases in invalid.js for bracket notation and Bun.env
  • Added test cases in valid.js for allowed variables with bracket notation and Bun.env
  • Updated validDynamicAccess.js to clarify that only truly dynamic access is skipped
  • All 26 existing tests pass

AI Assistance Disclosure

I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.

- Support bracket notation: process.env["VAR"], import.meta.env["VAR"]
- Support Bun runtime: Bun.env.VAR, Bun.env["VAR"]
- Only check string literal keys; dynamic keys are still skipped
@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: 4b0b8a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Dec 18, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 18, 2025

CodSpeed Performance Report

Merging #8498 will not alter performance

Comparing tt-a1i:feat/env-vars-bracket-bun (4b0b8a5) with main (922b04f)

Summary

✅ 58 untouched
⏩ 95 skipped1

Footnotes

  1. 95 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.

@tt-a1i tt-a1i marked this pull request as ready for review December 18, 2025 10:11
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2025

Walkthrough

This PR expands the noUndeclaredEnvVars lint to recognise additional environment-access patterns: bracket notation (e.g. process.env["VAR"], import.meta.env["VAR"]), Bun (Bun.env.VAR, Bun.env["VAR"]) and Deno (Deno.env.get("VAR")). The rule's query type was widened to match static and computed member expressions, extraction logic was refactored into static/computed helpers, Deno env.get handling added, global env object checks extended to Bun, and diagnostics remain governed by defaults/options before reporting.

Possibly related PRs

Suggested labels

A-Parser, A-Diagnostic

Suggested reviewers

  • dyc3
  • ematipico

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the main feature additions: bracket notation support and Bun.env support for the noUndeclaredEnvVars rule.
Description check ✅ Passed The description clearly explains the changes made, includes the linked issue reference, and documents the test plan and implementation details.
Linked Issues check ✅ Passed All objectives from #8494 are met: bracket notation support added [valid.js, invalid.js], Bun.env support added [no_undeclared_env_vars.rs], and Deno.env.get bonus support included with tests.
Out of Scope Changes check ✅ Passed All changes are directly related to extending the noUndeclaredEnvVars rule; the changeset entry and test updates are appropriately scoped to the feature.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (1)

264-267: Consider consolidating the VERCEL exact match.

"VERCEL" could be added to DEFAULT_ALLOWED_ENV_VARS rather than being special-cased here. The array is already sorted, and it would keep the logic simpler.

🔎 Suggested change
 const DEFAULT_ALLOWED_ENV_VARS: &[&str] = &[
-    "CI", "HOME", "NODE_ENV", "PATH", "PWD", "SHELL", "TZ", "USER",
+    "CI", "HOME", "NODE_ENV", "PATH", "PWD", "SHELL", "TZ", "USER", "VERCEL",
 ];

Then remove lines 264-267.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 922b04f and bcc886a.

⛔ Files ignored due to path filters (3)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (5)
  • .changeset/bracket-bun-env-support.md (1 hunks)
  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (5 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
crates/**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update inline rustdoc documentation for rules, assists, and their options when adding new features or changing existing features in Rust crates

Files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
.changeset/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Write changesets that are concise (1-3 sentences), user-focused, use past tense for actions taken and present tense for Biome behavior, include code examples for rules, and end sentences with periods

Files:

  • .changeset/bracket-bun-env-support.md
🧠 Learnings (23)
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.jsonc : Use `.jsonc` files in test specs with code snippets as array of strings to test rules in script environment (no import/export syntax)

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Check if a variable is global before banning it to avoid false positives when the variable is redeclared in local scope; use the semantic model to verify global scope

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js
  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js
  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnknown` prefix for rules that report mistyped entities in CSS (e.g., `noUnknownUnit`)

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js
  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/tests/specs/**/*.{js,ts,tsx,jsx,json,css} : Test rules using snapshot tests via the `insta` library with test cases in `tests/specs/<group>/<rule_name>/` directories prefixed by `invalid` or `valid`

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Deprecate rules by adding a `deprecated` field to the `declare_lint_rule!` macro with a message explaining the reason for deprecation (e.g., 'Use the rule noAnotherVar')

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnused` prefix for rules that report unused entities (e.g., `noUnusedVariables`)

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRestricted` prefix for rules that report user-banned entities (e.g., `noRestrictedGlobals`)

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnsafe` prefix for rules that report code leading to runtime failures (e.g., `noUnsafeOptionalChaining`)

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Wrap optional rule option fields in `Option<_>` to properly track set vs unset options during configuration merging

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Implement custom `Queryable` types and `Visitor` traits for rules requiring deep AST inspection to avoid redundant traversal passes

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : For tokens that are not mandatory, use helper functions instead of hardcoding

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use the `dbg_write!` macro to debug formatter output instead of other logging methods

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `p.eat(token)` for optional tokens, `p.expect(token)` for required tokens, `parse_rule(p).ok(p)` for optional nodes, and `parse_rule(p).or_add_diagnostic(p, error)` for required nodes

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `diagnostic` function must return a `RuleDiagnostic` that defines the message reported to the user using the `markup!` macro

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Commit rule changes with message format: `feat(biome_<crate>): <ruleName>` to follow Biome's conventional commit style

Applied to files:

  • .changeset/bracket-bun-env-support.md
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js
🧬 Code graph analysis (3)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js (2)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (2)
  • process (38-38)
  • Bun (44-44)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDestructuring.js (3)
  • process (5-5)
  • process (11-11)
  • process (14-14)
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (2)
crates/biome_js_syntax/src/expr_ext.rs (1)
  • global_identifier (1896-1916)
crates/biome_js_analyze/src/services/turborepo.rs (1)
  • model (59-61)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js (2)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (1)
  • process (38-38)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDestructuring.js (3)
  • process (5-5)
  • process (11-11)
  • process (14-14)
🔇 Additional comments (9)
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (4)

164-186: Solid extraction logic for static member access.

The helper correctly validates the .env member and extracts the variable name from the rightmost static member. Clean and straightforward.


188-218: Nice handling of computed member expressions.

Correctly extracts only string literal keys and skips truly dynamic access patterns. The use of inner_string_text properly handles quoted strings.


220-229: Correct global scope validation.

Properly uses the semantic model to ensure process and Bun aren't locally shadowed. This follows best practices for avoiding false positives. Based on learnings, this is the correct approach.


107-148: Well-structured rule logic.

Clean flow with early returns, proper handling of both expression types, and correct validation order. The refactoring from the previous implementation is nicely done.

.changeset/bracket-bun-env-support.md (1)

1-5: Changeset looks good.

Concise, user-focused, uses past tense, and links the issue. Follows the changeset guidelines nicely.

crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js (1)

10-17: Good test coverage for new patterns.

Covers bracket notation for both process.env and import.meta.env, plus Bun.env with both dot and bracket access. Nicely comprehensive.

crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (2)

25-34: Excellent coverage of valid patterns.

Good mix of bracket notation and Bun.env patterns with default-allowed variables. The tests properly verify that allowed variables work across all access methods.


42-46: Good symmetry with the process shadowing test.

Mirrors the local process shadowing test for Bun, ensuring the semantic model correctly handles local variable shadowing for both globals.

crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js (1)

1-23: Clear documentation of dynamic access behaviour.

The updated comments accurately distinguish between truly dynamic access (skipped) and string literal bracket access (now checked). Line 22-23 is particularly helpful for anyone reading these tests.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

I love the improvements, thank you @tt-a1i for that. I left some feedback. Mainly:

  • add Deno.env.get
  • remove the allocation of String

pub struct EnvVarAccess {
/// The name of the environment variable
env_var_name: TokenText,
env_var_name: String,
Copy link
Member

Choose a reason for hiding this comment

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

Any chance we can avoid storing a String? There's no need, If you can't extract TokenText, you can store a HtmlSyntaxToken. From there, we can read its trimmed value when we print the diagnostic

- Update changeset to use past tense per guidelines
- Avoid String allocations by using TokenText directly
- Add Deno.env.get("VAR") support
- Add comprehensive test cases for Deno runtime
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (1)

25-28: Consider clarifying the comment.

The comment "Bracket notation with allowed variables" might be read as "bracket notation using variables", but these are string literals accessing allowed environment variable names. Perhaps "Bracket notation with allowed env var names" would be clearer?

That said, the test cases themselves look spot on.

crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (1)

264-265: Minor: redundant .clone() before omit_parentheses().

The as_any_js_expression() returns an owned value, and omit_parentheses() consumes and returns an owned AnyJsExpression. The intermediate .clone() isn't strictly necessary.

Proposed fix
-    let first_arg = first_arg.as_any_js_expression()?.clone().omit_parentheses();
+    let first_arg = first_arg.as_any_js_expression()?.omit_parentheses();
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcc886a and 1bb0c1b.

⛔ Files ignored due to path filters (3)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (5)
  • .changeset/bracket-bun-env-support.md (1 hunks)
  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (5 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (1 hunks)
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/bracket-bun-env-support.md
🧰 Additional context used
📓 Path-based instructions (1)
crates/**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update inline rustdoc documentation for rules, assists, and their options when adding new features or changing existing features in Rust crates

Files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
🧠 Learnings (21)
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Check if a variable is global using the semantic model to avoid false positives

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
  • crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Assist rules should detect refactoring opportunities and emit code action signals

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : Add `issue_number` field to `declare_lint_rule!` macro for work-in-progress rules

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `RuleSource::Eslint(...).same()` when implementing a rule that matches the behavior of an ESLint rule

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Set `version` field to `next` in `declare_lint_rule!` macro

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : Place new rules inside the `nursery` group during development

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules should perform static analysis of source code to detect invalid or error-prone patterns and emit diagnostics with proposed fixes

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : Set `recommended` field to `false` for new rules in the nursery group

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Wrap rule options fields in `Option<>` to properly track set and unset options during merge

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : For tokens that are not mandatory, use helper functions instead of hardcoding

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Rule documentation code blocks should be ordered as language, expect_diagnostic, options/full_options/use_options, ignore, file

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Set `language` to `jsx`, `ts`, or `tsx` for rules that only apply to specific JavaScript dialects

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `p.eat(token)` for optional tokens, `p.expect(token)` for required tokens, `parse_rule(p).ok(p)` for optional nodes, and `parse_rule(p).or_add_diagnostic(p, error)` for required nodes

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use the `dbg_write!` macro to debug formatter output instead of other logging methods

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Each invalid code example in rule documentation must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Implement Queryable trait for custom query match types in analyzer rules

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `ctx.model()` to access semantic model information in a rule

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
🧬 Code graph analysis (4)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (1)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDestructuring.js (3)
  • process (5-5)
  • process (11-11)
  • process (14-14)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js (2)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (3)
  • process (38-38)
  • Bun (44-44)
  • Deno (55-55)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDestructuring.js (3)
  • process (5-5)
  • process (11-11)
  • process (14-14)
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (2)
crates/biome_js_syntax/src/expr_ext.rs (1)
  • global_identifier (1896-1916)
crates/biome_js_analyze/src/services/turborepo.rs (1)
  • model (59-61)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js (2)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (3)
  • process (38-38)
  • Bun (44-44)
  • Deno (55-55)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDestructuring.js (3)
  • process (5-5)
  • process (11-11)
  • process (14-14)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: End-to-end tests
  • GitHub Check: Documentation
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Test Node.js API
🔇 Additional comments (13)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js (2)

11-17: Excellent test coverage for the new features.

The bracket notation and Bun.env test cases properly cover the scenarios described in the PR objectives. Both dot and bracket notation are tested for Bun.env, and bracket notation is tested for both process.env and import.meta.env.


19-21: Documentation inconsistency: Deno support not mentioned in PR summary.

The PR title and summary mention bracket notation and Bun.env support, but these Deno.env.get test cases suggest the implementation also includes Deno support. Consider updating the PR title/summary to reflect this additional functionality.

crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js (2)

19-26: Good coverage of dynamic access patterns for new runtime sources.

The examples properly demonstrate truly dynamic access (variable-based) for import.meta.env, Bun.env, and Deno.env.get. This is consistent with the file's purpose and ensures the linter correctly skips these patterns.


28-30: Excellent clarification of the dynamic vs. static distinction.

These comments prevent confusion by explicitly documenting that string literal bracket access (e.g. process.env["VAR"]) is now checked, contrasting it with the truly dynamic patterns tested in this file.

crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js (2)

30-46: LGTM – nice defensive testing.

The Bun.env patterns look correct, and the local Bun shadow test (lines 42-46) mirrors the existing process pattern nicely. Good coverage for ensuring the rule distinguishes global from local scope.


48-57: Deno support is intentional and fully tested.

Good catch on the scope mismatch between the PR title and actual implementation, but the test coverage confirms this was deliberate. Both invalid.js and valid.js include comprehensive Deno.env.get test cases (undeclared and allowed patterns), demonstrating proper test symmetry. The feature is solid.

crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (7)

6-10: LGTM!

Imports correctly expanded to support the new computed member expression handling and Deno.env.get() call detection.


23-28: Documentation updated correctly.

The rustdoc now reflects all supported access patterns including bracket notation and runtime-specific APIs. Clear and comprehensive.


118-126: Good use of two-level Option pattern.

The Option<Option<TokenText>> return type from match_deno_env_get cleanly distinguishes between "not a Deno.env.get pattern" (outer None) and "matched pattern but couldn't extract static key" (inner None). Early return prevents unnecessary processing for non-Deno cases.


160-182: LGTM!

Clean extraction logic that correctly navigates the member expression tree. Returns TokenText directly from the token, addressing the previous feedback about avoiding String storage.


184-214: LGTM!

Correctly handles bracket notation whilst appropriately skipping dynamic accesses. The omit_parentheses() call ensures wrapped string literals are also handled.


216-225: Correct use of semantic model.

Using model.binding(&reference).is_none() to verify the identifier isn't shadowed by a local binding prevents false positives. Based on learnings, this is the recommended approach.


274-289: LGTM!

Clean consolidation of the env var validation logic. The check ordering (defaults → options → turbo config) is sensible, evaluating cheaper checks first.

@tt-a1i
Copy link
Contributor Author

tt-a1i commented Dec 19, 2025

I love the improvements, thank you @tt-a1i for that. I left some feedback. Mainly:

  • add Deno.env.get
  • remove the allocation of String

Done, also added Deno.env.get support with tests.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (1)

227-279: Deno.env.get detection is thorough.

The implementation correctly validates the entire call pattern and ensures Deno is global. The nested Option<Option<TokenText>> return type effectively distinguishes "not a match" from "matched but key unresolved".

Consider adding a doc comment explaining the return semantics and why optional chaining is skipped.

📝 Suggested documentation
+/// Matches Deno.env.get("VAR") patterns and extracts the variable name.
+///
+/// Returns:
+/// - `None` if the expression is not a Deno.env.get pattern
+/// - `Some(None)` if it matches Deno.env.get but the key cannot be statically resolved
+/// - `Some(Some(name))` if it matches and the key is a string literal
 fn match_deno_env_get(
     member_expr: &AnyJsMemberExpression,
     model: &biome_js_semantic::SemanticModel,
 ) -> Option<Option<TokenText>> {
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bb0c1b and 4b0b8a5.

📒 Files selected for processing (1)
  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
crates/**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update inline rustdoc documentation for rules, assists, and their options when adding new features or changing existing features in Rust crates

Files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
🧠 Learnings (21)
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Check if a variable is global using the semantic model to avoid false positives

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Assist rules should detect refactoring opportunities and emit code action signals

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : Place new rules inside the `nursery` group during development

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : Add `issue_number` field to `declare_lint_rule!` macro for work-in-progress rules

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `domains` field in `declare_lint_rule!` to tag rules that belong to specific concepts like testing or frameworks

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Set `version` field to `next` in `declare_lint_rule!` macro

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules should perform static analysis of source code to detect invalid or error-prone patterns and emit diagnostics with proposed fixes

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/lib/**/*.rs : Wrap rule options fields in `Option<>` to properly track set and unset options during merge

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : Set `recommended` field to `false` for new rules in the nursery group

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `RuleSource::Eslint(...).same()` when implementing a rule that matches the behavior of an ESLint rule

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : For tokens that are not mandatory, use helper functions instead of hardcoding

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Rule documentation code blocks should be ordered as language, expect_diagnostic, options/full_options/use_options, ignore, file

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Set `language` to `jsx`, `ts`, or `tsx` for rules that only apply to specific JavaScript dialects

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `p.eat(token)` for optional tokens, `p.expect(token)` for required tokens, `parse_rule(p).ok(p)` for optional nodes, and `parse_rule(p).or_add_diagnostic(p, error)` for required nodes

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use the `dbg_write!` macro to debug formatter output instead of other logging methods

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Each invalid code example in rule documentation must emit exactly one diagnostic

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Implement Queryable trait for custom query match types in analyzer rules

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
📚 Learning: 2025-12-19T12:53:30.399Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-12-19T12:53:30.399Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/**/*.rs : Use `ctx.model()` to access semantic model information in a rule

Applied to files:

  • crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (3)
crates/biome_js_syntax/src/expr_ext.rs (1)
  • global_identifier (1896-1916)
crates/biome_js_analyze/src/services/turborepo.rs (1)
  • model (59-61)
crates/biome_js_analyze/src/lint/complexity/use_optional_chain.rs (1)
  • get_member (1037-1062)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: End-to-end tests
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Documentation
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_js_formatter)
🔇 Additional comments (8)
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs (8)

6-10: LGTM! Imports align with new functionality.

The additional imports for computed member expressions, call expressions, and string utilities are necessary for bracket notation and Deno.env.get support.


23-27: Excellent documentation updates.

The rustdoc clearly describes all supported patterns, including the new bracket notation and runtime-specific accesses.


103-103: Correct query type generalisation.

Broadening to AnyJsMemberExpression properly enables matching both dot and bracket notation.


108-144: Well-structured control flow.

The logic clearly separates Deno's method-call pattern from the property-access patterns, then dispatches to the appropriate extraction helper.


161-182: Solid extraction logic for dot notation.

Correctly extracts the environment variable name and parent object, and properly uses TokenText to avoid allocations.


186-214: Robust bracket-notation handling.

The function correctly extracts string-literal keys whilst skipping dynamic accesses. Using inner_string_text avoids unnecessary allocations.


217-225: Correct global identifier verification.

Properly uses the semantic model to verify that process or Bun are global identifiers, not shadowed by local bindings. Based on learnings, this is the correct approach to avoid false positives.


281-296: Clean centralised validation.

The layered checks (defaults → options → declarations) are clear and maintainable.

Copy link
Member

@Netail Netail left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📎 Support other methods of accessing environment variables for noUndeclaredEnvVars

3 participants