Skip to content

Commit 175ea04

Browse files
authored
prefer-string-raw: Ignore strings in Enums (#2354)
1 parent 94b6f5e commit 175ea04

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

rules/prefer-string-raw.js

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const create = context => {
4747
)
4848
|| (node.parent.type === 'Property' && !node.parent.computed && node.parent.key === node)
4949
|| (node.parent.type === 'JSXAttribute' && node.parent.value === node)
50+
|| (node.parent.type === 'TSEnumMember' && (node.parent.initializer === node || node.parent.id === node))
5051
) {
5152
return;
5253
}

test/prefer-string-raw.mjs

+16
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ test.snapshot({
3838
String.raw`const foo = "foo \\x46";`,
3939
],
4040
});
41+
42+
test.typescript({
43+
valid: [
44+
outdent`
45+
enum Files {
46+
Foo = "C:\\\\path\\\\to\\\\foo.js",
47+
}
48+
`,
49+
outdent`
50+
enum Foo {
51+
"\\\\a\\\\b" = "baz",
52+
}
53+
`,
54+
],
55+
invalid: [],
56+
});

0 commit comments

Comments
 (0)