Skip to content

feat(lint/js): add useConsistentTestIt#9350

Merged
dyc3 merged 1 commit intomainfrom
dyc3/use-consistent-test-it
Apr 4, 2026
Merged

feat(lint/js): add useConsistentTestIt#9350
dyc3 merged 1 commit intomainfrom
dyc3/use-consistent-test-it

Conversation

@dyc3
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 commented Mar 5, 2026

Summary

I chose to implement both options from the source rule because it was less effort.

Planned and generated by sonnet 4.6

Test Plan

snapshots, also added cli tests for the custom migration

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: 2be306a

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-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Mar 5, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 5, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a new nursery lint rule useConsistentTestIt (implementation, state, diagnostics and safe auto-fixes) to enforce consistent use of it vs test with separate top-level and within-describe behaviour. Introduces public rule option types (UseConsistentTestItOptions, TestFunctionKind) and ESLint migration support mapping jest/consistent-test-it and vitest/consistent-test-it into Biome options. Adds migration translation module, CLI migration handling, and comprehensive tests/specs (valid/invalid cases, option variations, comment-trivia preservation) plus snapshots and CLI migrate tests. Also adds a changeset for a patch release.

Suggested reviewers

  • ematipico
  • Conaclos
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding a new lint rule useConsistentTestIt for JavaScript/Jest test consistency.
Description check ✅ Passed The description explains the motivation (implementing both options from the source rule), test coverage (snapshots and CLI tests), and discloses AI assistance (Sonnet 4.6).

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dyc3/use-consistent-test-it

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
crates/biome_cli/src/execute/migrate/eslint_to_biome.rs (1)

658-680: Avoid double-booking migration status for this branch.

migrate_eslint_any_rule(...) is already the central status recorder in adjacent branches; the extra results.add(...Migrated) creates avoidable coupling and can drift if helper behaviour changes.

♻️ Suggested simplification
         eslint_eslint::Rule::JestConsistentTestIt(conf) => {
             if migrate_eslint_any_rule(rules, &name, conf.severity(), opts, results) {
                 let severity = conf.severity();
                 let group = rules.nursery.get_or_insert_with(Default::default);
                 if let SeverityOrGroup::Group(group) = group {
                     let rule_options =
                         if let eslint_eslint::RuleConf::Option(_, rule_options) = conf {
                             rule_options.into()
                         } else {
                             eslint_jest::ConsistentTestItOptions::default().into()
                         };
                     group.use_consistent_test_it =
                         Some(biome_config::RuleFixConfiguration::WithOptions(
                             biome_config::RuleWithFixOptions {
                                 level: severity.into(),
                                 fix: None,
                                 options: rule_options,
                             },
                         ));
                 }
-                results.add(&name, RuleMigrationResult::Migrated);
             }
         }
