Skip to content

Commit 2f7fa1b

Browse files
committed
perf(linter/plugins): flatten LintFileResult fields
1 parent 0d48511 commit 2f7fa1b

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

apps/oxlint/src-js/plugins/context.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ interface Diagnostic {
1111
// Diagnostic in form sent to Rust
1212
interface DiagnosticReport {
1313
message: string;
14-
loc: { start: number; end: number };
14+
start: number;
15+
end: number;
1516
ruleIndex: number;
1617
}
1718

@@ -115,9 +116,12 @@ export class Context {
115116
*/
116117
report(diagnostic: Diagnostic): void {
117118
const { ruleIndex } = getInternal(this, 'report errors');
119+
// TODO: Validate `diagnostic`
120+
const { node } = diagnostic;
118121
diagnostics.push({
119122
message: diagnostic.message,
120-
loc: { start: diagnostic.node.start, end: diagnostic.node.end },
123+
start: node.start,
124+
end: node.end,
121125
ruleIndex,
122126
});
123127
}

crates/oxc_linter/src/external_linter.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ pub enum PluginLoadResult {
2929
pub struct LintFileResult {
3030
pub rule_index: u32,
3131
pub message: String,
32-
pub loc: Loc,
33-
}
34-
35-
#[derive(Clone, Debug, Deserialize, Serialize)]
36-
pub struct Loc {
3732
pub start: u32,
3833
pub end: u32,
3934
}

crates/oxc_linter/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ impl Linter {
408408
Ok(diagnostics) => {
409409
for diagnostic in diagnostics {
410410
// Convert UTF-16 offsets back to UTF-8
411-
let mut span = Span::new(diagnostic.loc.start, diagnostic.loc.end);
411+
let mut span = Span::new(diagnostic.start, diagnostic.end);
412412
span_converter.convert_span_back(&mut span);
413413

414414
let (external_rule_id, severity) =

0 commit comments

Comments
 (0)