Skip to content

Commit

Permalink
feat: dont check TSLiteralType
Browse files Browse the repository at this point in the history
  • Loading branch information
edvardchen committed Jul 10, 2019
1 parent 57c5066 commit fd93861
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/rules/no-literal-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion tests/lib/rules/no-literal-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ const tsTester = new RuleTester({
});

tsTester.run('no-literal-string', rule, {
valid: [{ code: '<div className="hello"></div>' }],
valid: [
{ code: '<div className="hello"></div>' },
{
code: "var a: Element['nodeName']"
},
{
code: "var a: Omit<T, 'af'>"
}
],
invalid: [
{
code: `(<button className={styles.btn}>loading</button>)`,
Expand Down

0 comments on commit fd93861

Please sign in to comment.