Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sort-switch-case): Adds partitionByNewLine #288

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Loading