Skip to content

Commit 07aea72

Browse files
authored
docs(linter): Add configuration option docs for eslint/sort-keys rule. (#15014)
Part of #14743. Generated docs: ```md ## Configuration This rule accepts a configuration object with the following properties: ### allowLineSeparatedGroups type: `boolean` default: `false` When true, groups of properties separated by a blank line are sorted independently. ### caseSensitive type: `boolean` default: `true` Whether the sort comparison is case-sensitive (A < a when true). ### minKeys type: `integer` default: `2` Minimum number of properties required in an object before sorting is enforced. ### natural type: `boolean` default: `false` Use natural sort order so that, for example, "a2" comes before "a10". ### sortOrder type: `"desc" | "asc"` default: `"asc"` Sorting order for keys. Accepts "asc" for ascending or "desc" for descending. ```
1 parent 35b36e0 commit 07aea72

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,34 @@ use oxc_ast::{AstKind, ast::ObjectPropertyKind};
77
use oxc_diagnostics::OxcDiagnostic;
88
use oxc_macros::declare_oxc_lint;
99
use oxc_span::{GetSpan, Span};
10+
use schemars::JsonSchema;
11+
use serde::{Deserialize, Serialize};
1012

1113
use crate::{AstNode, context::LintContext, rule::Rule};
1214

1315
#[derive(Debug, Default, Clone)]
1416
pub struct SortKeys(Box<SortKeysOptions>);
1517

16-
#[derive(Debug, Default, Clone, Eq, PartialEq)]
18+
#[derive(Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
19+
#[serde(rename_all = "lowercase")]
1720
pub enum SortOrder {
1821
Desc,
1922
#[default]
2023
Asc,
2124
}
2225

23-
#[derive(Debug, Clone)]
26+
#[derive(Debug, Clone, JsonSchema)]
27+
#[serde(rename_all = "camelCase", default)]
2428
pub struct SortKeysOptions {
29+
/// Sorting order for keys. Accepts "asc" for ascending or "desc" for descending.
2530
sort_order: SortOrder,
31+
/// Whether the sort comparison is case-sensitive (A < a when true).
2632
case_sensitive: bool,
33+
/// Use natural sort order so that, for example, "a2" comes before "a10".
2734
natural: bool,
35+
/// Minimum number of properties required in an object before sorting is enforced.
2836
min_keys: usize,
37+
/// When true, groups of properties separated by a blank line are sorted independently.
2938
allow_line_separated_groups: bool,
3039
}
3140

@@ -84,7 +93,8 @@ declare_oxc_lint!(
8493
SortKeys,
8594
eslint,
8695
style,
87-
conditional_fix
96+
conditional_fix,
97+
config = SortKeysOptions
8898
);
8999

90100
impl Rule for SortKeys {

0 commit comments

Comments
 (0)