diff --git a/rules/prefer-string-raw.js b/rules/prefer-string-raw.js index 4241e11163..134e0e5d02 100644 --- a/rules/prefer-string-raw.js +++ b/rules/prefer-string-raw.js @@ -47,6 +47,7 @@ const create = context => { ) || (node.parent.type === 'Property' && !node.parent.computed && node.parent.key === node) || (node.parent.type === 'JSXAttribute' && node.parent.value === node) + || (node.parent.type === 'TSEnumMember' && (node.parent.initializer === node || node.parent.id === node)) ) { return; } diff --git a/test/prefer-string-raw.mjs b/test/prefer-string-raw.mjs index 2f818eac66..af5e034c7a 100644 --- a/test/prefer-string-raw.mjs +++ b/test/prefer-string-raw.mjs @@ -38,3 +38,19 @@ test.snapshot({ String.raw`const foo = "foo \\x46";`, ], }); + +test.typescript({ + valid: [ + outdent` + enum Files { + Foo = "C:\\\\path\\\\to\\\\foo.js", + } + `, + outdent` + enum Foo { + "\\\\a\\\\b" = "baz", + } + `, + ], + invalid: [], +});