From 6afe4fc27b24d0fbb1e14d512f7eddf53a1b7783 Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 10 Mar 2020 12:40:42 +0800 Subject: [PATCH] Add `html` and `svg` --- rules/string-content.js | 4 +++- test/string-content.js | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/rules/string-content.js b/rules/string-content.js index 0facb77efe..64ea86ce4d 100644 --- a/rules/string-content.js +++ b/rules/string-content.js @@ -9,7 +9,9 @@ const defaultPatterns = { }; const ignoredIdentifier = new Set([ - 'gql' + 'gql', + 'html', + 'svg' ]); const ignoredMemberExpressionObject = new Set([ diff --git a/test/string-content.js b/test/string-content.js index e782434489..4b603427ed 100644 --- a/test/string-content.js +++ b/test/string-content.js @@ -43,8 +43,26 @@ ruleTester.run('string-content', rule, { // Should not escape 'const foo = `\\`\\${1}`', // Ignored - 'const foo = gql`\'`', - 'const foo = styled.div`\'`' + ` + const foo = gql\`{ + field(input: '...') + }\`; + `, + ` + const foo = styled.div\` + background: url('...') + \`; + `, + ` + const foo = html\` +
...
+ \`; + `, + ` + const foo = svg\` + + \`; + ` /* eslint-enable no-template-curly-in-string */ ], invalid: [ @@ -208,7 +226,6 @@ ruleTester.run('string-content', rule, { output: 'const foo = notIgnoredTag`’`', errors: createError('\'', '’') } - /* eslint-enable no-template-curly-in-string */ ] });