🤖 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_to_biome.rs` around lines 658 -
680, The branch handling eslint_eslint::Rule::JestConsistentTestIt is
redundantly calling results.add(&name, RuleMigrationResult::Migrated) after
migrate_eslint_any_rule(...) already records migration status; remove that extra
results.add call so migrate_eslint_any_rule remains the single source of truth,
leaving the logic that sets group.use_consistent_test_it (using rules.nursery
and matching SeverityOrGroup::Group) and severity handling intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/add-use-consistent-test-it.md:
- Around line 1-5: The changeset currently bumps "@biomejs/biome" as "minor" for
the new nursery rule useConsistentTestIt; change the release type from "minor"
to "patch" in the changeset header so the new nursery rule targets main as per
project guidelines, leaving the rest of the changeset content (rule description
and link) intact.

In `@crates/biome_cli/src/execute/migrate/eslint_eslint.rs`:
- Around line 549-553: The migration currently maps both
"jest/consistent-test-it" and "vitest/consistent-test-it" into the same Rule
variant and name, so inserting into result (via
result.insert(Rule::JestConsistentTestIt(conf))) silently drops one entry;
change the migration to preserve both sources by either (A) deserializing into
distinct variants/names (e.g., introduce Rule::VitestConsistentTestIt and use
that for "vitest/..." so name() differs) or (B) detect an existing rule before
insert and merge RuleConf (use RuleConf::merge or implement a merge function)
then insert the merged config; apply the same fix to the analogous mappings at
the other locations you noted (lines handling "jest/..." vs "vitest/..." around
the other occurrences).

In `@crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs`:
- Around line 112-134: The match for computing rename_kind in the
use_consistent_test_it lint is missing the case for converting "fit" to
"it.only"; update the match arms inside the block that references
base_name.text(), required_kind, and callee (the match that assigns rename_kind)
to add ("fit", TestFunctionKind::It) => RenameKind::FitToItOnly so that when
required_kind == TestFunctionKind::It and base_name.text() == "fit" you return
the new RenameKind variant; ensure RenameKind includes FitToItOnly (or add it if
absent) and keep the existing fallback that checks base_name == "test" with
is_static_member_only(&callee).

---

Nitpick comments:
In `@crates/biome_cli/src/execute/migrate/eslint_to_biome.rs`:
- Around line 658-680: The branch handling
eslint_eslint::Rule::JestConsistentTestIt is redundantly calling
results.add(&name, RuleMigrationResult::Migrated) after
migrate_eslint_any_rule(...) already records migration status; remove that extra
results.add call so migrate_eslint_any_rule remains the single source of truth,
leaving the logic that sets group.use_consistent_test_it (using rules.nursery
and matching SeverityOrGroup::Group) and severity handling intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09b0abc4-3608-4df8-8597-d356c4cca81e

📥 Commits

Reviewing files that changed from the base of the PR and between 4509fc6 and e54360c.

⛔ Files ignored due to path filters (15)
  • 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_jest_consistent_test_it_no_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_jest_consistent_test_it_with_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_vitest_consistent_test_it_with_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/domain_selector.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/useConsistentTestIt/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js.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 (19)
  • .changeset/add-use-consistent-test-it.md
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_cli/src/execute/migrate/eslint_jest.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_consistent_test_it.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_consistent_test_it.rs

Comment thread .changeset/add-use-consistent-test-it.md Outdated
Comment thread crates/biome_cli/src/execute/migrate/eslint_eslint.rs
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 5, 2026

Merging this PR will not alter performance

✅ 58 untouched benchmarks
⏩ 156 skipped benchmarks1


Comparing dyc3/use-consistent-test-it (2be306a) with main (70c2d4e)

Open in CodSpeed

Footnotes

  1. 156 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/use-consistent-test-it branch from e54360c to 52851d5 Compare March 5, 2026 19:43
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 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_js_analyze/src/lint/nursery/use_consistent_test_it.rs`:
- Around line 114-138: The fallback TestOnlyToFit branch is unreachable because
the ("test", TestFunctionKind::It) match arm already catches "test" including
"test.only"; change the match to test for the static-member-only case first (or
add a guard) so "test.only" maps to RenameKind::TestOnlyToFit when required_kind
== TestFunctionKind::It and is_static_member_only(&callee) is true, otherwise
fall through to RenameKind::TestToIt; update the match on (base_name.text(),
required_kind) to check is_static_member_only(&callee) before returning TestToIt
(or remove the TestOnlyToFit variant and its fix function if you decide it's
dead code).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 723b97bd-d370-4558-8ce6-bc7005504267

📥 Commits

Reviewing files that changed from the base of the PR and between e54360c and 52851d5.

⛔ Files ignored due to path filters (15)
  • 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_jest_consistent_test_it_no_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_jest_consistent_test_it_with_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_vitest_consistent_test_it_with_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/domain_selector.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/useConsistentTestIt/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js.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/add-use-consistent-test-it.md
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_cli/src/execute/migrate/eslint_jest.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_consistent_test_it.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js.snap.new
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_consistent_test_it.rs
✅ Files skipped from review due to trivial changes (2)
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js.snap.new
  • .changeset/add-use-consistent-test-it.md
🚧 Files skipped from review as they are similar to previous changes (9)
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js
  • crates/biome_cli/src/execute/migrate/eslint_jest.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js
  • crates/biome_cli/src/execute/migrate/eslint_to_biome.rs
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json

Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs Outdated
@dyc3 dyc3 force-pushed the dyc3/use-consistent-test-it branch from 52851d5 to 535fbfc Compare March 5, 2026 20:07
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs (1)

