test(linter/unicorn): regenerate tests#19861
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 1, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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/fixtest 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. |
Merging this PR will not alter performance
Comparing Footnotes
|
camc314
approved these changes
Mar 1, 2026
Contributor
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.
9ff1d2c to
14e5ddb
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: