Skip to content
Permalink
Browse files

fix(eslint-plugin): [prefer-literal-enum-member] allow pure template …

…literal strings (#2786)
  • Loading branch information
ddubrava committed Nov 19, 2020
1 parent 7af66a7 commit f3bf6a1791c9dc64bb18d45712f07767c9f96cbd
@@ -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 &&
@@ -18,6 +18,11 @@ enum ValidString {
}
`,
`
enum ValidLiteral {
A = \`test\`,
}
`,
`
enum ValidNumber {
A = 42,
}
@@ -90,7 +95,7 @@ enum InvalidArray {
{
code: `
enum InvalidTemplateLiteral {
A = \`a\`,
A = \`foo \${0}\`,
}
`,
errors: [

0 comments on commit f3bf6a1

Please sign in to comment.