Skip to content

regexp/sort-alternatives โ€‹

๐Ÿ”ง 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 โ€‹

Nothing.

๐Ÿš€ Version โ€‹

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

๐Ÿ” Implementation โ€‹