-
-
Notifications
You must be signed in to change notification settings - Fork 792
feat(noUndeclaredEnvVars): add bracket notation and Bun.env support #8498
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
base: main
Are you sure you want to change the base?
Conversation
- 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 detectedLatest commit: 4b0b8a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
CodSpeed Performance ReportMerging #8498 will not alter performanceComparing Summary
Footnotes
|
WalkthroughThis PR expands the Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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.
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 toDEFAULT_ALLOWED_ENV_VARSrather 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
⛔ Files ignored due to path filters (3)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js.snapis excluded by!**/*.snapand 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.jscrates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.jscrates/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.jscrates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.jscrates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rscrates/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.jscrates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.jscrates/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.jscrates/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
.envmember 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_textproperly handles quoted strings.
220-229: Correct global scope validation.Properly uses the semantic model to ensure
processandBunaren'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.envandimport.meta.env, plusBun.envwith 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
processshadowing test forBun, 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.
ematipico
left a comment
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.
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, |
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.
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
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
Outdated
Show resolved
Hide resolved
crates/biome_js_analyze/src/lint/nursery/no_undeclared_env_vars.rs
Outdated
Show resolved
Hide resolved
- 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
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.
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()beforeomit_parentheses().The
as_any_js_expression()returns an owned value, andomit_parentheses()consumes and returns an ownedAnyJsExpression. 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
⛔ Files ignored due to path filters (3)
crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/invalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/valid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noUndeclaredEnvVars/validDynamicAccess.js.snapis excluded by!**/*.snapand 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.rscrates/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.jsandvalid.jsinclude 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 frommatch_deno_env_getcleanly 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
TokenTextdirectly from the token, addressing the previous feedback about avoidingStringstorage.
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.
Done, also added Deno.env.get support with tests. |
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.
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
Denois global. The nestedOption<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
📒 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
AnyJsMemberExpressionproperly 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
TokenTextto avoid allocations.
186-214: Robust bracket-notation handling.The function correctly extracts string-literal keys whilst skipping dynamic accesses. Using
inner_string_textavoids unnecessary allocations.
217-225: Correct global identifier verification.Properly uses the semantic model to verify that
processorBunare 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.
Netail
left a comment
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.
LGTM
Summary
Closes #8494
process.env["VAR"],import.meta.env["VAR"]Bun.env.VAR,Bun.env["VAR"]Test plan
invalid.jsfor bracket notation and Bun.envvalid.jsfor allowed variables with bracket notation and Bun.envvalidDynamicAccess.jsto clarify that only truly dynamic access is skippedAI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.