@@ -14,6 +14,7 @@ use oxc_span::{SourceType, Span};
1414
1515use super :: { AllowWarnDeny , ConfigStore , DisableDirectives , ResolvedLinterState , read_to_string} ;
1616
17+ use crate :: FixKind ;
1718#[ cfg( feature = "language_server" ) ]
1819use crate :: fixer:: { CompositeFix , Message , PossibleFixes } ;
1920
@@ -29,24 +30,46 @@ pub struct TsGoLintState {
2930 /// If `oxlint` will output the diagnostics or not.
3031 /// When `silent` is true, we do not need to access the file system for nice diagnostics messages.
3132 silent : bool ,
33+ /// If `true`, request that fixes be returned from `tsgolint`.
34+ fix : bool ,
35+ /// If `true`, request that suggestions be returned from `tsgolint`.
36+ fix_suggestions : bool ,
3237}
3338
3439impl TsGoLintState {
35- pub fn new ( cwd : & Path , config_store : ConfigStore ) -> Self {
40+ pub fn new ( cwd : & Path , config_store : ConfigStore , fix_kind : FixKind ) -> Self {
3641 let executable_path =
3742 try_find_tsgolint_executable ( cwd) . unwrap_or ( PathBuf :: from ( "tsgolint" ) ) ;
3843
39- TsGoLintState { config_store, executable_path, cwd : cwd. to_path_buf ( ) , silent : false }
44+ TsGoLintState {
45+ config_store,
46+ executable_path,
47+ cwd : cwd. to_path_buf ( ) ,
48+ silent : false ,
49+ fix : fix_kind. contains ( FixKind :: Fix ) ,
50+ fix_suggestions : fix_kind. contains ( FixKind :: Suggestion ) ,
51+ }
4052 }
4153
4254 /// Try to create a new TsGoLintState, returning an error if the executable cannot be found.
4355 ///
4456 /// # Errors
4557 /// Returns an error if the tsgolint executable cannot be found.
46- pub fn try_new ( cwd : & Path , config_store : ConfigStore ) -> Result < Self , String > {
58+ pub fn try_new (
59+ cwd : & Path ,
60+ config_store : ConfigStore ,
61+ fix_kind : FixKind ,
62+ ) -> Result < Self , String > {
4763 let executable_path = try_find_tsgolint_executable ( cwd) ?;
4864
49- Ok ( TsGoLintState { config_store, executable_path, cwd : cwd. to_path_buf ( ) , silent : false } )
65+ Ok ( TsGoLintState {
66+ config_store,
67+ executable_path,
68+ cwd : cwd. to_path_buf ( ) ,
69+ silent : false ,
70+ fix : fix_kind. contains ( FixKind :: Fix ) ,
71+ fix_suggestions : fix_kind. contains ( FixKind :: Suggestion ) ,
72+ } )
5073 }
5174
5275 /// Set to `true` to skip file system reads.
@@ -90,6 +113,14 @@ impl TsGoLintState {
90113 . stdout ( std:: process:: Stdio :: piped ( ) )
91114 . stderr ( stderr ( ) ) ;
92115
116+ if self . fix {
117+ cmd. arg ( "-fix" ) ;
118+ }
119+
120+ if self . fix_suggestions {
121+ cmd. arg ( "-fix-suggestions" ) ;
122+ }
123+
93124 if let Ok ( trace_file) = std:: env:: var ( "OXLINT_TSGOLINT_TRACE" ) {
94125 cmd. arg ( format ! ( "-trace={trace_file}" ) ) ;
95126 }
0 commit comments