Skip to content


🔧 This rule is automatically fixable by the --fix CLI option.

sort alternatives if order doesn't matter

📖 Rule Details

This rule will sort alternatives to improve readability and maintainability.

The primary target of this rule are lists of words and/or numbers. These lists are somewhat common, and sorting them makes it easy for readers to check whether a particular word or number is included.

This rule will only sort alternatives if reordering the alternatives doesn't affect the pattern.
However, character classes containing strings are ensured to match the longest string, so they can always be sorted.

Now loading...

🔧 Options


🚀 Version

This rule was introduced in eslint-plugin-regexp v0.12.0

🔍 Implementation