refactor(linter): remove MessageRule - #25031
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will improve performance by 3.56%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR refactors oxc_linter diagnostics by removing the dedicated MessageRule metadata and relying on OxcDiagnostic’s error code (scope + number) as the single source of truth for identifying the producing rule.
Changes:
- Remove
MessageRuleand theMessage::rulefield, and stop attaching rule metadata viawith_rule. - Introduce
oxc_code_short_canonical_name(&OxcCode)and switch suppression tracking + ignore-fix generation to derive rule keys frommessage.error.code. - Update TypeScript Go-lint (
tsgolint) message construction and core linter diagnostic emission to work withoutMessageRule.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_linter/src/tsgolint.rs | Stop attaching MessageRule to TS Go-lint messages; rely on diagnostic error codes. |
| crates/oxc_linter/src/suppression/diff.rs | Compute suppression keys from message.error.code via oxc_code_short_canonical_name. |
| crates/oxc_linter/src/lib.rs | Remove MessageRule from re-exports; re-export new helper; adjust diagnostic ordering/emission accordingly. |
| crates/oxc_linter/src/fixer/mod.rs | Delete MessageRule type and Message::rule; add oxc_code_short_canonical_name helper. |
| crates/oxc_linter/src/fixer/disable_fix.rs | Generate ignore-disable directive rule names from the diagnostic error code. |
| crates/oxc_linter/src/context/mod.rs | Stop populating Message::rule in LintContext::add_diagnostic (error code remains the rule identifier). |
Comments suppressed due to low confidence (1)
crates/oxc_linter/src/suppression/diff.rs:111
- The suppression key is now derived from
message.error.coderather thanMessageRule, which changes the canonicalization source (notably it will follow the diagnostic scope/display-name mapping likejsx-a11y,react-perf,next). There don’t appear to be suppression fixtures covering plugins whose internal name differs from the display name, so this behavior is currently untested and could regress silently.
for message in diagnostics {
// Only consider error severity messages for suppression tracking
if message.error.severity != Severity::Error {
continue;
}
let Some(key) = oxc_code_short_canonical_name(&message.error.code) else {
continue;
};
suppression_tracking.entry(key).or_insert(DiagnosticCounts { count: 0 }).count += 1;
}
a95ecd6 to
8c16760
Compare
6c962d2 to
0929b81
Compare

This struct was introduced by Bulk-Suppressions (#19328).
OxcDiagnosticalready containsOxcCodewith the relevant information.Downside: The
oxc_parserdiagnostics can be included now in the suppression file.