Skip to content

test(linter/unicorn): regenerate tests#19861

Merged
graphite-app[bot] merged 1 commit intomainfrom
update-unicorn-tests2
Mar 1, 2026
Merged

test(linter/unicorn): regenerate tests#19861
graphite-app[bot] merged 1 commit intomainfrom
update-unicorn-tests2

Conversation

@connorshea
Copy link
Member

I can break this into smaller PRs if desired, basically just cleaning up the unicorn tests in a variety of ways and/or regenerating them:

  • Remove unnecessary raw string usage.
  • Regenerate tests that used old escaping, so we can more easily detect updates/new tests/changes in the future.
  • Indentation fixes
  • Removal of tab usage in a few files.
  • Regeneration of all of the unicorn rules' tests where new rules were added, some are commented out due to failure for now.
  • Updates to the snapshots accordingly.

Copilot AI review requested due to automatic review settings March 1, 2026 06:23
@connorshea connorshea requested a review from camc314 as a code owner March 1, 2026 06:23
@github-actions github-actions bot added A-linter Area - Linter C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Mar 1, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Regenerates and normalizes the Unicorn linter rules’ unit tests and their snapshots, primarily to improve consistency (escaping/indentation) and to incorporate newly added/updated test cases across the Unicorn rule set.

Changes:

  • Regenerated Unicorn rule pass/fail/fix test cases with updated escaping/formatting and additional coverage (incl. multiline/optional-chaining variants).
  • Cleaned up indentation/tab usage in multiple Unicorn rule tests.
  • Updated snapshot outputs to match regenerated tests and any newly covered diagnostics.

Reviewed changes

