-
-
Notifications
You must be signed in to change notification settings - Fork 714
feat(useConst): don't report uninit variables read befroe to be written #7201
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
Conversation
🦋 Changeset detectedLatest commit: 6322891 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 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 |
WalkthroughAdds a changeset for a minor release of @biomejs/biome and modifies the useConst lint: it no longer reports bindings whose very first reference is a read from an inner function before a later write. The lint logic is simplified to bail out when the first reference is a read; AnyJsControlFlowRoot import removed and Semantic path switched to crate::services::semantic::Semantic. A Caveats docs note about potential false negatives was added, a comment typo fixed, and no public API signatures were changed. Suggested labels
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ 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). (25)
✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
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: 1
🧹 Nitpick comments (6)
.changeset/tired-results-knock.md (5)
5-5
: Grammar: “read before to be written” → “read before being written”.Clearer and idiomatic phrasing; keeps intent intact.
Apply this diff:
-Implemented [#7174](https://github.com/biomejs/biome/issues/7174). [`useConst`](https://biomejs.dev/linter/rules/use-const/) no longer reports variables read before to be written. +Implemented [#7174](https://github.com/biomejs/biome/issues/7174). [`useConst`](https://biomejs.dev/linter/rules/use-const/) no longer reports variables that are read before being written.
7-7
: Typo and punctuation: remove double colon.Single colon reads better here.
-Previously, `useConst` reported uninitialised variables that were read in an inner function before being written, as shown in the following example:: +Previously, `useConst` reported uninitialised variables that were read in an inner function before being written, as shown in the following example:
17-17
: Grammar: “has be written” → “has been written”; optional comma.Polishes the sentence and matches the style guide.
-This can produce false positives in the case where `f` is called before `v` has be written as in the following code: +This can produce false positives in the case where `f` is called before `v` has been written, as in the following code:
28-28
: Possessive fix: “rule fix” → “rule’s fix”.Small readability improvement.
-Although this is an expected behavior of the original implementation, we consider it problematic since the rule fix is marked as safe. +Although this is an expected behavior of the original implementation, we consider it problematic since the rule’s fix is marked as safe.
30-31
: Clarify the false-negative statement.Make the example explicit.
-However, this has the disadvantage of resulting in false negatives, such as reporting the first code. +However, this has the disadvantage of resulting in false negatives, such as not reporting the first example.crates/biome_js_analyze/src/lint/style/use_const.rs (1)
219-221
: Nit: pluralise comment and tighten wording.Minor doc fix for clarity.
- // If there are multiple assignment or the write is not in the same scope + // If there are multiple assignments, or if the write is not in the same scope
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_js_analyze/tests/specs/style/useConst/invalid.jsonc.snap
is excluded by!**/*.snap
and included by**
📒 Files selected for processing (2)
.changeset/tired-results-knock.md
(1 hunks)crates/biome_js_analyze/src/lint/style/use_const.rs
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}
📄 CodeRabbit Inference Engine (CLAUDE.md)
Format code (Rust + TOML) using
just format
Format Rust and TOML files before committing (use
just f
/just format
).
Files:
crates/biome_js_analyze/src/lint/style/use_const.rs
crates/biome_*/**/*
📄 CodeRabbit Inference Engine (CLAUDE.md)
Core crates must be located in
/crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/style/use_const.rs
.changeset/*.md
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
.changeset/*.md
: Create changesets withjust new-changeset
; store them in.changeset/
with correct frontmatter (package keys and change type).
In changeset descriptions, follow content conventions: user-facing changes only; past tense for what you did; present tense for current behavior; link issues for fixes; link rules/assists; include representative code blocks; end every sentence with a period.
When adding headers in a changeset, only use #### or ##### levels.
Files:
.changeset/tired-results-knock.md
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Set version: "next" in declare_lint_rule! for new or changing rules
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : When banning globals (e.g., console.log), consult the semantic model to avoid flagging locally shadowed bindings
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Use the Semantic<> query and ctx.model() when semantic information is required; ensure the query runs in the phase where services are available
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : When returning a code action, construct JsRuleAction with ctx.action_category(ctx.category(), ctx.group()) and ctx.metadata().applicability()
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : If a rule provides code actions, add fix_kind to declare_lint_rule! and pass category and applicability in action()
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : When porting a lint rule, specify sources in declare_lint_rule! (e.g., RuleSource::Eslint(...).same() or .inspired())
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Use meaningful, cross-language-capable rule names when appropriate; use language/framework-specific names when constrained
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Use the declare_lint_rule! macro to declare each rule
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : If multiple services are needed, retrieve them via ctx.get_service::<Type>() and ensure the rule runs in a phase where they exist
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Set the language field in declare_lint_rule! to the primary language/dialect (js, jsx, ts, tsx)
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Access rule options within a rule via ctx.options()
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
🪛 LanguageTool
.changeset/tired-results-knock.md
[grammar] ~17-~17: The verb form ‘be’ does not seem to be suitable in this context.
Context: ...case where f
is called before v
has be written as in the following code: ```j...
(HAVE_VB)
[uncategorized] ~17-~17: Possible missing comma found.
Context: ...e where f
is called before v
has be written as in the following code: ```js let v;...
(AI_HYDRA_LEO_MISSING_COMMA)
⏰ 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). (24)
- GitHub Check: autofix
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Documentation
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_module_graph)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_html_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_package)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_html_formatter)
- GitHub Check: Bench (biome_json_formatter)
🔇 Additional comments (1)
crates/biome_js_analyze/src/lint/style/use_const.rs (1)
1-1
: Import change looks correct.Switching to
crate::services::semantic::Semantic
aligns with current services usage in this crate.
@Conaclos are you sure that the docs don't need to be updated? I mean we're changing the behaviour of the rule... |
@coderabbitai Please apply nitpick comments. |
This is an edge case. The previous behavior was not documented. Do you think it is worth to document a such case? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I think we could just add a small paragraph saying "The rule doesn't detect...". This might prevent users from filing an issue regarding the past behaviour |
@ematipico fixed in aa779e9 |
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
♻️ Duplicate comments (1)
crates/biome_js_analyze/src/lint/style/use_const.rs (1)
244-246
: Don’t assume iterator yields source order; pick earliest by position.Using next() on all_references(model) risks misclassifying the “first” reference unless the API guarantees source order. Select the minimum by text range start.
- // If a read occurs before a write. - if binding.all_references(model).next()?.is_read() { + // If the first source-ordered reference is a read, skip reporting. + let first_is_read = binding + .all_references(model) + .min_by_key(|r| r.syntax().text_range().start())? + .is_read(); + if first_is_read { return None; }If the iterator order is guaranteed by contract, keep next() but add a brief comment citing that guarantee.
🧹 Nitpick comments (6)
.changeset/tired-results-knock.md (4)
5-5
: Grammar: “before being written”.Tweak the phrasing for clarity.
-Implemented [#7174](https://github.com/biomejs/biome/issues/7174). [`useConst`](https://biomejs.dev/linter/rules/use-const/) no longer reports variables read before to be written. +Implemented [#7174](https://github.com/biomejs/biome/issues/7174). [`useConst`](https://biomejs.dev/linter/rules/use-const/) no longer reports variables read before being written.
7-8
: Typos: double colon and inconsistent spelling.
- Single colon after “example”.
- Prefer “uninitialized” to stay consistent with the rest of the docs.
-Previously, `useConst` reported uninitialised variables that were read in an inner function before being written, as shown in the following example:: +Previously, `useConst` reported uninitialized variables that were read in an inner function before being written, as shown in the following example:
17-17
: Grammar: “has been written, …”.Fix verb form and add a comma for the subordinate clause.
-This can produce false positives in the case where `f` is called before `v` has be written as in the following code: +This can produce false positives when `f` is called before `v` has been written, as in the following code:
28-31
: Wording: clarify rationale and consequence.
- “rule’s fix” reads better.
- Spell out the false-negative example.
-Although this is an expected behavior of the original implementation, we consider it problematic since the rule fix is marked as safe. -To avoid false positives like this, the rule now ignores the previous examples. -However, this has the disadvantage of resulting in false negatives, such as reporting the first code. +Although this was expected behavior of the original implementation, we consider it problematic because the rule's fix is marked as safe. +To avoid false positives like this, the rule now ignores this pattern. +However, this has the disadvantage of resulting in false negatives, such as not reporting the first example.crates/biome_js_analyze/src/lint/style/use_const.rs (2)
74-86
: Nice “Caveats” addition; confirm or avoid hard-coding the version.The note is helpful. If “v2.2” isn’t final, either confirm it or remove the version to prevent staleness.
Proposed version-agnostic wording:
- /// Since v2.2, the rule no longer reports variables that are read in an inner function before being written. + /// The rule no longer reports variables that are read in an inner function before being written.
232-233
: Tiny typo in comment.Plural noun.
- // If there are multiple assignment or the write is not in the same scope + // If there are multiple assignments or the write is not in the same scope
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/tired-results-knock.md
(1 hunks)crates/biome_js_analyze/src/lint/style/use_const.rs
(4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{rs,toml}
📄 CodeRabbit Inference Engine (CLAUDE.md)
Format code (Rust + TOML) using
just format
Format Rust and TOML files before committing (use
just f
/just format
).
Files:
crates/biome_js_analyze/src/lint/style/use_const.rs
crates/biome_*/**/*
📄 CodeRabbit Inference Engine (CLAUDE.md)
Core crates must be located in
/crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/style/use_const.rs
.changeset/*.md
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
.changeset/*.md
: Create changesets withjust new-changeset
; store them in.changeset/
with correct frontmatter (package keys and change type).
In changeset descriptions, follow content conventions: user-facing changes only; past tense for what you did; present tense for current behavior; link issues for fixes; link rules/assists; include representative code blocks; end every sentence with a period.
When adding headers in a changeset, only use #### or ##### levels.
Files:
.changeset/tired-results-knock.md
🧠 Learnings (11)
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : When banning globals (e.g., console.log), consult the semantic model to avoid flagging locally shadowed bindings
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : When returning a code action, construct JsRuleAction with ctx.action_category(ctx.category(), ctx.group()) and ctx.metadata().applicability()
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : If a rule provides code actions, add fix_kind to declare_lint_rule! and pass category and applicability in action()
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : When porting a lint rule, specify sources in declare_lint_rule! (e.g., RuleSource::Eslint(...).same() or .inspired())
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Use meaningful, cross-language-capable rule names when appropriate; use language/framework-specific names when constrained
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Use the declare_lint_rule! macro to declare each rule
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Use the Semantic<> query and ctx.model() when semantic information is required; ensure the query runs in the phase where services are available
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : If multiple services are needed, retrieve them via ctx.get_service::<Type>() and ensure the rule runs in a phase where they exist
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Set the language field in declare_lint_rule! to the primary language/dialect (js, jsx, ts, tsx)
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-11T11:43:46.589Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.589Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Access rule options within a rule via ctx.options()
Applied to files:
crates/biome_js_analyze/src/lint/style/use_const.rs
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
PR: biomejs/biome#7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.
Applied to files:
.changeset/tired-results-knock.md
🪛 LanguageTool
.changeset/tired-results-knock.md
[grammar] ~17-~17: The verb form ‘be’ does not seem to be suitable in this context.
Context: ...case where f
is called before v
has be written as in the following code: ```j...
(HAVE_VB)
[uncategorized] ~17-~17: Possible missing comma found.
Context: ...e where f
is called before v
has be written as in the following code: ```js let v;...
(AI_HYDRA_LEO_MISSING_COMMA)
⏰ 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). (24)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_html_formatter)
- GitHub Check: Bench (biome_package)
- GitHub Check: Bench (biome_module_graph)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_html_parser)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: autofix
🔇 Additional comments (2)
.changeset/tired-results-knock.md (1)
1-3
: Frontmatter looks correct for a minor bump.Package and change type are set as expected.
crates/biome_js_analyze/src/lint/style/use_const.rs (1)
1-1
: Import path change looks good.Switching to crate::services::semantic::Semantic is consistent with the crate layout.
Summary
Implements #7174
useConst
no longer reports variables read before to be written.Previously,
useConst
reported uninitialised variables that were read in an inner function before being written, as shown in the following example::This can produce false positives in the case where
f
is called beforev
has be written as in the following code:Although this is an expected behavior of the original implementation, we consider it problematic since the rule fix is marked as safe.
To avoid false positives like this, the rule now ignores the previous examples.
However, this has the disadvantage of resulting in false negatives, such as reporting the first code.
Test Plan
I updated the rule's test snapshots.
Docs
Not applicable.