# regexp/prefer-range

enforce using character class range

  • ⚙️ This rule is included in "plugin:regexp/recommended".
  • 🔧 The --fix option on the command line (opens new window) can automatically fix some of the problems reported by this rule.

# 📖 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

Last Updated: 6/25/2022, 12:32:38 PM