Skip to content

feat(lint/js): add useThisForClassMethods#9807

Merged
dyc3 merged 1 commit into
mainfrom
dyc3/useThisForClassMethods
May 5, 2026
Merged

feat(lint/js): add useThisForClassMethods#9807
dyc3 merged 1 commit into
mainfrom
dyc3/useThisForClassMethods

Conversation

@dyc3

@dyc3 dyc3 commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds useThisForClassMethods which is a port of https://eslint.org/docs/latest/rules/class-methods-use-this

I chose to implement these options because they're pretty trivial, and they are useful escape hatches.

Generated by gpt 5.4

Test Plan

snapshots

Docs

@changeset-bot

changeset-bot Bot commented Apr 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3060f4f

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

@dyc3 dyc3 force-pushed the dyc3/useThisForClassMethods branch from db3e74a to 0408706 Compare April 5, 2026 15:56
@github-actions github-actions Bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Apr 5, 2026
@dyc3 dyc3 force-pushed the dyc3/useThisForClassMethods branch from 0408706 to 3551362 Compare April 5, 2026 15:59
@codspeed-hq

codspeed-hq Bot commented Apr 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 59 untouched benchmarks
⏩ 195 skipped benchmarks1


Comparing dyc3/useThisForClassMethods (3060f4f) with main (b565bed)

Open in CodSpeed

Footnotes

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

@dyc3 dyc3 force-pushed the dyc3/useThisForClassMethods branch from 1248d3a to 3e5b87d Compare April 5, 2026 16:36
@dyc3 dyc3 marked this pull request as ready for review April 5, 2026 19:37
@dyc3 dyc3 requested review from a team April 5, 2026 19:37
@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a new nursery lint rule useThisInClassMethods and its Biome rule options, implements ESLint deserialization and migration for class-methods-use-this (including mapping of exceptMethods, ignoreOverrideMethods, ignoreClassesWithImplements, and ignoring enforceForClassFields), wires migration to emit the nursery rule with severity and options, exposes the rule options module, adds tests for migration and rule behaviour, and adds a changeset entry.

Possibly related PRs

  • biomejs/biome#9836 — Adds ESLint→Biome migration helpers and test infrastructure used by new rule migrations.
  • biomejs/biome#10118 — Modifies parts of the ESLint→Biome migration pipeline that overlap with adding new rule mappings.

