Skip to content

Commit f639d94

Browse files
authoredFeb 11, 2025··
feat: add fallback sort option to all rules
1 parent b0a54df commit f639d94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2109
-32
lines changed
 

‎docs/content/rules/sort-array-includes.mdx

+19
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,25 @@ Determines whether the sorted items should be in ascending or descending order.
140140
- `'asc'` — Sort items in ascending order (A to Z, 1 to 9).
141141
- `'desc'` — Sort items in descending order (Z to A, 9 to 1).
142142

143+
### fallbackSort
144+
145+
<sub>
146+
type: `{ type: string; order?: 'asc' | 'desc' }`
147+
</sub>
148+
<sub>default: `{ type: 'unsorted' }`</sub>
149+
150+
Defines a list of fallback sort options to use when comparing two elements that are equal according to the primary sort
151+
[`type`](#type).
152+
153+
Example: enforce alphabetical sort between two elements with the same length.
154+
```ts
155+
{
156+
type: 'line-length',
157+
order: 'desc'
158+
fallbackSort: { type: 'alphabetical', order: 'asc' }
159+
}
160+
```
161+
143162
### alphabet
144163

145164
<sub>default: `''`</sub>

‎docs/content/rules/sort-classes.mdx

+19
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,25 @@ Determines whether the sorted items should be in ascending or descending order.
174174
- `'asc'` — Sort items in ascending order (A to Z, 1 to 9).
175175
- `'desc'` — Sort items in descending order (Z to A, 9 to 1).
176176

177+
### fallbackSort
178+
179+
<sub>
180+
type: `{ type: string; order?: 'asc' | 'desc' }`
181+
</sub>
182+
<sub>default: `{ type: 'unsorted' }`</sub>
183+
184+
Defines a list of fallback sort options to use when comparing two elements that are equal according to the primary sort
185+
[`type`](#type).
186+
187+
Example: enforce alphabetical sort between two elements with the same length.
188+
```ts
189+
{
190+
type: 'line-length',
191+
order: 'desc'
192+
fallbackSort: { type: 'alphabetical', order: 'asc' }
193+
}
194+
```
195+
177196
### alphabet
178197

179198
<sub>default: `''`</sub>

0 commit comments

Comments
 (0)
Please sign in to comment.