114-138: ⚠️ Potential issue | 🟡 Minor

TestOnlyToFit branch remains unreachable.

The match arm at line 118 ("test", TestFunctionKind::It) => RenameKind::TestToIt catches all cases where the base identifier is "test", including test.only(...). The fallback condition at lines 128-137 can never be reached for test.only because it requires base_name.text() == "test" which is already matched above.

Current behaviour: test.only(...)it.only(...) via TestToIt

If the intent is to convert test.only(...)fit(...), restructure the match to check is_static_member_only first:

,

Proposed fix
         let rename_kind = match (base_name.text(), required_kind) {
             // `it` when `test` is required
             ("it", TestFunctionKind::Test) => RenameKind::ItToTest,
-            // `test` when `it` is required
-            ("test", TestFunctionKind::It) => RenameKind::TestToIt,
+            // `test.only` when `it` is required (becomes `fit`)
+            ("test", TestFunctionKind::It) if is_static_member_only(&callee) => {
+                RenameKind::TestOnlyToFit
+            }
+            // `test` when `it` is required (includes test.skip, test.concurrent, etc.)
+            ("test", TestFunctionKind::It) => RenameKind::TestToIt,
             // `xit` when `test` is required (becomes `xtest`)
             ("xit", TestFunctionKind::Test) => RenameKind::XitToXtest,
             // ... rest unchanged
-            _ => {
-                if required_kind == TestFunctionKind::It
-                    && base_name.text() == "test"
-                    && is_static_member_only(&callee)
-                {
-                    RenameKind::TestOnlyToFit
-                } else {
-                    return None;
-                }
-            }
+            _ => return None,
         };

Alternatively, if test.only → it.only is the intended behaviour, remove the dead TestOnlyToFit variant and fix_test_only_to_fit function entirely.

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

In `@crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs` around
lines 114 - 138, The match arm that maps ("test", TestFunctionKind::It) =>
RenameKind::TestToIt makes the fallback branch that returns
RenameKind::TestOnlyToFit unreachable for test.only cases; either (A) if you
want test.only -> fit, change the matching so you check
is_static_member_only(&callee) and handle the static-member-only case (use
RenameKind::TestOnlyToFit) before the plain ("test", TestFunctionKind::It) arm,
or (B) if test.only -> it.only is intended, remove the RenameKind::TestOnlyToFit
variant and delete the fix_test_only_to_fit helper and any code paths that
reference RenameKind::TestOnlyToFit so the match and callers only use
RenameKind::TestToIt for base_name.text() == "test".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs`:
- Around line 114-138: The match arm that maps ("test", TestFunctionKind::It) =>
RenameKind::TestToIt makes the fallback branch that returns
RenameKind::TestOnlyToFit unreachable for test.only cases; either (A) if you
want test.only -> fit, change the matching so you check
is_static_member_only(&callee) and handle the static-member-only case (use
RenameKind::TestOnlyToFit) before the plain ("test", TestFunctionKind::It) arm,
or (B) if test.only -> it.only is intended, remove the RenameKind::TestOnlyToFit
variant and delete the fix_test_only_to_fit helper and any code paths that
reference RenameKind::TestOnlyToFit so the match and callers only use
RenameKind::TestToIt for base_name.text() == "test".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ba9dbfce-1e58-4303-9239-abada3431d47

📥 Commits

Reviewing files that changed from the base of the PR and between 52851d5 and 535fbfc.

⛔ Files ignored due to path filters (15)
  • 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_jest_consistent_test_it_no_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_jest_consistent_test_it_with_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_vitest_consistent_test_it_with_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/domain_selector.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/useConsistentTestIt/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js.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/add-use-consistent-test-it.md
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_cli/src/execute/migrate/eslint_jest.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_consistent_test_it.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js.snap.new
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_consistent_test_it.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
🚧 Files skipped from review as they are similar to previous changes (10)
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js
  • crates/biome_cli/src/execute/migrate/eslint_to_biome.rs
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_rule_options/src/use_consistent_test_it.rs

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

The code is a bit naive; it can be improved. We could add some tests with trivia so we can verify they aren't lost after the code action is applied

Comment thread .changeset/add-use-consistent-test-it.md Outdated
Comment thread crates/biome_cli/src/execute/migrate/eslint_jest.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs Outdated
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs
@dyc3 dyc3 force-pushed the dyc3/use-consistent-test-it branch from 535fbfc to 7a6879e Compare March 6, 2026 18:52
@dyc3 dyc3 requested a review from ematipico March 6, 2026 18:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/biome_cli/tests/commands/migrate_eslint.rs (1)

790-874: Consider lint-roundtripping the optioned cases as well.

Line 775 already does this for the default-options test. Mirroring that in these two tests would harden the suite against option-serialisation breakage.

Suggested test hardening
 fn migrate_jest_consistent_test_it_with_options() {
@@
     assert!(result.is_ok(), "run_cli returned {result:?}");
+    let (fs, result) = run_cli(fs, &mut console, Args::from(["lint"].as_slice()));
+    assert!(result.is_ok(), "run_cli rerun returned {result:?}");
     assert_cli_snapshot(SnapshotPayload::new(
         module_path!(),
         "migrate_jest_consistent_test_it_with_options",
         fs,
         console,
         result,
     ));
 }

 fn migrate_vitest_consistent_test_it_with_options() {
@@
     assert!(result.is_ok(), "run_cli returned {result:?}");
+    let (fs, result) = run_cli(fs, &mut console, Args::from(["lint"].as_slice()));
+    assert!(result.is_ok(), "run_cli rerun returned {result:?}");
     assert_cli_snapshot(SnapshotPayload::new(
         module_path!(),
         "migrate_vitest_consistent_test_it_with_options",
         fs,
         console,
         result,
     ));
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_cli/tests/commands/migrate_eslint.rs` around lines 790 - 874,
The two tests migrate_jest_consistent_test_it_with_options and
migrate_vitest_consistent_test_it_with_options currently only run the migration;
add the same lint-roundtrip check used by the existing default-options test that
verifies rule options survive serialization so the option objects are persisted.
Locate the default-options test that performs the roundtrip and replicate its
assertion/roundtrip helper after the run_cli success in both
migrate_jest_consistent_test_it_with_options and
migrate_vitest_consistent_test_it_with_options (use the same helper or
assertions) so the fn/withinDescribe options are validated end-to-end.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/biome_cli/tests/commands/migrate_eslint.rs`:
- Around line 790-874: The two tests
migrate_jest_consistent_test_it_with_options and
migrate_vitest_consistent_test_it_with_options currently only run the migration;
add the same lint-roundtrip check used by the existing default-options test that
verifies rule options survive serialization so the option objects are persisted.
Locate the default-options test that performs the roundtrip and replicate its
assertion/roundtrip helper after the run_cli success in both
migrate_jest_consistent_test_it_with_options and
migrate_vitest_consistent_test_it_with_options (use the same helper or
assertions) so the fn/withinDescribe options are validated end-to-end.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d7f0b39-9b3f-4ea8-be30-2d8fdc19ed84

📥 Commits

Reviewing files that changed from the base of the PR and between 535fbfc and 7a6879e.

⛔ 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_jest_consistent_test_it_no_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_jest_consistent_test_it_with_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_vitest_consistent_test_it_with_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/domain_selector.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/useConsistentTestIt/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidCommentTrivia.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js.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/add-use-consistent-test-it.md
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_cli/src/execute/migrate/eslint_jest.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_consistent_test_it.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidCommentTrivia.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_consistent_test_it.rs
🚧 Files skipped from review as they are similar to previous changes (9)
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_cli/src/execute/migrate/eslint_jest.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js
  • .changeset/add-use-consistent-test-it.md

@dyc3 dyc3 force-pushed the dyc3/use-consistent-test-it branch from 7a6879e to 2be306a Compare March 6, 2026 19:20
```

```block
test2.js:5:5 lint/nursery/useConsistentTestIt FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
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.

tbh, I wasn't expecting this snapshot to change. shouldn't nursery rules be disabled by default, even when you enable the domain?

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs (1)

225-249: ⚠️ Potential issue | 🟠 Major

TestOnlyToFit is unreachable again due to match ordering.

(TestFunctionName::Test, TestFunctionKind::It) already matches test.only, so the fallback that returns RenameKind::TestOnlyToFit never runs.

Suggested fix
-            // `test` when `it` is required
-            (TestFunctionName::Test, TestFunctionKind::It) => RenameKind::TestToIt,
+            // `test.only` when `it` is required (becomes `fit`)
+            (TestFunctionName::Test, TestFunctionKind::It) if is_static_member_only(&callee) => {
+                RenameKind::TestOnlyToFit
+            }
+            // `test` when `it` is required
+            (TestFunctionName::Test, TestFunctionKind::It) => RenameKind::TestToIt,
@@
-            // `test.only` when `it` is required (becomes `fit`)
-            _ => {
-                if required_kind == TestFunctionKind::It
-                    && base_name == TestFunctionName::Test
-                    && is_static_member_only(&callee)
-                {
-                    RenameKind::TestOnlyToFit
-                } else {
-                    return None;
-                }
-            }
+            _ => return None,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs` around
lines 225 - 249, The fallback producing RenameKind::TestOnlyToFit is unreachable
because the (TestFunctionName::Test, TestFunctionKind::It) arm already matches
test.only; update the match to distinguish plain `test` vs `test.only` by adding
a guard: change the existing (TestFunctionName::Test, TestFunctionKind::It) =>
RenameKind::TestToIt arm to only match when !is_static_member_only(&callee), and
add a new arm (TestFunctionName::Test, TestFunctionKind::It) with
is_static_member_only(&callee) => RenameKind::TestOnlyToFit (or place an
equivalent guarded arm before the fallback), keeping references to
is_static_member_only, TestFunctionName::Test, TestFunctionKind::It,
RenameKind::TestToIt, and RenameKind::TestOnlyToFit.
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs (1)

14-25: Prefer keeping helper types below impl Rule for this crate’s rule-file layout.

Not blocking, but moving TestFunctionName, ConsistentTestItState, and RenameKind below impl Rule would match existing conventions and keep rule files easier to scan.

Based on learnings: "In crates/biome_analyze/**/*.rs rule files, all helper functions, structs, and enums must be placed below the impl Rule block. The only exception is when declaring a node union to use in the rule's Query type, which can be kept above the rule block for better readability".

Also applies to: 148-200

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

