diff --git a/lib/rules/no-literal-string.js b/lib/rules/no-literal-string.js index 5e7391d..bd5690b 100644 --- a/lib/rules/no-literal-string.js +++ b/lib/rules/no-literal-string.js @@ -146,6 +146,16 @@ module.exports = { }, // ───────────────────────────────────────────────────────────────── + // + // ─── TYPESCRIPT ────────────────────────────────────────────────── + // + + 'TSLiteralType Literal'(node) { + // allow var a: Type['member']; + visited.push(node); + }, + // ───────────────────────────────────────────────────────────────── + 'VariableDeclarator > Literal'(node) { // allow statements like const A_B = "test" if (isUpperCase(node.parent.id.name)) visited.push(node); diff --git a/tests/lib/rules/no-literal-string.js b/tests/lib/rules/no-literal-string.js index c7bf778..365945e 100644 --- a/tests/lib/rules/no-literal-string.js +++ b/tests/lib/rules/no-literal-string.js @@ -106,7 +106,15 @@ const tsTester = new RuleTester({ }); tsTester.run('no-literal-string', rule, { - valid: [{ code: '
' }], + valid: [ + { code: '' }, + { + code: "var a: Element['nodeName']" + }, + { + code: "var a: Omit