A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://eslint.org/docs/latest/rules/no-invalid-regexp below:

no-invalid-regexp - ESLint - Pluggable JavaScript Linter

no-invalid-regexp

Disallow invalid regular expression strings in RegExp constructors

Recommended

Using the recommended config from @eslint/js in a configuration file enables this rule

Table of Contents

An invalid pattern in a regular expression literal is a SyntaxError when the code is parsed, but an invalid string in RegExp constructors throws a SyntaxError only when the code is executed.

Rule Details

This rule disallows invalid regular expression strings in RegExp constructors.

Examples of incorrect code for this rule:

Examples of correct code for this rule:

Please note that this rule validates regular expressions per the latest ECMAScript specification, regardless of your parser settings.

If you want to allow additional constructor flags for any reason, you can specify them using the allowConstructorFlags option. These flags will then be ignored by the rule.

Options

This rule has an object option for exceptions:

allowConstructorFlags

Examples of correct code for this rule with the { "allowConstructorFlags": ["a", "z"] } option:

Version

This rule was introduced in ESLint v0.1.4.

Further Reading Annotated ES5
es5.github.io Resources

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4