Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@omasakun
Copy link
Contributor

@omasakun omasakun commented Aug 5, 2025

Summary

This PR fixes #7101

  1. If a class member defined in a constructor argument is only used within the constructor, remove the private modifier and make it a plain method argument.
  2. If it is not used within the constructor, prefix it with an underscore, as with no_unused_function_parameter.

Note:
Previously, unused class members defined as constructor arguments were completely removed from the constructor arguments. However, this changed the constructor signature and was inconsistent with the behavior of no_unused_function_parameter.

As a side effect of this bug fix, the constructor signature is no longer changed, which has caused some existing tests to produce different results. (check changed files)

Test Plan

New test file has been added.

@changeset-bot
Copy link

changeset-bot bot commented Aug 5, 2025

🦋 Changeset detected

Latest commit: 74d4c62

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 Aug 5, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 5, 2025

CodSpeed Performance Report

Merging #7102 will not alter performance

Comparing omasakun:fix/7101 (1d87c8a) with main (80515ec)

Summary

✅ 128 untouched benchmarks

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

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

Nice work!

I think one of the diagnostics should be tweaked, but looks good otherwise! Do you want to add a changeset too?


#[derive(Debug, Clone)]
pub enum UnusedMemberAction {
Remove(AnyMember),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe RemoveMember(AnyMember)? Calling it only Remove doesn't clarify how it differs from RemovePrivateModifier.

Comment on lines 257 to 263
if let Ok(AnyJsFormalParameter::JsFormalParameter(param)) = ts_property_param.formal_parameter()
{
if let Ok(binding) = param.binding() {
if let Some(identifier_binding) = binding
.as_any_js_binding()
.and_then(|b| b.as_js_identifier_binding())
{
Copy link
Contributor

Choose a reason for hiding this comment

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

This would benefit from let chaining:

Suggested change
if let Ok(AnyJsFormalParameter::JsFormalParameter(param)) = ts_property_param.formal_parameter()
{
if let Ok(binding) = param.binding() {
if let Some(identifier_binding) = binding
.as_any_js_binding()
.and_then(|b| b.as_js_identifier_binding())
{
if let Ok(AnyJsFormalParameter::JsFormalParameter(param)) = ts_property_param.formal_parameter()
&& let Ok(binding) = param.binding()
&& let Some(identifier_binding) = binding
.as_any_js_binding()
.and_then(|b| b.as_js_identifier_binding())
{

```
invalid_issue_7101.ts:9:23 lint/correctness/noUnusedPrivateClassMembers FIXABLE ━━━━━━━━━━━━━━━━━━
! This private class member is defined but never used.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the diagnostic is not correct here. It should be something such as "This argument is never used outside of the constructor."

@github-actions github-actions bot added the A-LSP Area: language server protocol label Aug 5, 2025
@omasakun
Copy link
Contributor Author

omasakun commented Aug 5, 2025

This PR changed the order of diagnostics output, probably because the rule now requires Semantic<JsClassDeclaration> instead of Ast<JsClassMemberList>.
This caused the test for server::tests::pull_diagnostics_of_syntax_rules in biome_lsp to fail, so I fixed the test code.

@arendjr arendjr merged commit d3118c6 into biomejs:main Aug 5, 2025
29 checks passed
@github-actions github-actions bot mentioned this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-LSP Area: language server protocol L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Panic Malformed list, node expected but found token... in biome_rowan/src/ast/mod.rs

2 participants