Skip to content

Commit

Permalink
fix(sort-switch-case): adds documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 committed Sep 26, 2024
1 parent b983efc commit cce0fb3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/content/rules/sort-switch-case.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ Controls whether sorting should be case-sensitive or not.
- `true` — Ignore case when sorting alphabetically or naturally (e.g., “A” and “a” are the same).
- `false` — Consider case when sorting (e.g., “A” comes before “a”).

### partitionByNewLine

<sub>default: `false`</sub>

When `true`, the rule will not sort the members of an enum if there is an empty line between them. This can be useful for keeping logically separated groups of members in their defined order.

```ts
switch (action) {
// Group 1
case 'Drone':
case 'Keyboard':
case 'Mouse':
case 'Smartphone':

// Group 2
case 'Laptop':
case 'Monitor':
case 'Smartwatch':
case 'Tablet':

// Group 3
case 'Headphones':
case 'Router':
}
```

## Usage

<CodeTabs
Expand All @@ -195,6 +221,7 @@ Controls whether sorting should be case-sensitive or not.
type: 'alphabetical',
order: 'asc',
ignoreCase: true,
partitionByNewLine: false
},
],
},
Expand All @@ -218,6 +245,7 @@ Controls whether sorting should be case-sensitive or not.
type: 'alphabetical',
order: 'asc',
ignoreCase: true,
partitionByNewLine: false
},
],
},
Expand Down

0 comments on commit cce0fb3

Please sign in to comment.