Suggested reviewers

  • ematipico
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title references 'useThisForClassMethods', but the changeset and implementation consistently use 'useThisInClassMethods'. This is a naming mismatch. Correct the PR title to 'feat(lint/js): add useThisInClassMethods' to match the actual rule name implemented throughout the codebase.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the motivation (porting ESLint's class-methods-use-this rule), mentions options chosen, and includes AI disclosure as required.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dyc3/useThisForClassMethods

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/biome_cli/src/execute/migrate/eslint_eslint.rs`:
- Around line 625-648: The code in
ClassMethodsUseThisOptions::into_biome_options currently ignores the
enforce_for_class_fields field (the let _ = self.enforce_for_class_fields;)
which silently tightens behaviour; update into_biome_options to handle
enforce_for_class_fields: if
biome_rule_options::use_this_for_class_methods::UseThisForClassMethodsOptions
supports an equivalent toggle, map self.enforce_for_class_fields into the
options (e.g., set a matching field or invert as needed), otherwise emit a
migration diagnostic/warning when enforce_for_class_fields is present (false) so
users are informed of the behavioural change; locate ClassMethodsUseThisOptions,
the enforce_for_class_fields field and the into_biome_options function and
either add mapping into
biome_rule_options::use_this_for_class_methods::UseThisForClassMethodsOptions or
add a diagnostic emission path when that field is Some(false).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15b1a5b1-206b-480c-8dc5-2ae3b92c43d1

📥 Commits

Reviewing files that changed from the base of the PR and between 1d09f0f and 3e5b87d.

⛔ Files ignored due to path filters (17)
  • .opencode/package-lock.json is excluded by !**/package-lock.json and included by **
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_eslintrcjson_class_methods_use_this_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_configuration/src/generated/linter_options_check.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidClassFields.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidExceptMethods.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidIgnoreClassesWithImplementsPublicFields.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validClassFields.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreClassesWithImplementsAll.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreOverrideMethods.ts.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (20)
  • .changeset/rich-cases-cheat.md
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_cli/src/execute/migrate/eslint_to_biome.rs
  • crates/biome_cli/tests/commands/migrate_eslint.rs
  • crates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rs
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidClassFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidExceptMethods.js
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidExceptMethods.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidIgnoreClassesWithImplementsPublicFields.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidIgnoreClassesWithImplementsPublicFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validClassFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreClassesWithImplementsAll.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreClassesWithImplementsAll.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreOverrideMethods.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreOverrideMethods.ts
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_this_for_class_methods.rs

Comment on lines +625 to +648
#[deserializable(rename = "enforceForClassFields")]
enforce_for_class_fields: Option<bool>,
#[deserializable(rename = "ignoreOverrideMethods")]
ignore_override_methods: Option<bool>,
#[deserializable(rename = "ignoreClassesWithImplements")]
ignore_classes_with_implements: Option<EslintIgnoreClassesWithImplements>,
}
impl ClassMethodsUseThisOptions {
pub(crate) fn into_biome_options(
self,
) -> Option<biome_rule_options::use_this_for_class_methods::UseThisForClassMethodsOptions> {
let options =
biome_rule_options::use_this_for_class_methods::UseThisForClassMethodsOptions {
except_methods: (!self.except_methods.is_empty()).then_some(self.except_methods),
ignore_override_methods: self.ignore_override_methods,
ignore_classes_with_implements: self.ignore_classes_with_implements.map(Into::into),
};

let _ = self.enforce_for_class_fields;

(options.except_methods.is_some()
|| options.ignore_override_methods.is_some()
|| options.ignore_classes_with_implements.is_some())
.then_some(options)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In ESLint's class-methods-use-thisrule, what doesenforceForClassFieldsdo, what is its default, and what behaviour changes when it is set tofalse?

💡 Result:

The enforceForClassFields option in ESLint's class-methods-use-this rule enforces that arrow functions and function expressions used as instance field initializers (class fields) utilize this. It also applies to auto-accessor fields declared with the accessor keyword. Its default value is true. When set to false, the rule does not check class fields for this usage, allowing functions in class field initializers that do not reference this without flagging them as violations. With the default true, such fields are flagged unless this is used.

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check where the option is parsed, dropped, or asserted in migration/tests.
rg -n -C3 '\benforceForClassFields\b|\benforce_for_class_fields\b|class-methods-use-this|useThisForClassMethods' \
  crates/biome_cli/src/execute/migrate \
  crates/biome_cli/tests \
  crates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rs \
  crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods

# Check whether migration currently emits diagnostics/warnings for unsupported option semantics.
rg -n -C3 'unsupported|not supported|cannot migrate|warning|diagnostic' crates/biome_cli/src/execute/migrate

Repository: biomejs/biome

Length of output: 50371


Silently dropping enforceForClassFields changes rule behaviour.

When a user sets enforceForClassFields: false in ESLint (disabling class field checks), the migration discards this option without warning. Biome's useThisForClassMethods always checks class fields, so users unknowingly get stricter enforcement post-migration—behaviour tightening disguised as migration.

Line 643 silently discards the value. Consider either:

  • Emitting a diagnostic informing users of the behaviour change
  • Mapping the option (if Biome's rule supports runtime disabling)

Check whether Biome's rule can support a similar toggle.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_cli/src/execute/migrate/eslint_eslint.rs` around lines 625 -
648, The code in ClassMethodsUseThisOptions::into_biome_options currently
ignores the enforce_for_class_fields field (the let _ =
self.enforce_for_class_fields;) which silently tightens behaviour; update
into_biome_options to handle enforce_for_class_fields: if
biome_rule_options::use_this_for_class_methods::UseThisForClassMethodsOptions
supports an equivalent toggle, map self.enforce_for_class_fields into the
options (e.g., set a matching field or invert as needed), otherwise emit a
migration diagnostic/warning when enforce_for_class_fields is present (false) so
users are informed of the behavioural change; locate ClassMethodsUseThisOptions,
the enforce_for_class_fields field and the into_biome_options function and
either add mapping into
biome_rule_options::use_this_for_class_methods::UseThisForClassMethodsOptions or
add a diagnostic emission path when that field is Some(false).

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am a bit biased against this rule (their semantics and name), let me know what you think about the suggestion I gave.

Apart from that, the docs need more work, and code can be improved.

Comment thread .changeset/rich-cases-cheat.md Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rs Outdated
Comment thread crates/biome_rule_options/src/use_this_for_class_methods.rs Outdated
Comment thread .opencode/package-lock.json Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rs Outdated
@dyc3 dyc3 force-pushed the dyc3/useThisForClassMethods branch from 3e5b87d to 76e94e3 Compare April 18, 2026 17:07
@dyc3 dyc3 requested a review from ematipico April 18, 2026 17:07
"@biomejs/biome": patch
---

Added the new nursery rule [`useThisInClassMethods`](https://biomejs.dev/linter/rules/use-this-in-class-methods/), based on ESLint's `class-methods-use-this`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Should we mention the eslint port here? We usually don't

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maybe we should, i don't really have strong feelings about it

@dyc3 dyc3 force-pushed the dyc3/useThisForClassMethods branch from 76e94e3 to 3b4a16f Compare May 4, 2026 21:49
@dyc3 dyc3 force-pushed the dyc3/useThisForClassMethods branch from 3b4a16f to 3060f4f Compare May 5, 2026 13:17

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/biome_js_analyze/src/lint/nursery/use_this_in_class_methods.rs`:
- Around line 520-534: The matcher in uses_lexical_this_in_property_initializer
currently only handles bare arrow/function expressions; update it to peel off
any outer parenthesized expressions from the property's initializer before
attempting to match as an arrow or function (i.e., normalize initializer by
unwrapping ParenthesizedExpression nodes until you hit the inner expression),
then proceed with the existing arrow/function extraction logic on that unwrapped
node; also add a unit snapshot test covering a parenthesised callable field
initializer such as field = (() => this.value) or field = (function () { return
this.value; }) to ensure the new behavior is exercised.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 73559c5d-0d93-4f99-b176-0517036cf8a1

📥 Commits

Reviewing files that changed from the base of the PR and between 3b4a16f and 3060f4f.

⛔ Files ignored due to path filters (16)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_eslintrcjson_class_methods_use_this_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_configuration/src/generated/linter_options_check.rs is excluded by !**/generated/**, !**/generated/** and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalid.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidClassFields.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreClassesWithImplementsPublicFields.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreMethods.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validClassFields.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreClassesWithImplementsAll.ts.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreOverrideMethods.ts.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing (21)
  • .changeset/rich-cases-cheat.md
  • .claude/skills/lint-rule-development/SKILL.md
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_cli/src/execute/migrate/eslint_to_biome.rs
  • crates/biome_cli/tests/commands/migrate_eslint.rs
  • crates/biome_js_analyze/src/lint/nursery/use_this_in_class_methods.rs
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalid.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidClassFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreClassesWithImplementsPublicFields.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreClassesWithImplementsPublicFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreMethods.js
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreMethods.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validClassFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreClassesWithImplementsAll.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreClassesWithImplementsAll.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreOverrideMethods.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreOverrideMethods.ts
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_this_in_class_methods.rs
✅ Files skipped from review due to trivial changes (13)
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreOverrideMethods.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreClassesWithImplementsAll.options.json
  • .changeset/rich-cases-cheat.md
  • .claude/skills/lint-rule-development/SKILL.md
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreMethods.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreClassesWithImplementsPublicFields.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validIgnoreOverrideMethods.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalid.ts
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/validClassFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidClassFields.ts
  • crates/biome_js_analyze/tests/specs/nursery/useThisInClassMethods/invalidIgnoreClassesWithImplementsPublicFields.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/biome_cli/src/execute/migrate/eslint_to_biome.rs
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs

Comment on lines +520 to +534
fn uses_lexical_this_in_property_initializer(member: &JsPropertyClassMember) -> Option<bool> {
let initializer = member.value()?.expression().ok()?;
let root = if let Some(arrow) = initializer.as_js_arrow_function_expression() {
let body = arrow.body().ok()?;
match body {
AnyJsFunctionBody::AnyJsExpression(expression) => expression.into_syntax(),
AnyJsFunctionBody::JsFunctionBody(body) => body.into_syntax(),
}
} else {
initializer
.as_js_function_expression()?
.body()
.ok()?
.into_syntax()
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Unwrap parenthesised callable field initialisers.

This only recognises bare () => {} / function () {} values. field = (() => this.value) and field = (function () { return this.value; }) currently fall through to None, so the rule skips those members entirely. Please normalise away outer parentheses before matching here, and add a snapshot for one of these forms.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/biome_js_analyze/src/lint/nursery/use_this_in_class_methods.rs` around
lines 520 - 534, The matcher in uses_lexical_this_in_property_initializer
currently only handles bare arrow/function expressions; update it to peel off
any outer parenthesized expressions from the property's initializer before
attempting to match as an arrow or function (i.e., normalize initializer by
unwrapping ParenthesizedExpression nodes until you hit the inner expression),
then proceed with the existing arrow/function extraction logic on that unwrapped
node; also add a unit snapshot test covering a parenthesised callable field
initializer such as field = (() => this.value) or field = (function () { return
this.value; }) to ensure the new behavior is exercised.

@dyc3 dyc3 merged commit 0ae5840 into main May 5, 2026
30 of 31 checks passed
@dyc3 dyc3 deleted the dyc3/useThisForClassMethods branch May 5, 2026 14:09
@github-actions github-actions Bot mentioned this pull request May 5, 2026
OIRNOIR pushed a commit to OIRNOIR/YouTube-Helper-Server that referenced this pull request May 12, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@biomejs/biome](https://biomejs.dev) ([source](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome)) | imports | patch | [`2.4.14` -> `2.4.15`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/2.4.14/2.4.15) |

---

### Release Notes

<details>
<summary>biomejs/biome (@&#8203;biomejs/biome)</summary>

### [`v2.4.15`](https://github.com/biomejs/biome/blob/HEAD/packages/@&#8203;biomejs/biome/CHANGELOG.md#2415)

[Compare Source](https://github.com/biomejs/biome/compare/@biomejs/biome@2.4.14...@biomejs/biome@2.4.15)

##### Patch Changes

- [#&#8203;9394](biomejs/biome#9394) [`ba3480e`](biomejs/biome@ba3480e) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the nursery rule [`useTestHooksInOrder`](https://biomejs.dev/linter/rules/use-test-hooks-in-order) in the `test` domain. The rule enforces that Jest/Vitest lifecycle hooks (`beforeAll`, `beforeEach`, `afterEach`, `afterAll`) are declared in the order they execute, making test setup and teardown easier to reason about.

- [#&#8203;10254](biomejs/biome#10254) [`e0a54cc`](biomejs/biome@e0a54cc) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added a new nursery rule [`useVueNextTickPromise`](https://biomejs.dev/linter/rules/use-vue-next-tick-promise/), which enforces Promise syntax when using Vue `nextTick`.

  For example, the following snippet triggers the rule:

  ```js
  import { nextTick } from "vue";

  nextTick(() => {
    updateDom();
  });
  ```

- [#&#8203;10219](biomejs/biome#10219) [`64aee45`](biomejs/biome@64aee45) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added a new nursery rule [`noVueVOnNumberValues`](https://biomejs.dev/linter/rules/no-vue-v-on-number-values/), that disallows deprecated number modifiers on Vue `v-on` directives.

  For example, the following snippet triggers the rule:

  ```vue
  <input @&#8203;keyup.13="submit" />
  ```

- [#&#8203;10195](biomejs/biome#10195) [`7b8d4e1`](biomejs/biome@7b8d4e1) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the new nursery rule [`useVueValidVFor`](https://biomejs.dev/linter/rules/use-vue-valid-v-for/), which validates Vue `v-for` directives and reports invalid aliases, missing component keys, and keys that do not use iteration variables.

- [#&#8203;10238](biomejs/biome#10238) [`1110256`](biomejs/biome@1110256) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the recommended nursery rule [`noVueImportCompilerMacros`](https://biomejs.dev/linter/rules/no-vue-import-compiler-macros/), which disallows importing Vue compiler macros such as `defineProps` from `vue` because they are automatically available.

- [#&#8203;10201](biomejs/biome#10201) [`1a08f89`](biomejs/biome@1a08f89) Thanks [@&#8203;realknove](https://github.com/realknove)! - Fixed [#&#8203;10193](biomejs/biome#10193): `style/useReadonlyClassProperties` no longer reports class properties as readonly-able when they are assigned inside arrow callbacks nested in class property initializers.

- [#&#8203;9574](biomejs/biome#9574) [`3bd2b6a`](biomejs/biome@3bd2b6a) Thanks [@&#8203;Conaclos](https://github.com/Conaclos)! - Fixed [#&#8203;9530](biomejs/biome#9530). The diagnostics of [`organizeImports`](https://biomejs.dev/assist/actions/organize-imports/) are now more detailed and more precise. They are also better at localizing where the issue is.

- [#&#8203;10205](biomejs/biome#10205) [`a704a6c`](biomejs/biome@a704a6c) Thanks [@&#8203;Conaclos](https://github.com/Conaclos)! - Fixed [#&#8203;10185](biomejs/biome#10185). [\`organizeImports](https://biomejs.dev/assist/actions/organize-imports/) now errors when it encounters an unknown predefined group.

  The following configuration is now reported as invalid because `:INEXISTENT:` is an unknown predefined group.

  ```json
  {
    "assist": {
      "actions": {
        "source": {
          "organizeImports": { "options": { "groups": [":INEXISTENT:"] } }
        }
      }
    }
  }
  ```

- [#&#8203;10052](biomejs/biome#10052) [`b565bed`](biomejs/biome@b565bed) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - Improved [`noMisleadingReturnType`](https://biomejs.dev/linter/rules/no-misleading-return-type/): it now flags union annotations whose extra variants are never returned, and suggests the narrower type (e.g. `string | null` → `string`).

  These functions are now reported because `null` and `number` are included in the return annotations but never returned:

  ```ts
  function getUser(): string | null {
    return "hello";
  } // null is never returned
  function getCode(): string | number {
    return "hello";
  } // number is never returned
  ```

- [#&#8203;10213](biomejs/biome#10213) [`ac30057`](biomejs/biome@ac30057) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Fixed [#&#8203;9450](biomejs/biome#9450): HTML and Vue element formatting now preserves child line breaks when an element contains another element child on its own line, instead of collapsing the child element onto the same line.

- [#&#8203;10275](biomejs/biome#10275) [`9ee6c03`](biomejs/biome@9ee6c03) Thanks [@&#8203;solithcy](https://github.com/solithcy)! - Fixed [#&#8203;10274](biomejs/biome#10274): Svelte templates with missing expressions no longer parsed as `HtmlBogusElement`

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`noMisleadingReturnType`](https://biomejs.dev/linter/rules/no-misleading-return-type/) now detects misleading return type annotations when object literal properties are initialized with `as const`.

  This function is now reported because the return annotation widens a property initialized with `as const`:

  ```ts
  function f(): { value: string } {
    return { value: "text" as const };
  }
  ```

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`noUselessTypeConversion`](https://biomejs.dev/linter/rules/no-useless-type-conversion/) now detects redundant conversions on object literal properties initialized with `as const`.

  This conversion is now reported because `message.value` is inferred as a string literal:

  ```ts
  const message = { value: "text" as const };
  String(message.value);
  ```

- [#&#8203;9807](biomejs/biome#9807) [`0ae5840`](biomejs/biome@0ae5840) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the new nursery rule [`useThisInClassMethods`](https://biomejs.dev/linter/rules/use-this-in-class-methods/), based on ESLint's `class-methods-use-this`.

  The rule now reports instance methods, getters, setters, and function-valued instance fields that do not use `this`, and `biome migrate eslint` preserves the supported `ignoreMethods`, `ignoreOverrideMethods`, and `ignoreClassesWithImplements` options.

  **Invalid**:

  ```js
  class Foo {
    bar() {
      // does not use `this`, invalid
      console.log("Hello Biome");
    }
  }
  ```

- [#&#8203;10258](biomejs/biome#10258) [`e7b18f7`](biomejs/biome@e7b18f7) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Improved linter performance by narrowing the query nodes for several lint rules, reducing how often they are evaluated.

- [#&#8203;10273](biomejs/biome#10273) [`04e22a1`](biomejs/biome@04e22a1) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Fixed [#&#8203;10271](biomejs/biome#10271): The HTML parser now correctly parses `of` as text content when in text contexts.

- [#&#8203;9838](biomejs/biome#9838) [`83f7385`](biomejs/biome@83f7385) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the nursery rule [`noBaseToString`](https://biomejs.dev/linter/rules/no-base-to-string/), which reports stringification sites that fall back to Object's default `"[object Object]"` formatting. The rule also supports the `ignoredTypeNames` option.

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`useExhaustiveSwitchCases`](https://biomejs.dev/linter/rules/use-exhaustive-switch-cases/) now checks switch statements over object literal properties initialized with `as const`.

  This switch is now reported because `status.kind` is inferred as the string literal `"ready"` but no case handles it:

  ```ts
  const status = { kind: "ready" as const };
  switch (status.kind) {
  }
  ```

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`useStringStartsEndsWith`](https://biomejs.dev/linter/rules/use-string-starts-ends-with/) now detects string index comparisons on object literal properties initialized with `as const`.

  This comparison is now reported because `message.value` is inferred as a string literal:

  ```ts
  const message = { value: "hello" as const };
  message.value[0] === "h";
  ```

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzMuMyIsInVwZGF0ZWRJblZlciI6IjQzLjE3My4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Server/pulls/12
OIRNOIR pushed a commit to OIRNOIR/YouTube-Helper-Client that referenced this pull request May 13, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@biomejs/biome](https://biomejs.dev) ([source](https://github.com/biomejs/biome/tree/HEAD/packages/@biomejs/biome)) | imports | patch | [`2.4.14` -> `2.4.15`](https://renovatebot.com/diffs/npm/@biomejs%2fbiome/2.4.14/2.4.15) |

---

### Release Notes

<details>
<summary>biomejs/biome (@&#8203;biomejs/biome)</summary>

### [`v2.4.15`](https://github.com/biomejs/biome/blob/HEAD/packages/@&#8203;biomejs/biome/CHANGELOG.md#2415)

[Compare Source](https://github.com/biomejs/biome/compare/@biomejs/biome@2.4.14...@biomejs/biome@2.4.15)

##### Patch Changes

- [#&#8203;9394](biomejs/biome#9394) [`ba3480e`](biomejs/biome@ba3480e) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the nursery rule [`useTestHooksInOrder`](https://biomejs.dev/linter/rules/use-test-hooks-in-order) in the `test` domain. The rule enforces that Jest/Vitest lifecycle hooks (`beforeAll`, `beforeEach`, `afterEach`, `afterAll`) are declared in the order they execute, making test setup and teardown easier to reason about.

- [#&#8203;10254](biomejs/biome#10254) [`e0a54cc`](biomejs/biome@e0a54cc) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added a new nursery rule [`useVueNextTickPromise`](https://biomejs.dev/linter/rules/use-vue-next-tick-promise/), which enforces Promise syntax when using Vue `nextTick`.

  For example, the following snippet triggers the rule:

  ```js
  import { nextTick } from "vue";

  nextTick(() => {
    updateDom();
  });
  ```

- [#&#8203;10219](biomejs/biome#10219) [`64aee45`](biomejs/biome@64aee45) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added a new nursery rule [`noVueVOnNumberValues`](https://biomejs.dev/linter/rules/no-vue-v-on-number-values/), that disallows deprecated number modifiers on Vue `v-on` directives.

  For example, the following snippet triggers the rule:

  ```vue
  <input @&#8203;keyup.13="submit" />
  ```

- [#&#8203;10195](biomejs/biome#10195) [`7b8d4e1`](biomejs/biome@7b8d4e1) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the new nursery rule [`useVueValidVFor`](https://biomejs.dev/linter/rules/use-vue-valid-v-for/), which validates Vue `v-for` directives and reports invalid aliases, missing component keys, and keys that do not use iteration variables.

- [#&#8203;10238](biomejs/biome#10238) [`1110256`](biomejs/biome@1110256) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the recommended nursery rule [`noVueImportCompilerMacros`](https://biomejs.dev/linter/rules/no-vue-import-compiler-macros/), which disallows importing Vue compiler macros such as `defineProps` from `vue` because they are automatically available.

- [#&#8203;10201](biomejs/biome#10201) [`1a08f89`](biomejs/biome@1a08f89) Thanks [@&#8203;realknove](https://github.com/realknove)! - Fixed [#&#8203;10193](biomejs/biome#10193): `style/useReadonlyClassProperties` no longer reports class properties as readonly-able when they are assigned inside arrow callbacks nested in class property initializers.

- [#&#8203;9574](biomejs/biome#9574) [`3bd2b6a`](biomejs/biome@3bd2b6a) Thanks [@&#8203;Conaclos](https://github.com/Conaclos)! - Fixed [#&#8203;9530](biomejs/biome#9530). The diagnostics of [`organizeImports`](https://biomejs.dev/assist/actions/organize-imports/) are now more detailed and more precise. They are also better at localizing where the issue is.

- [#&#8203;10205](biomejs/biome#10205) [`a704a6c`](biomejs/biome@a704a6c) Thanks [@&#8203;Conaclos](https://github.com/Conaclos)! - Fixed [#&#8203;10185](biomejs/biome#10185). [\`organizeImports](https://biomejs.dev/assist/actions/organize-imports/) now errors when it encounters an unknown predefined group.

  The following configuration is now reported as invalid because `:INEXISTENT:` is an unknown predefined group.

  ```json
  {
    "assist": {
      "actions": {
        "source": {
          "organizeImports": { "options": { "groups": [":INEXISTENT:"] } }
        }
      }
    }
  }
  ```

- [#&#8203;10052](biomejs/biome#10052) [`b565bed`](biomejs/biome@b565bed) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - Improved [`noMisleadingReturnType`](https://biomejs.dev/linter/rules/no-misleading-return-type/): it now flags union annotations whose extra variants are never returned, and suggests the narrower type (e.g. `string | null` → `string`).

  These functions are now reported because `null` and `number` are included in the return annotations but never returned:

  ```ts
  function getUser(): string | null {
    return "hello";
  } // null is never returned
  function getCode(): string | number {
    return "hello";
  } // number is never returned
  ```

- [#&#8203;10213](biomejs/biome#10213) [`ac30057`](biomejs/biome@ac30057) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Fixed [#&#8203;9450](biomejs/biome#9450): HTML and Vue element formatting now preserves child line breaks when an element contains another element child on its own line, instead of collapsing the child element onto the same line.

- [#&#8203;10275](biomejs/biome#10275) [`9ee6c03`](biomejs/biome@9ee6c03) Thanks [@&#8203;solithcy](https://github.com/solithcy)! - Fixed [#&#8203;10274](biomejs/biome#10274): Svelte templates with missing expressions no longer parsed as `HtmlBogusElement`

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`noMisleadingReturnType`](https://biomejs.dev/linter/rules/no-misleading-return-type/) now detects misleading return type annotations when object literal properties are initialized with `as const`.

  This function is now reported because the return annotation widens a property initialized with `as const`:

  ```ts
  function f(): { value: string } {
    return { value: "text" as const };
  }
  ```

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`noUselessTypeConversion`](https://biomejs.dev/linter/rules/no-useless-type-conversion/) now detects redundant conversions on object literal properties initialized with `as const`.

  This conversion is now reported because `message.value` is inferred as a string literal:

  ```ts
  const message = { value: "text" as const };
  String(message.value);
  ```

- [#&#8203;9807](biomejs/biome#9807) [`0ae5840`](biomejs/biome@0ae5840) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the new nursery rule [`useThisInClassMethods`](https://biomejs.dev/linter/rules/use-this-in-class-methods/), based on ESLint's `class-methods-use-this`.

  The rule now reports instance methods, getters, setters, and function-valued instance fields that do not use `this`, and `biome migrate eslint` preserves the supported `ignoreMethods`, `ignoreOverrideMethods`, and `ignoreClassesWithImplements` options.

  **Invalid**:

  ```js
  class Foo {
    bar() {
      // does not use `this`, invalid
      console.log("Hello Biome");
    }
  }
  ```

- [#&#8203;10258](biomejs/biome#10258) [`e7b18f7`](biomejs/biome@e7b18f7) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Improved linter performance by narrowing the query nodes for several lint rules, reducing how often they are evaluated.

- [#&#8203;10273](biomejs/biome#10273) [`04e22a1`](biomejs/biome@04e22a1) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Fixed [#&#8203;10271](biomejs/biome#10271): The HTML parser now correctly parses `of` as text content when in text contexts.

- [#&#8203;9838](biomejs/biome#9838) [`83f7385`](biomejs/biome@83f7385) Thanks [@&#8203;dyc3](https://github.com/dyc3)! - Added the nursery rule [`noBaseToString`](https://biomejs.dev/linter/rules/no-base-to-string/), which reports stringification sites that fall back to Object's default `"[object Object]"` formatting. The rule also supports the `ignoredTypeNames` option.

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`useExhaustiveSwitchCases`](https://biomejs.dev/linter/rules/use-exhaustive-switch-cases/) now checks switch statements over object literal properties initialized with `as const`.

  This switch is now reported because `status.kind` is inferred as the string literal `"ready"` but no case handles it:

  ```ts
  const status = { kind: "ready" as const };
  switch (status.kind) {
  }
  ```

- [#&#8203;10143](biomejs/biome#10143) [`56798a7`](biomejs/biome@56798a7) Thanks [@&#8203;minseong0324](https://github.com/minseong0324)! - [`useStringStartsEndsWith`](https://biomejs.dev/linter/rules/use-string-starts-ends-with/) now detects string index comparisons on object literal properties initialized with `as const`.

  This comparison is now reported because `message.value` is inferred as a string literal:

  ```ts
  const message = { value: "hello" as const };
  message.value[0] === "h";
  ```

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzMuMyIsInVwZGF0ZWRJblZlciI6IjQzLjE3My4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.oirnoir.dev/OIRNOIR/YouTube-Helper-Client/pulls/3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants