Skip to content

Latest commit

ย 

History

History
38 lines (26 loc) ยท 1.05 KB

File metadata and controls

38 lines (26 loc) ยท 1.05 KB

prefer-string-raw

๐Ÿ“ Prefer using the String.raw tag to avoid escaping \.

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

String.raw can be used to avoid escaping \.

Examples

// โŒ
const file = "C:\\windows\\style\\path\\to\\file.js";

// โœ…
const file = String.raw`C:\windows\style\path\to\file.js`;
// โŒ
const regexp = new RegExp('foo\\.bar');

// โœ…
const regexp = new RegExp(String.raw`foo\.bar`);
// โŒ
const file = `C:\\windows\\temp\\myapp-${process.pid}.log`;

// โœ…
const file = String.raw`C:\windows\temp\myapp-${process.pid}.log`;
โšก