diff --git a/lib/rules/no-literal-string.js b/lib/rules/no-literal-string.js index 705cb11..33e812a 100644 --- a/lib/rules/no-literal-string.js +++ b/lib/rules/no-literal-string.js @@ -348,6 +348,11 @@ module.exports = { indicatorStack.push(true); }, 'TSLiteralType:exit': endIndicator, + TSEnumMember(node) { + // allow enum E { "a b" = 1 } + indicatorStack.push(true); + }, + 'TSEnumMember:exit': endIndicator, // ───────────────────────────────────────────────────────────────── ClassProperty(node) { diff --git a/tests/lib/rules/no-literal-string.js b/tests/lib/rules/no-literal-string.js index 7c64477..384683b 100644 --- a/tests/lib/rules/no-literal-string.js +++ b/tests/lib/rules/no-literal-string.js @@ -238,7 +238,7 @@ tsTester.run('no-literal-string', rule, { { code: `var a: 'abc' = 'abc'` }, { code: `var a: 'abc' | 'name' | undefined= 'abc'` }, { code: "type T = {name: 'b'} ; var a: T = {name: 'b'}" }, - { code: "enum T {howard=1} ; var a = T['howard']" }, + { code: "enum T {howard=1, 'a b'=2} ; var a = T['howard']" }, { code: "function Button({ t= 'name' }: {t: 'name'}){} " }, { code: "type T ={t?:'name'|'abc'};function Button({t='name'}:T){}" }, ],