RunDevelopment/eslint-plugin-clean-regex

Suggest i flag if it simplifies the pattern

RunDevelopment opened this issue · 1 comments

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")?