Skip to content

Files

Latest commit

 

History

History
24 lines (16 loc) · 600 Bytes

no-standalone-backslash.md

File metadata and controls

24 lines (16 loc) · 600 Bytes

Pattern: Standalone backslash without escape

Issue: -

Description

This rule disallows backslash (\) without escape.

E.g. the regular expression /\c/ without the Unicode (u) flag is the same pattern as /\\c/.

In most cases, standalone backslashes are used by accident when a control escape sequence (\cX) or another escape sequence was intended. They are very confusing and should not be used intentionally.

Examples

/* eslint regexp/no-standalone-backslash: "error" */
/* ✓ GOOD */
var foo = /\cX/;

/* ✗ BAD */
var foo = /\c/;
var foo = /\c-/;
var foo = /[\c]/;