fix(lint): don't report Props interface as unused in Astro files#9101
fix(lint): don't report Props interface as unused in Astro files#9101
Props interface as unused in Astro files#9101Conversation
🦋 Changeset detectedLatest commit: 74d5df4 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 |
99f6116 to
71a36f2
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 WalkthroughAdds an Astro-specific guard to the correctness/noUnusedVariables rule so a top-level Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs`:
- Around line 345-350: Remove the leftover dbg! invocation that prints
binding_name, is_underscore_prefixed, is_defined_in_embedded_binding, and
is_used_as_reference from the no-unused-variables lint implementation; locate
the dbg!(binding_name, is_underscore_prefixed, is_defined_in_embedded_binding,
is_used_as_reference) call in the no_unused_variables rule and delete it (or
replace with a non-std debug logger like trace! if structured runtime logging is
required).
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)
356-365: Astro Props handling looks correct.The logic properly checks all conditions: binding name, embedding kind, binding type, interface declaration, and top-level position via
JsModuleItemList.Minor style note:
let Some(_) = decl.parent::<JsModuleItemList>()could be written asdecl.parent::<JsModuleItemList>().is_some()for consistency with idiomatic Rust, but this is entirely optional.,
♻️ Optional: more idiomatic check
if binding_name == "Props" && let EmbeddingKind::Astro { .. } = file_source.as_embedding_kind() && let AnyJsIdentifierBinding::TsIdentifierBinding(binding) = binding && let Some(decl) = binding.parent::<TsInterfaceDeclaration>() - && let Some(_) = decl.parent::<JsModuleItemList>() + && decl.parent::<JsModuleItemList>().is_some() {
Merging this PR will not alter performance
Comparing Footnotes
|
71a36f2 to
bb0712d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)
302-365: Housekeeping: regen rule metadata and run format/lint.
Please confirmjust gen-rules+just gen-configuration(rule change in *_analyze) andjust f+just lbefore merge. As per coding guidelines, “Runjust gen-rulesandjust gen-configurationbefore opening a PR when implementing changes to lint rules in*_analyzedirectories” and “Always runjust f(code formatting) andjust l(linting) before committing code.”
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)
337-365: Reminder: Pre-PR commandsAs per the coding guidelines, please ensure you've run
just gen-rules,just gen-configuration,just f, andjust lbefore finalising. (You likely have, but just checking!)
5cc133f to
c65878b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.changeset/smooth-tips-fry.md:
- Around line 1-5: The changeset contains a typo in the rule name: replace the
incorrect "noUnusedVariable" with the correct rule identifier
"noUnusedVariables" in the changeset text so the rule name matches the docs and
rule identifier; update the string in .changeset/smooth-tips-fry.md wherever
"noUnusedVariable" appears to "noUnusedVariables".
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary
Fixes #9080
Propsinterface declarations at the top-level of Astro files are used to add typing to props and it's read by the framework implicitly. This pull request adds an exception to thenoUnusedVariableto ignore that case.Test Plan
Added snapshot tests.
Docs
Added description for the exception to the rule doc.