Skip to content

Commit

Permalink
prefer-string-raw: Ignore strings in Enums
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 11, 2024
1 parent 94b6f5e commit 6fdd107
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions rules/prefer-string-raw.js
Expand Up @@ -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;
}
Expand Down
16 changes: 16 additions & 0 deletions test/prefer-string-raw.mjs
Expand Up @@ -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: [],
});

0 comments on commit 6fdd107

Please sign in to comment.