Skip to content

Commit f57621c

Browse files
committed
docs(linter): Add configuration option docs for no-map-spread rule.
1 parent 55ee962 commit f57621c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

crates/oxc_linter/src/rules/oxc/no_map_spread.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::ops::Deref;
22

3+
use schemars::JsonSchema;
34
use serde::{Deserialize, Serialize};
45

56
use 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")]
6869
pub 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

319317
const MAP_FN_NAMES: [&str; 2] = ["map", "flatMap"];

0 commit comments

Comments
 (0)