Skip to content

Commit 008e67a

Browse files
authored
docs(linter): Add configuration option docs for jest/no-large-snapshots rule. (#15079)
Part of #14743. Generated docs: ```md ## Configuration This rule accepts a configuration object with the following properties: ### allowedSnapshots type: `Record<string, array>` default: `{}` A map of snapshot file paths to arrays of snapshot names that are allowed to exceed the size limit. Snapshot names can be specified as regular expressions. ### inlineMaxSize type: `integer` default: `50` Maximum number of lines allowed for inline snapshots. ### maxSize type: `integer` default: `50` Maximum number of lines allowed for external snapshot files. ```
1 parent 31daf79 commit 008e67a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/oxc_linter/src/rules/jest/no_large_snapshots.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use oxc_diagnostics::OxcDiagnostic;
99
use oxc_macros::declare_oxc_lint;
1010
use oxc_span::{CompactStr, GetSpan, Span};
1111
use rustc_hash::FxHashMap;
12+
use schemars::JsonSchema;
13+
use serde::Deserialize;
1214

1315
use crate::{
1416
context::LintContext,
@@ -35,10 +37,15 @@ fn too_long_snapshot(line_limit: usize, line_count: usize, span: Span) -> OxcDia
3537
#[derive(Debug, Default, Clone)]
3638
pub struct NoLargeSnapshots(Box<NoLargeSnapshotsConfig>);
3739

38-
#[derive(Debug, Clone)]
40+
#[derive(Debug, Clone, Deserialize, JsonSchema)]
41+
#[serde(rename_all = "camelCase", default)]
3942
pub struct NoLargeSnapshotsConfig {
43+
/// Maximum number of lines allowed for external snapshot files.
4044
pub max_size: usize,
45+
/// Maximum number of lines allowed for inline snapshots.
4146
pub inline_max_size: usize,
47+
/// A map of snapshot file paths to arrays of snapshot names that are allowed to exceed the size limit.
48+
/// Snapshot names can be specified as regular expressions.
4249
pub allowed_snapshots: FxHashMap<CompactStr, Vec<CompactStr>>,
4350
}
4451

@@ -140,6 +147,7 @@ declare_oxc_lint!(
140147
NoLargeSnapshots,
141148
jest,
142149
style,
150+
config = NoLargeSnapshotsConfig,
143151
);
144152

145153
impl Rule for NoLargeSnapshots {

0 commit comments

Comments
 (0)