Skip to content

Commit

Permalink
fix(eslint-plugin): [prefer-literal-enum-member] allow pure template …
Browse files Browse the repository at this point in the history
…literal strings (#2786)
  • Loading branch information
ddubrava committed Nov 19, 2020
1 parent 7af66a7 commit f3bf6a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -29,6 +29,13 @@ export default createRule({
if (node.initializer.type === AST_NODE_TYPES.Literal) {
return;
}
// TemplateLiteral without expressions
if (
node.initializer.type === AST_NODE_TYPES.TemplateLiteral &&
node.initializer.expressions.length === 0
) {
return;
}
// -1 and +1
if (
node.initializer.type === AST_NODE_TYPES.UnaryExpression &&
Expand Down
Expand Up @@ -18,6 +18,11 @@ enum ValidString {
}
`,
`
enum ValidLiteral {
A = \`test\`,
}
`,
`
enum ValidNumber {
A = 42,
}
Expand Down Expand Up @@ -90,7 +95,7 @@ enum InvalidArray {
{
code: `
enum InvalidTemplateLiteral {
A = \`a\`,
A = \`foo \${0}\`,
}
`,
errors: [
Expand Down

0 comments on commit f3bf6a1

Please sign in to comment.