Skip to content
This repository was archived by the owner on Oct 11, 2021. It is now read-only.
This repository was archived by the owner on Oct 11, 2021. It is now read-only.

perfer-character-class: Reorder alternatives if it's safe #18

@RunDevelopment

Description

@RunDevelopment

If the only thing preventing two one-character alternatives from being merged is an alternative that cannot start with either characters (from the one-character alternatives), then it's safe to reorder the alternatives and merge the one-character alternatives.

Example:
(?:a|foo|b) == (?:a|b|foo) == (?:[ab]|foo)

I already added a util method that can detect the first character of an alternative, so this should be easy to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomersruleIt's about new or existing rules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions