Skip to content

Latest commit

 

History

History
81 lines (57 loc) · 1.67 KB

match-any.md

File metadata and controls

81 lines (57 loc) · 1.67 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/match-any
enforce match any character style
v0.1.0

regexp/match-any

💼 This rule is enabled in the ✅ plugin:regexp/recommended config.

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

enforce match any character style

📖 Rule Details

This rule enforces the regular expression notation to match any character.
e.g. [\s\S], [^], /./s (dotAll) and more.

/* eslint regexp/match-any: "error" */

/* ✓ GOOD */
var foo = /[\s\S]/;
var foo = /./s;

/* ✗ BAD */
var foo = /[\S\s]/;
var foo = /[^]/;
var foo = /[\d\D]/;
var foo = /[\w\W]/;

🔧 Options

{
  "regexp/match-any": ["error", {
    "allows": ["[\\s\\S]", "dotAll"]
  }]
}
  • "allows" ... An array of notations that any characters that are allowed.
    "[\\s\\S]", "[\\S\\s]", "[^]" and "dotAll" can be set.

{ "allows": ["[^]"] }

/* eslint regexp/match-any: ["error", { "allows": ["[^]"] }] */

/* ✓ GOOD */
var foo = /[^]/;

/* ✗ BAD */
var foo = /[\s\S]/;
var foo = /[\S\s]/;
var foo = /./s;
var foo = /[\d\D]/;
var foo = /[\w\W]/;

🚀 Version

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

🔍 Implementation