11use std:: ops:: Deref ;
22
3+ use schemars:: JsonSchema ;
34use serde:: { Deserialize , Serialize } ;
45
56use oxc_ast:: {
@@ -63,15 +64,13 @@ fn no_map_spread_diagnostic(
6364 diagnostic. and_labels ( others) . and_labels ( returned_label)
6465}
6566
66- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
67+ #[ derive( Debug , Clone , Serialize , Deserialize , JsonSchema ) ]
6768#[ serde( rename_all = "camelCase" ) ]
6869pub struct NoMapSpreadConfig {
6970 /// Ignore mapped arrays that are re-read after the `map` call.
7071 ///
7172 /// Re-used arrays may rely on shallow copying behavior to avoid mutations.
7273 /// In these cases, `Object.assign` is not really more performant than spreads.
73- ///
74- /// Default: `true`
7574 #[ serde( default = "default_true" ) ]
7675 ignore_rereads : bool ,
7776 /// Ignore maps on arrays passed as parameters to a function.
@@ -80,7 +79,7 @@ pub struct NoMapSpreadConfig {
8079 /// comes at the cost of potentially missing spreads that are inefficient.
8180 /// We recommend turning this off in your `.oxlintrc.json` files.
8281 ///
83- /// ### Example
82+ /// #### Examples
8483 ///
8584 /// Examples of **incorrect** code for this rule when `ignoreArgs` is `true`:
8685 /// ```ts
@@ -98,8 +97,6 @@ pub struct NoMapSpreadConfig {
9897 /// return arr.map(x => ({ ...x }));
9998 /// }
10099 /// ```
101- ///
102- /// Default: `true`
103100 #[ serde( default = "default_true" ) ]
104101 ignore_args : bool ,
105102 // todo: ignore_arrays?
@@ -313,7 +310,8 @@ declare_oxc_lint!(
313310 NoMapSpread ,
314311 oxc,
315312 nursery, // TODO: make this `perf` once we've battle-tested this a bit
316- conditional_fix_suggestion
313+ conditional_fix_suggestion,
314+ config = NoMapSpreadConfig ,
317315) ;
318316
319317const MAP_FN_NAMES : [ & str ; 2 ] = [ "map" , "flatMap" ] ;
0 commit comments