@@ -2,6 +2,7 @@ use oxc_ast::{AstKind, ast::UpdateOperator};
22use oxc_diagnostics:: OxcDiagnostic ;
33use oxc_macros:: declare_oxc_lint;
44use oxc_span:: { GetSpan , Span } ;
5+ use schemars:: JsonSchema ;
56
67use 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 ) ]
2628pub 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
10491impl Rule for NoPlusplus {
0 commit comments