From fd93861fb5728f3bb6a5354f7141584fbcf76d2d Mon Sep 17 00:00:00 2001 From: edvardchen <> Date: Wed, 10 Jul 2019 15:27:16 +0800 Subject: [PATCH] feat: dont check TSLiteralType --- lib/rules/no-literal-string.js | 10 ++++++++++ tests/lib/rules/no-literal-string.js | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) 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