Suggest i flag if it simplifies the pattern
RunDevelopment opened this issue · 1 comments
RunDevelopment commented
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:
- The
iflag isn't present. - All characters, character classes, and character sets match the same character(s) regardless of the
iflag (aka. the flag doesn't change the meaning of the pattern.) - There is at least one character class that can be simplified because of the added
iflag. 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")?
RunDevelopment commented
Already covered by ota-meshi/eslint-plugin-regexp#201