@@ -71,37 +71,36 @@ export async function runOxlintCommand(ids: string | string[], ctx: OxlintContex
7171 }
7272
7373 const results : LintResult [ ] = [ ]
74- const outputs = destr < OxlintOutput [ ] > ( format ( stdout ) )
75-
76- if ( Array . isArray ( outputs ) ) {
77- for await ( const { filename } of outputs ) {
78- if ( contentRecord [ filename ] )
79- continue
80- const c = await fse . readFile ( filename , { encoding : 'utf8' } )
81- contentRecord [ filename ] = c
82- }
83-
84- outputs . forEach ( ( { code, filename, severity, message, labels } ) => {
85- const [ { span } ] = labels
86- const lines = contentRecord [ filename ] . slice ( 0 , span . offset ) . split ( '\n' )
87- const line = lines . length
88- const column = lines [ lines . length - 1 ] . length + 1
89- const { content } = detectOxlintMessage ( message )
90- const ruleId = code . match ( / \( ( [ ^ ) ] + ) \) / ) ?. [ 1 ] ?? ''
91- const result : LintResult = {
92- filename,
93- linter : 'oxlint' ,
94- severity,
95- message : content ,
96- ruleId,
97- line,
98- column,
99- }
100- results . push ( result )
101- ctx . insertLintResult ( filename , result )
102- } )
74+ const outputs = destr < OxlintOutput | OxlintOutput [ 'diagnostics' ] > ( format ( stdout ) )
75+ const diagnostics = Array . isArray ( outputs ) ? outputs : outputs . diagnostics
76+
77+ for await ( const { filename } of diagnostics ) {
78+ if ( contentRecord [ filename ] )
79+ continue
80+ const c = await fse . readFile ( filename , { encoding : 'utf8' } )
81+ contentRecord [ filename ] = c
10382 }
10483
84+ diagnostics . forEach ( ( { code, filename, severity, message, labels } ) => {
85+ const [ { span } ] = labels
86+ const lines = contentRecord [ filename ] . slice ( 0 , span . offset ) . split ( '\n' )
87+ const line = lines . length
88+ const column = lines [ lines . length - 1 ] . length + 1
89+ const { content } = detectOxlintMessage ( message )
90+ const ruleId = code . match ( / \( ( [ ^ ) ] + ) \) / ) ?. [ 1 ] ?? ''
91+ const result : LintResult = {
92+ filename,
93+ linter : 'oxlint' ,
94+ severity,
95+ message : content ,
96+ ruleId,
97+ line,
98+ column,
99+ }
100+ results . push ( result )
101+ ctx . insertLintResult ( filename , result )
102+ } )
103+
105104 return results
106105}
107106
0 commit comments