@@ -8,6 +8,7 @@ use oxc_ast::{
88use oxc_diagnostics:: OxcDiagnostic ;
99use oxc_macros:: declare_oxc_lint;
1010use oxc_span:: Span ;
11+ use schemars:: JsonSchema ;
1112use serde_json:: Value ;
1213
1314use crate :: { AstNode , context:: LintContext , rule:: Rule } ;
@@ -23,7 +24,8 @@ fn init_declarations_diagnostic(span: Span, mode: &Mode, identifier_name: &str)
2324 . with_label ( span)
2425}
2526
26- #[ derive( Debug , Default , PartialEq , Clone ) ]
27+ #[ derive( Debug , Default , PartialEq , Clone , JsonSchema ) ]
28+ #[ serde( rename_all = "lowercase" ) ]
2729enum Mode {
2830 #[ default]
2931 Always ,
@@ -36,9 +38,14 @@ impl Mode {
3638 }
3739}
3840
39- #[ derive( Debug , Default , Clone ) ]
41+ #[ derive( Debug , Default , Clone , JsonSchema ) ]
42+ #[ serde( rename_all = "camelCase" , default ) ]
4043pub struct InitDeclarations {
44+ /// When set to `"always"` (default), requires that variables be initialized on declaration.
45+ /// When set to `"never"`, disallows initialization during declaration.
4146 mode : Mode ,
47+ /// When set to `true`, allows uninitialized variables in the init expression of `for`, `for-in`, and `for-of` loops.
48+ /// Only applies when mode is set to `"never"`.
4249 ignore_for_loop_init : bool ,
4350}
4451
@@ -109,7 +116,8 @@ declare_oxc_lint!(
109116 /// ```
110117 InitDeclarations ,
111118 eslint,
112- style
119+ style,
120+ config = InitDeclarations ,
113121) ;
114122
115123impl Rule for InitDeclarations {
0 commit comments