chore(linter): Update diagnostics with backticks for code.#16790
chore(linter): Update diagnostics with backticks for code.#16790graphite-app[bot] merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
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
Theprefer_regexp_testrule documentation says it prefersRegExp#test()overString#match()andString#exec(), but the rest of the rule (diagnostic + later text) correctly referencesRegExp#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
Thehelptext still contains plain words likereduceandforEachwithout 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 - indexand adds a trailing period.prefer_object_from_entries: switches from single quotes to backticks forObject.fromEntries(andObject.fromEntries(pairs)), plus a trailing period in the main warning.prefer_reflect_apply: switches to backticks forReflect.apply()/Function#apply()in both warning/help text and docs comments.prefer_regexp_test: switches to backticks forRegExp#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.snapunicorn_prefer_reflect_apply.snapunicorn_prefer_regexp_test.snap
There was a problem hiding this comment.
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.
crates/oxc_linter/src/rules/unicorn/prefer_object_from_entries.rs
Outdated
Show resolved
Hide resolved
CodSpeed Performance ReportMerging #16790 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
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.
Merge activity
|
Update a few rules to use backticks in their diagnostic messages.
da684ca to
0d0d606
Compare
Update a few rules to use backticks in their diagnostic messages.