In `@crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs` around
lines 14 - 25, Move the helper types TestFunctionName, ConsistentTestItState,
and RenameKind from above the impl Rule block to below the impl Rule block so
the file follows the crate's rule-file layout convention; locate the enum
TestFunctionName and the structs/enum named ConsistentTestItState and RenameKind
and cut/paste them to a position after the impl Rule implementation while
ensuring any references inside impl Rule still resolve (adjust visibility if
necessary).
🤖 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_jest.rs`:
- Around line 16-18: The conversion wrongly hardcodes TestFunctionKind::It for
the `within_describe` fallback; change the logic that maps `within_describe:
Option<EslintTestFunctionKind>` to `TestFunctionKind` so that when
`within_describe` is None it inherits the value derived from the `fn` field (the
same `EslintTestFunctionKind` -> `TestFunctionKind` mapping used for `fn`)
instead of always returning TestFunctionKind::It; update the conversion code
that currently returns TestFunctionKind::It to use
`within_describe.unwrap_or(fn)` semantics (i.e., map `within_describe` if
present, otherwise map the parsed `fn` value) so ESLint's fallback behavior is
respected.

In `@crates/biome_cli/src/execute/migrate/eslint_to_biome.rs`:
- Around line 658-679: The branch handling
eslint_eslint::Rule::JestConsistentTestIt calls migrate_eslint_any_rule(...)
which already records migration status, so remove the redundant
results.add(&name, RuleMigrationResult::Migrated) at the end of that branch;
keep the severity/group/options logic and the group.use_consistent_test_it
assignment but delete the extra results.add call to avoid double-bookkeeping and
make this rule consistent with other optioned-rule branches.

---

Duplicate comments:
In `@crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs`:
- Around line 225-249: The fallback producing RenameKind::TestOnlyToFit is
unreachable because the (TestFunctionName::Test, TestFunctionKind::It) arm
already matches test.only; update the match to distinguish plain `test` vs
`test.only` by adding a guard: change the existing (TestFunctionName::Test,
TestFunctionKind::It) => RenameKind::TestToIt arm to only match when
!is_static_member_only(&callee), and add a new arm (TestFunctionName::Test,
TestFunctionKind::It) with is_static_member_only(&callee) =>
RenameKind::TestOnlyToFit (or place an equivalent guarded arm before the
fallback), keeping references to is_static_member_only, TestFunctionName::Test,
TestFunctionKind::It, RenameKind::TestToIt, and RenameKind::TestOnlyToFit.

---

Nitpick comments:
In `@crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs`:
- Around line 14-25: Move the helper types TestFunctionName,
ConsistentTestItState, and RenameKind from above the impl Rule block to below
the impl Rule block so the file follows the crate's rule-file layout convention;
locate the enum TestFunctionName and the structs/enum named
ConsistentTestItState and RenameKind and cut/paste them to a position after the
impl Rule implementation while ensuring any references inside impl Rule still
resolve (adjust visibility if necessary).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de65a12e-626b-464d-bf11-1825a4252894

📥 Commits

Reviewing files that changed from the base of the PR and between 7a6879e and 2be306a.

⛔ Files ignored due to path filters (17)
  • 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_cases_linter_domains/should_enable_domain_via_cli.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_jest_consistent_test_it_no_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_jest_consistent_test_it_with_options.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_commands_migrate_eslint/migrate_vitest_consistent_test_it_with_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/domain_selector.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/useConsistentTestIt/invalid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidCommentTrivia.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js.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/add-use-consistent-test-it.md
  • crates/biome_cli/src/execute/migrate.rs
  • crates/biome_cli/src/execute/migrate/eslint_eslint.rs
  • crates/biome_cli/src/execute/migrate/eslint_jest.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_consistent_test_it.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidCommentTrivia.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_consistent_test_it.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validFnTest.options.json
🚧 Files skipped from review as they are similar to previous changes (10)
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_rule_options/src/use_consistent_test_it.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/valid.js
  • crates/biome_cli/tests/commands/migrate_eslint.rs
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/validWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidWithinDescribeTest.options.json
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalid.js
  • crates/biome_js_analyze/tests/specs/nursery/useConsistentTestIt/invalidFnTest.js

Comment on lines +16 to +18
/// The function to prefer inside `describe` blocks. Defaults to the value of `fn`.
#[deserializable(rename = "withinDescribe")]
pub within_describe: Option<EslintTestFunctionKind>,
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

🧩 Analysis chain

🌐 Web query:

In eslint-plugin-jest's consistent-test-itrule, what are the default values forfnandwithinDescribe? Does withinDescribedefault tofn when omitted?

💡 Result:

  • Default fn: "test"

  • Default withinDescribe: "it" (so, by default, top-level uses test and inside describe uses it). [1][2]

  • Does withinDescribe default to fn when omitted? Yes—if you provide fn but omit withinDescribe, the rule uses withinDescribe = fn. If you omit both, it falls back to the defaults above. [2]

Sources:
[1] Rule docs (consistent-test-it.md) — default configuration description
[2] Rule implementation (src/rules/consistent-test-it.ts) — defaultOptions and option fallback logic


Fix withinDescribe default to respect the ESLint fallback behaviour.

The struct documentation correctly notes that withinDescribe defaults to the value of fn when omitted. However, the conversion at lines 45–47 hardcodes TestFunctionKind::It instead, which diverges from ESLint's actual fallback semantics: when fn is provided and withinDescribe is omitted, the latter should inherit from the former.

Suggested fix
         let fn_kind = val
             .function
             .map_or(TestFunctionKind::Test, TestFunctionKind::from);
         let within_describe = val
             .within_describe
-            .map_or(TestFunctionKind::It, TestFunctionKind::from);
+            .map_or(fn_kind, TestFunctionKind::from);
🤖 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_jest.rs` around lines 16 - 18,
The conversion wrongly hardcodes TestFunctionKind::It for the `within_describe`
fallback; change the logic that maps `within_describe:
Option<EslintTestFunctionKind>` to `TestFunctionKind` so that when
`within_describe` is None it inherits the value derived from the `fn` field (the
same `EslintTestFunctionKind` -> `TestFunctionKind` mapping used for `fn`)
instead of always returning TestFunctionKind::It; update the conversion code
that currently returns TestFunctionKind::It to use
`within_describe.unwrap_or(fn)` semantics (i.e., map `within_describe` if
present, otherwise map the parsed `fn` value) so ESLint's fallback behavior is
respected.

