useSortedEnumMembers (GraphQL)
Summary
Section titled “Summary”- Rule available since:
v2.5.0 - Diagnostic Category:
assist/source/useSortedEnumMembers - Sources:
- Inspired from
@graphql-eslint/alphabetize
- Inspired from
How to enable in your editor
Section titled “How to enable in your editor”{ "editor.codeActionsOnSave": { "source.action.useSortedEnumMembers.biome": "explicit", "source.fixAll.biome": "explicit" }}{ "code_actions_on_format": { "source.action.useSortedEnumMembers.biome": true, "source.fixAll.biome": true }}
Use the source action code
source.action.useSortedEnumMembers.biome How to configure
Section titled “How to configure”{ "assist": { "actions": { "source": { "useSortedEnumMembers": "on" } } }}Description
Section titled “Description”Sort GraphQL enum values in natural order.
Natural order compares numbers by value, so ROLE_9 comes before ROLE_10. It places
uppercase letters before lowercase letters when names otherwise match. Keeping values
sorted makes growing enums easier to scan and review.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”enum Role { SUPER_ADMIN ADMIN USER GOD}code-block.graphql ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Source action diff:
1 1 │ enum Role {
2 │ - ··SUPER_ADMIN
3 │ - ··ADMIN
4 │ - ··USER
5 │ - ··GOD
2 │ + ··ADMIN
3 │ + ··GOD
4 │ + ··SUPER_ADMIN
5 │ + ··USER
6 6 │ }
7 7 │
enum Role { ADMIN GOD SUPER_ADMIN USER}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.