Skip to content


💼 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

  "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