Skip to content

chore(linter): Update diagnostics with backticks for code.#16790

Merged
graphite-app[bot] merged 1 commit intomainfrom
regex-test-docs
Dec 13, 2025
Merged

chore(linter): Update diagnostics with backticks for code.#16790
graphite-app[bot] merged 1 commit intomainfrom
regex-test-docs

Conversation

@connorshea
Copy link
Copy Markdown
Member

Update a few rules to use backticks in their diagnostic messages.

Copilot AI review requested due to automatic review settings December 13, 2025 09:04
@connorshea connorshea requested a review from camc314 as a code owner December 13, 2025 09:04
@github-actions github-actions bot added A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Dec 13, 2025
Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

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

The main issue is an internal documentation inconsistency in prefer_regexp_test: the docs mention String#exec() while the rule and diagnostics target RegExp#exec(). Everything else in the diff is straightforward message formatting and snapshot regeneration.

Additional notes (3)
  • Readability | crates/oxc_linter/src/rules/unicorn/prefer_regexp_test.rs:16-16
    The prefer_regexp_test rule documentation says it prefers RegExp#test() over String#match() and String#exec(), but the rest of the rule (diagnostic + later text) correctly references RegExp#exec(). This looks like a copy/paste typo and makes the docs internally inconsistent.

  • Maintainability | crates/oxc_linter/src/rules/unicorn/prefer_negative_index.rs:14-16
    The diagnostic message now includes a trailing period and uses inline code formatting. This is fine stylistically, but watch out for snapshot/test churn across the codebase: if other rules intentionally omit trailing punctuation, this introduces inconsistency in user-facing diagnostics (and makes it harder to grep for exact messages).

If the project has (or should have) a convention, it would be better to apply it uniformly rather than per-rule.

  • Readability | crates/oxc_linter/src/rules/unicorn/prefer_object_from_entries.rs:19-22
    The help text still contains plain words like reduce and forEach without inline code formatting, while other identifiers were switched to backticks. This makes the message partially formatted and slightly harder to scan.

Also, the warning now ends with a period but the help line does not—again, potential inconsistency in user-facing output.

Summary of changes

Summary

This PR standardizes several unicorn rule diagnostics by formatting code identifiers with Markdown backticks and slightly improving message punctuation/line-wrapping.

Updated rule diagnostics

  • prefer_negative_index: message now uses inline code formatting for .length - index and adds a trailing period.
  • prefer_object_from_entries: switches from single quotes to backticks for Object.fromEntries (and Object.fromEntries(pairs)), plus a trailing period in the main warning.
  • prefer_reflect_apply: switches to backticks for Reflect.apply() / Function#apply() in both warning/help text and docs comments.
  • prefer_regexp_test: switches to backticks for RegExp#test() / String#match() / RegExp#exec(), adds punctuation, and wraps a long doc comment across multiple lines.

Snapshot updates

  • Regenerated snapshots to reflect the updated diagnostic strings for:
    • unicorn_prefer_object_from_entries.snap
    • unicorn_prefer_reflect_apply.snap
    • unicorn_prefer_regexp_test.snap

Copy link
Copy Markdown
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

This PR updates diagnostic messages for several linter rules to use backticks for code references, improving readability and consistency. The changes add backticks around function names, method names, and code snippets, and ensure messages end with proper punctuation.

Key changes:

  • Added backticks around code references in diagnostic and help messages (e.g., RegExp#test(), Reflect.apply(), Object.fromEntries)
  • Added periods at the end of messages for consistency
  • Reformatted documentation in one rule to improve line wrapping

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/oxc_linter/src/rules/unicorn/prefer_regexp_test.rs Added backticks to diagnostic and help messages, added periods, reformatted documentation comment
crates/oxc_linter/src/rules/unicorn/prefer_reflect_apply.rs Added backticks to diagnostic, help, and documentation messages, added periods
crates/oxc_linter/src/rules/unicorn/prefer_object_from_entries.rs Added backticks to diagnostic message and period
crates/oxc_linter/src/rules/unicorn/prefer_negative_index.rs Added backticks to diagnostic message and period, includes minor whitespace cleanup
crates/oxc_linter/src/snapshots/unicorn_prefer_regexp_test.snap Updated snapshot to reflect new diagnostic messages with backticks and periods
crates/oxc_linter/src/snapshots/unicorn_prefer_reflect_apply.snap Updated snapshot to reflect new diagnostic messages with backticks and periods
crates/oxc_linter/src/snapshots/unicorn_prefer_object_from_entries.snap Updated snapshot to reflect new diagnostic messages with backticks and periods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 13, 2025

CodSpeed Performance Report

Merging #16790 will not alter performance

Comparing regex-test-docs (da684ca) with main (67bde85)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

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

Copy link
Copy Markdown
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

Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@connorshea connorshea added the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
Copy link
Copy Markdown
Member Author

connorshea commented Dec 13, 2025

Merge activity

Update a few rules to use backticks in their diagnostic messages.
@graphite-app graphite-app bot merged commit 0d0d606 into main Dec 13, 2025
20 checks passed
@graphite-app graphite-app bot deleted the regex-test-docs branch December 13, 2025 09:28
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants