Skip to content

Commit

Permalink
prefer-string-raw: Ignore strings in Enums (#2354)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored May 11, 2024
1 parent 94b6f5e commit 175ea04
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 175ea04

Please sign in to comment.