File tree Expand file tree Collapse file tree 11 files changed +13
-17
lines changed Expand file tree Collapse file tree 11 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ impl Linter {
248248 let external_linter = self . external_linter . as_ref ( ) . unwrap ( ) ;
249249
250250 // Write offset of `Program` in metadata at end of buffer
251- let program = semantic. nodes ( ) . program ( ) . unwrap ( ) ;
251+ let program = semantic. nodes ( ) . program ( ) ;
252252 let program_offset = ptr:: from_ref ( program) as u32 ;
253253
254254 let metadata = RawTransferMetadata :: new ( program_offset) ;
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ impl Rule for SortImports {
134134 }
135135
136136 fn run_once ( & self , ctx : & LintContext ) {
137- let program = ctx. nodes ( ) . program ( ) . unwrap ( ) ;
137+ let program = ctx. nodes ( ) . program ( ) ;
138138
139139 let mut import_declarations = vec ! [ ] ;
140140
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ declare_oxc_lint!(
5151impl Rule for ExportsLast {
5252 fn run_once ( & self , ctx : & LintContext < ' _ > ) {
5353 // find last non export declaration index
54- let program = ctx. nodes ( ) . program ( ) . unwrap ( ) ;
54+ let program = ctx. nodes ( ) . program ( ) ;
5555 let body = & program. body ;
5656 let find_res =
5757 body. iter ( ) . rev ( ) . find_position ( |statement| !is_exports_declaration ( statement) ) ;
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ impl Rule for First {
110110 let mut non_import_count = 0 ;
111111 let mut any_relative = false ;
112112
113- let program = ctx. nodes ( ) . program ( ) . unwrap ( ) ;
113+ let program = ctx. nodes ( ) . program ( ) ;
114114
115115 for statement in & program. body {
116116 match statement {
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ declare_oxc_lint!(
9090
9191impl Rule for NoAsyncClientComponent {
9292 fn run_once ( & self , ctx : & LintContext ) {
93- let program = ctx. nodes ( ) . program ( ) . unwrap ( ) ;
93+ let program = ctx. nodes ( ) . program ( ) ;
9494
9595 if program. directives . iter ( ) . any ( |directive| directive. directive . as_str ( ) == "use client" ) {
9696 for node in & program. body {
Original file line number Diff line number Diff line change @@ -576,7 +576,7 @@ fn get_type_only_named_import<'a>(
576576 ctx : & LintContext < ' a > ,
577577 source : & str ,
578578) -> Option < & ' a ImportDeclaration < ' a > > {
579- let program = ctx. nodes ( ) . program ( ) . unwrap ( ) ;
579+ let program = ctx. nodes ( ) . program ( ) ;
580580
581581 for stmt in & program. body {
582582 let Statement :: ImportDeclaration ( import_decl) = stmt else {
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ impl Rule for TripleSlashReference {
106106 }
107107
108108 fn run_once ( & self , ctx : & LintContext ) {
109- let program = ctx. nodes ( ) . program ( ) . unwrap ( ) ;
109+ let program = ctx. nodes ( ) . program ( ) ;
110110
111111 // We don't need to iterate over all comments since Triple-slash directives are only valid at the top of their containing file.
112112 // We are trying to get the first statement start potioin, falling back to the program end if statement does not exist
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ declare_oxc_lint!(
4343
4444impl Rule for NoEmptyFile {
4545 fn run_once ( & self , ctx : & LintContext ) {
46- let program = ctx. nodes ( ) . program ( ) . unwrap ( ) ;
46+ let program = ctx. nodes ( ) . program ( ) ;
4747 if program. body . iter ( ) . any ( |node| !is_empty_stmt ( node) ) {
4848 return ;
4949 }
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ impl Rule for NoProcessExit {
6363}
6464
6565fn has_hashbang ( ctx : & LintContext ) -> bool {
66- ctx. nodes ( ) . program ( ) . unwrap ( ) . hashbang . is_some ( )
66+ ctx. nodes ( ) . program ( ) . hashbang . is_some ( )
6767}
6868
6969fn is_inside_process_event_handler ( ctx : & LintContext , node : & AstNode ) -> bool {
Original file line number Diff line number Diff line change @@ -185,12 +185,10 @@ impl<'a> AstNodes<'a> {
185185 }
186186
187187 /// Get the [`Program`] that's also the root of the AST.
188- ///
189- /// Returns [`None`] if root node isn't set. This will never happen if you
190- /// are obtaining an [`AstNodes`] that has already been constructed.
191188 #[ inline]
192- pub fn program ( & self ) -> Option < & ' a Program < ' a > > {
193- self . program
189+ pub fn program ( & self ) -> & ' a Program < ' a > {
190+ #[ expect( clippy:: missing_panics_doc, reason = "self.program is always `Some`" ) ]
191+ self . program . as_ref ( ) . unwrap ( )
194192 }
195193
196194 /// Create and add an [`AstNode`] to the [`AstNodes`] tree and get its [`NodeId`].
You can’t perform that action at this time.
0 commit comments