Skip to content

Latest commit

 

History

History
72 lines (47 loc) · 2.17 KB

strict.md

File metadata and controls

72 lines (47 loc) · 2.17 KB
pageClass sidebarDepth title description since
rule-details
0
regexp/strict
disallow not strictly valid regular expressions
v0.12.0

regexp/strict

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

🔧💡 This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.

disallow not strictly valid regular expressions

📖 Rule Details

This rule disallows not strictly valid regular expressions.

An invalid pattern in a regular expression literal is a SyntaxError when the code is parsed. However, it is not always strictly checked.

Depending on the syntax defined in Annex B of the ECMAScript specification, some ambiguous pattern syntax may also succeed in parsing as a valid pattern. This rule reports these ambiguous patterns.

/* eslint regexp/strict: "error" */

/* ✓ GOOD */
var foo = /\}/
var foo = /\{/
var foo = /\]/
var foo = /\u{42}/u; // It matches "B".
var foo = /u{42}/; // It matches a string followed by 42 "u"s.

/* ✗ BAD */
var foo = /}/
var foo = /{/
var foo = /]/
var foo = /\u{42}/; // It matches a string followed by 42 "u"s.

🔧 Options

Nothing.

📚 Further reading

👫 Related rules

🚀 Version

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

🔍 Implementation