# regexp/prefer-d

enforce using \d

  • ⚙️ 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 at using \d instead of [0-9] in regular expressions.

Now loading...

# 🔧 Options

{
  "regexp/prefer-d": [
    "error",
    {
        "insideCharacterClass": "d"
    }
  ]
}

# insideCharacterClass

This option control how character class element equivalent to \d will be treated.

Note: This option does not affect character classes equivalent to \d. E.g. [\d], [0-9], and [0123456789] are unaffected.

  • insideCharacterClass: "d" (default)

    Character class element equivalent to \d will be reported and replaced with \d.

    Now loading...
  • insideCharacterClass: "range"

    Character class element equivalent to \d will be reported and replaced with the range 0-9.

    Now loading...
  • insideCharacterClass: "ignore"

    Character class element will not be reported.

    Now loading...

# 🚀 Version

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

# 🔍 Implementation