Conversation
🦋 Changeset detectedLatest commit: 76e94e3 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 |
db3e74a to
0408706
Compare
0408706 to
3551362
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
1248d3a to
3e5b87d
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (3)
WalkthroughThis pull request adds support for migrating ESLint's Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (17)
.opencode/package-lock.jsonis excluded by!**/package-lock.jsonand included by**crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rsis excluded by!**/migrate/eslint_any_rule_to_biome.rsand included by**crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_eslintrcjson_class_methods_use_this_options.snapis excluded by!**/*.snapand included by**crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_configuration/src/generated/linter_options_check.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidClassFields.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidExceptMethods.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidIgnoreClassesWithImplementsPublicFields.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/valid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validClassFields.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreClassesWithImplementsAll.ts.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreOverrideMethods.ts.snapis excluded by!**/*.snapand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (20)
.changeset/rich-cases-cheat.mdcrates/biome_cli/src/execute/migrate/eslint_eslint.rscrates/biome_cli/src/execute/migrate/eslint_to_biome.rscrates/biome_cli/tests/commands/migrate_eslint.rscrates/biome_js_analyze/src/lint/nursery/use_this_for_class_methods.rscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.jscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalid.tscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidClassFields.tscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidExceptMethods.jscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidExceptMethods.options.jsoncrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidIgnoreClassesWithImplementsPublicFields.options.jsoncrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/invalidIgnoreClassesWithImplementsPublicFields.tscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/valid.jscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validClassFields.tscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreClassesWithImplementsAll.options.jsoncrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreClassesWithImplementsAll.tscrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreOverrideMethods.options.jsoncrates/biome_js_analyze/tests/specs/nursery/useThisForClassMethods/validIgnoreOverrideMethods.tscrates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/use_this_for_class_methods.rs
| #[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) |
There was a problem hiding this comment.
🧩 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:
- 1: https://eslint.org/docs/latest/rules/class-methods-use-this
- 2: https://archive.eslint.org/docs/rules/class-methods-use-this
🏁 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/migrateRepository: 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
left a comment
There was a problem hiding this comment.
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.
3e5b87d to
76e94e3
Compare
Summary
This PR adds
useThisForClassMethodswhich is a port of https://eslint.org/docs/latest/rules/class-methods-use-thisI 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