Comment on lines +658 to +679
eslint_eslint::Rule::JestConsistentTestIt(conf) => {
if migrate_eslint_any_rule(rules, &name, conf.severity(), opts, results) {
let severity = conf.severity();
let group = rules.nursery.get_or_insert_with(Default::default);
if let SeverityOrGroup::Group(group) = group {
let rule_options =
if let eslint_eslint::RuleConf::Option(_, rule_options) = conf {
rule_options.into()
} else {
eslint_jest::ConsistentTestItOptions::default().into()
};
group.use_consistent_test_it =
Some(biome_config::RuleFixConfiguration::WithOptions(
biome_config::RuleWithFixOptions {
level: severity.into(),
fix: None,
options: rule_options,
},
));
}
results.add(&name, RuleMigrationResult::Migrated);
}
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

Avoid double-bookkeeping migration status for this rule.

migrate_eslint_any_rule(...) already handles migration status tracking in this file’s flow; the extra results.add(...Migrated) makes this branch inconsistent with the other optioned rules and can skew reporting.

Suggested fix
-                results.add(&name, RuleMigrationResult::Migrated);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
eslint_eslint::Rule::JestConsistentTestIt(conf) => {
if migrate_eslint_any_rule(rules, &name, conf.severity(), opts, results) {
let severity = conf.severity();
let group = rules.nursery.get_or_insert_with(Default::default);
if let SeverityOrGroup::Group(group) = group {
let rule_options =
if let eslint_eslint::RuleConf::Option(_, rule_options) = conf {
rule_options.into()
} else {
eslint_jest::ConsistentTestItOptions::default().into()
};
group.use_consistent_test_it =
Some(biome_config::RuleFixConfiguration::WithOptions(
biome_config::RuleWithFixOptions {
level: severity.into(),
fix: None,
options: rule_options,
},
));
}
results.add(&name, RuleMigrationResult::Migrated);
}
eslint_eslint::Rule::JestConsistentTestIt(conf) => {
if migrate_eslint_any_rule(rules, &name, conf.severity(), opts, results) {
let severity = conf.severity();
let group = rules.nursery.get_or_insert_with(Default::default);
if let SeverityOrGroup::Group(group) = group {
let rule_options =
if let eslint_eslint::RuleConf::Option(_, rule_options) = conf {
rule_options.into()
} else {
eslint_jest::ConsistentTestItOptions::default().into()
};
group.use_consistent_test_it =
Some(biome_config::RuleFixConfiguration::WithOptions(
biome_config::RuleWithFixOptions {
level: severity.into(),
fix: None,
options: rule_options,
},
));
}
}
🤖 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_to_biome.rs` around lines 658 -
679, The branch handling eslint_eslint::Rule::JestConsistentTestIt calls
migrate_eslint_any_rule(...) which already records migration status, so remove
the redundant results.add(&name, RuleMigrationResult::Migrated) at the end of
that branch; keep the severity/group/options logic and the
group.use_consistent_test_it assignment but delete the extra results.add call to
avoid double-bookkeeping and make this rule consistent with other optioned-rule
branches.

@dyc3 dyc3 merged commit 4af4a3a into main Apr 4, 2026
20 checks passed
@dyc3 dyc3 deleted the dyc3/use-consistent-test-it branch April 4, 2026 17:26
@github-actions github-actions Bot mentioned this pull request Apr 4, 2026
Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Diagnostics need a lot of attention

Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs
Comment thread crates/biome_js_analyze/src/lint/nursery/use_consistent_test_it.rs
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.

2 participants