Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 872 Bytes

prefer-string-raw.md

File metadata and controls

30 lines (20 loc) · 872 Bytes

Prefer using the String.raw tag to avoid escaping \

💼 This rule is enabled in the ✅ recommended config.

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

String.raw can be used to avoid escaping \.

Fail

const file = "C:\\windows\\style\\path\\to\\file.js";
const regexp = new RegExp('foo\\.bar');

Pass

const file = String.raw`C:\windows\style\path\to\file.js`;
const regexp = new RegExp(String.raw`foo\.bar`);