Skip to content

Commit 29b6fed

Browse files
committed
docs(linter): Update no-plusplus rule to expose documentation for config options.
1 parent 7a420a1 commit 29b6fed

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use oxc_ast::{AstKind, ast::UpdateOperator};
22
use oxc_diagnostics::OxcDiagnostic;
33
use oxc_macros::declare_oxc_lint;
44
use oxc_span::{GetSpan, Span};
5+
use schemars::JsonSchema;
56

67
use crate::{AstNode, context::LintContext, rule::Rule};
78

@@ -22,7 +23,8 @@ fn no_plusplus_diagnostic(span: Span, operator: UpdateOperator) -> OxcDiagnostic
2223
}
2324
}
2425

25-
#[derive(Debug, Default, Clone)]
26+
#[derive(Debug, Default, Clone, JsonSchema)]
27+
#[serde(rename_all = "camelCase", default)]
2628
pub struct NoPlusplus {
2729
/// Whether to allow `++` and `--` in for loop afterthoughts.
2830
allow_for_loop_afterthoughts: bool,
@@ -76,29 +78,14 @@ declare_oxc_lint!(
7678
/// doSomething(i);
7779
/// }
7880
/// ```
79-
///
80-
/// ### Options
81-
///
82-
/// #### allowForLoopAfterthoughts
83-
///
84-
/// `{ type: boolean, default: false }`
85-
///
86-
/// Pass `"allowForLoopAfterthoughts": true` to allow `++` and `--` in for loop afterthoughts.
87-
///
88-
/// Example:
89-
/// ```json
90-
/// "no-plusplus": [
91-
/// "error",
92-
/// { "allowForLoopAfterthoughts": true }
93-
/// ]
94-
/// ```
9581
NoPlusplus,
9682
eslint,
9783
restriction,
9884
// This is not guaranteed to rewrite the code in a way that is equivalent.
9985
// For example, `++i` and `i++` will be rewritten as `i += 1` even though they are not the same.
10086
// If the code depends on the order of evaluation, then this might break it.
10187
conditional_suggestion,
88+
config = NoPlusplus,
10289
);
10390

10491
impl Rule for NoPlusplus {

0 commit comments

Comments
 (0)