Copilot reviewed 61 out of 62 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
crates/oxc_linter/src/snapshots/unicorn_require_array_join_separator.snap Snapshot updated for newly added complex failing case output.
crates/oxc_linter/src/snapshots/unicorn_prefer_string_trim_start_end.snap Snapshot updated to include additional .trimRight diagnostic case.
crates/oxc_linter/src/snapshots/unicorn_prefer_string_slice.snap Snapshot updated for new substr/substring cases and spans.
crates/oxc_linter/src/snapshots/unicorn_prefer_regexp_test.snap Snapshot updated for new async/await and additional match/exec cases.
crates/oxc_linter/src/snapshots/unicorn_prefer_query_selector.snap Snapshot updated for added chained DOM query cases.
crates/oxc_linter/src/snapshots/unicorn_prefer_optional_catch_binding.snap Snapshot updated for expanded catch-binding scenarios and formatting changes.
crates/oxc_linter/src/snapshots/unicorn_prefer_node_protocol.snap Snapshot updated for new dynamic import cases and additional coverage.
crates/oxc_linter/src/snapshots/unicorn_prefer_native_coercion_functions.snap Snapshot updated for added function/class cases and callback coercion diagnostics.
crates/oxc_linter/src/snapshots/unicorn_prefer_modern_dom_apis.snap Snapshot updated for multiline replaceChild/insertAdjacentElement cases.
crates/oxc_linter/src/snapshots/unicorn_prefer_global_this.snap Snapshot updated for new 'in' operator global alias cases.
crates/oxc_linter/src/snapshots/unicorn_prefer_array_flat_map.snap Snapshot updated for additional .map(...).flat() variants and formatting.
crates/oxc_linter/src/snapshots/unicorn_prefer_array_flat.snap Snapshot updated for added .flatMap(...) legacy-flattening detections.
crates/oxc_linter/src/snapshots/unicorn_no_zero_fractions.snap Snapshot updated for new numeric literal edge cases (dangling dots / exponent).
crates/oxc_linter/src/snapshots/unicorn_no_useless_fallback_in_spread.snap Snapshot updated for nested spread/fallback case.
crates/oxc_linter/src/snapshots/unicorn_no_useless_collection_argument.snap Snapshot updated for empty-array argument variant.
crates/oxc_linter/src/snapshots/unicorn_no_unreadable_iife.snap Snapshot updated due to regenerated formatting/locations.
crates/oxc_linter/src/snapshots/unicorn_no_static_only_class.snap Snapshot updated for additional static-only class patterns.
crates/oxc_linter/src/snapshots/unicorn_no_object_as_default_parameter.snap Snapshot updated for additional class-member default parameter cases (incl. parser error output).
crates/oxc_linter/src/snapshots/unicorn_no_new_buffer.snap Snapshot updated for expanded new Buffer(...) patterns.
crates/oxc_linter/src/snapshots/unicorn_no_nested_ternary.snap Snapshot updated for additional nested-ternary case.
crates/oxc_linter/src/snapshots/unicorn_no_negation_in_equality_check.snap Snapshot updated due to regenerated formatting/locations.
crates/oxc_linter/src/snapshots/unicorn_error_message.snap Snapshot updated for additional Error()/assignment flows and new cases.
crates/oxc_linter/src/rules/unicorn/require_post_message_target_origin.rs Adjusted tests; added TODO-commented optional-chain case.
crates/oxc_linter/src/rules/unicorn/require_array_join_separator.rs Added complex failing test to validate separator detection on noisy AST.
crates/oxc_linter/src/rules/unicorn/prefer_top_level_await.rs Added optional-call and Promise.all patterns to tests.
crates/oxc_linter/src/rules/unicorn/prefer_string_trim_start_end.rs Added multiline .trimRight test case coverage.
crates/oxc_linter/src/rules/unicorn/prefer_string_slice.rs Added additional substr/substring fail cases and new fix expectations (some commented out).
crates/oxc_linter/src/rules/unicorn/prefer_regexp_test.rs Added async/await and additional match/exec scenarios to tests.
crates/oxc_linter/src/rules/unicorn/prefer_query_selector.rs Normalized string literals and added chained DOM query failure example; added TODO-commented getElementsByName cases.
crates/oxc_linter/src/rules/unicorn/prefer_optional_catch_binding.rs Regenerated pass/fail/fix tests with additional scoping and comment-heavy cases.
crates/oxc_linter/src/rules/unicorn/prefer_node_protocol.rs Expanded tests (incl. dynamic imports) and normalized raw-string usage; some cases commented out.
crates/oxc_linter/src/rules/unicorn/prefer_native_coercion_functions.rs Added more pass/fail coverage for function/class patterns and array-callback coercion cases; some cases commented out.
crates/oxc_linter/src/rules/unicorn/prefer_modern_dom_apis.rs Normalized string literals and added multiline/inline-comment cases for DOM API replacements.
crates/oxc_linter/src/rules/unicorn/prefer_math_trunc.rs Added additional bitwise-or assignment (`
crates/oxc_linter/src/rules/unicorn/prefer_global_this.rs Added new 'in' operator cases; commented out an additional TODO case.
crates/oxc_linter/src/rules/unicorn/prefer_dom_node_text_content.rs Normalized string literal escaping in tests.
crates/oxc_linter/src/rules/unicorn/prefer_dom_node_remove.rs Added TODO-commented computed-property call case.
crates/oxc_linter/src/rules/unicorn/prefer_dom_node_dataset.rs Normalized string literal formatting in tests.
crates/oxc_linter/src/rules/unicorn/prefer_code_point.rs Normalized string literal usage and tuple formatting in fix tests.
crates/oxc_linter/src/rules/unicorn/prefer_array_some.rs Normalized raw-string usage and tuple formatting in tests.
crates/oxc_linter/src/rules/unicorn/prefer_array_flat_map.rs Added additional .map(...).flat() variants; added TODO-commented optional-chain cases.
crates/oxc_linter/src/rules/unicorn/prefer_array_flat.rs Added additional .flatMap(...) detection cases; commented out some fixer expectations.
crates/oxc_linter/src/rules/unicorn/no_zero_fractions.rs Expanded failing cases and normalized string usage in tests.
crates/oxc_linter/src/rules/unicorn/no_useless_undefined.rs Normalized test case formatting/quoting and multiline literals.
crates/oxc_linter/src/rules/unicorn/no_useless_switch_case.rs Normalized multiline test string literals (removed raw-string usage).
crates/oxc_linter/src/rules/unicorn/no_useless_fallback_in_spread.rs Added nested spread/fallback test input.
crates/oxc_linter/src/rules/unicorn/no_useless_collection_argument.rs Added new Set([/**/]) test case.
crates/oxc_linter/src/rules/unicorn/no_unreadable_iife.rs Normalized multiline strings in pass/fail tests.
crates/oxc_linter/src/rules/unicorn/no_this_assignment.rs Added class field = this pass coverage (instance/static).
crates/oxc_linter/src/rules/unicorn/no_static_only_class.rs Added multiple static-only class variants to pass coverage.
crates/oxc_linter/src/rules/unicorn/no_process_exit.rs Normalized raw-string usage and multiline literal formatting in tests.
crates/oxc_linter/src/rules/unicorn/no_object_as_default_parameter.rs Added class-member default parameter cases (incl. invalid setter syntax) and additional pass coverage.
crates/oxc_linter/src/rules/unicorn/no_null.rs Added optional-chaining variant for insertBefore(..., null) test tuple.
crates/oxc_linter/src/rules/unicorn/no_new_buffer.rs Expanded new Buffer(...) detection test inputs.
crates/oxc_linter/src/rules/unicorn/no_nested_ternary.rs Added additional nested-ternary failure example.
crates/oxc_linter/src/rules/unicorn/no_negation_in_equality_check.rs Normalized multiline strings for negation-in-equality cases.
crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs Normalized raw-string usage for multiple test inputs.
crates/oxc_linter/src/rules/unicorn/no_invalid_fetch_options.rs Normalized raw-string usage for multiple test inputs.
crates/oxc_linter/src/rules/unicorn/no_array_method_this_argument.rs Added optional-chaining Array?.fromAsync(...) pass test.
crates/oxc_linter/src/rules/unicorn/no_array_for_each.rs Normalized raw-string usage for multiple test inputs.
crates/oxc_linter/src/rules/unicorn/error_message.rs Expanded pass/fail coverage and normalized formatting; added TODO-commented unsupported cases.
crates/oxc_linter/src/rules/unicorn/consistent_date_clone.rs Fixed indentation / removed tab usage in multiline Date constructor test strings.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 1, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 51 skipped benchmarks1


Comparing update-unicorn-tests2 (9ff1d2c) with main (3e70161)

Open in CodSpeed

Footnotes

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

@camc314 camc314 changed the title test(linter): Regenerate tests for Unicorn rules test(linter/unicorn): regenerate tests Mar 1, 2026
@camc314 camc314 self-assigned this Mar 1, 2026
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 1, 2026
Copy link
Contributor

camc314 commented Mar 1, 2026

Merge activity

I can break this into smaller PRs if desired, basically just cleaning up the unicorn tests in a variety of ways and/or regenerating them:

- Remove unnecessary raw string usage.
- Regenerate tests that used old escaping, so we can more easily detect updates/new tests/changes in the future.
- Indentation fixes
- Removal of tab usage in a few files.
- Regeneration of all of the unicorn rules' tests where new rules were added, some are commented out due to failure for now.
- Updates to the snapshots accordingly.
@graphite-app graphite-app bot force-pushed the update-unicorn-tests2 branch from 9ff1d2c to 14e5ddb Compare March 1, 2026 11:33
@graphite-app graphite-app bot merged commit 14e5ddb into main Mar 1, 2026
21 checks passed
@graphite-app graphite-app bot deleted the update-unicorn-tests2 branch March 1, 2026 11:38
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 1, 2026
graphite-app bot pushed a commit that referenced this pull request Mar 6, 2026
…tElementsByName()`. (#20060)

See the upstream where this change was made: sindresorhus/eslint-plugin-unicorn@e511ffd

I added these tests in #19861. I've also added a few more fixer tests accordingly.

AI Disclosure: Used Claude to implement the update for the fixer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants