Skip to content

Commit c77dce0

Browse files
committed
docs(linter): Add configuration option docs for eslint/init-declarations rule.
1 parent 1f8f979 commit c77dce0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

crates/oxc_linter/src/rules/eslint/init_declarations.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use oxc_ast::{
88
use oxc_diagnostics::OxcDiagnostic;
99
use oxc_macros::declare_oxc_lint;
1010
use oxc_span::Span;
11+
use schemars::JsonSchema;
1112
use serde_json::Value;
1213

1314
use 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")]
2729
enum 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)]
4043
pub 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

115123
impl Rule for InitDeclarations {

0 commit comments

Comments
 (0)