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.

Suggest i flag if it simplifies the pattern #19

@RunDevelopment

Description

@RunDevelopment

If a pattern can be simplified by adding the i flag, it might be a good idea to suggest that to the user.

The conditions for this rule to add the i flag (and subsequently simplify the pattern) are:

  1. The i flag isn't present.
  2. All characters, character classes, and character sets match the same character(s) regardless of the i flag (aka. the flag doesn't change the meaning of the pattern.)
  3. There is at least one character class that can be simplified because of the added i flag. E.g. a character range can be removed, or a character class can be replaced by a character or character set, or similar.

Adding flags willy-nilly might cause some problems, so I don't know whether it should be auto-fixable. Does ESLint have a suggestion mode (aka "you might want to do this but I (ESLint) won't auto-fix it for you")?

Metadata

Metadata

Assignees

No one assigned

    Labels

    new ruleruleIt's about new or existing rules

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions