Skip to content

regexp/prefer-range

💼 This rule is enabled in the following configs: 🟢 flat/recommended, 🔵 recommended.

🔧 This rule is automatically fixable by the --fix CLI option.

enforce using character class range

📖 Rule Details

This rule is aimed to use ranges instead of multiple adjacent characters in character class.

Now loading...

🔧 Options

json5
{
  "regexp/prefer-range": ["error",
    {
      "target": "alphanumeric" // or "all" or [...]
    }
  ]
}

This option can be used to override the allowedCharacterRanges setting.

It allows all values that the allowedCharacterRanges setting allows.

"target": "alphanumeric"

Now loading...

"target": "all"

Now loading...

"target": [ "alphanumeric", "😀-😏" ]

Now loading...

🚀 Version

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

🔍 Implementation