Skip to content

Commit

Permalink
Update: fix quotes false negative for string literals as template tags (
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark authored and kaicataldo committed Feb 20, 2017
1 parent 21be366 commit d89d0b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rules/quotes.js
Expand Up @@ -257,7 +257,11 @@ module.exports = {
TemplateLiteral(node) {

// If backticks are expected or it's a tagged template, then this shouldn't throw an errors
if (allowTemplateLiterals || quoteOption === "backtick" || node.parent.type === "TaggedTemplateExpression") {
if (
allowTemplateLiterals ||
quoteOption === "backtick" ||
node.parent.type === "TaggedTemplateExpression" && node === node.parent.quasi
) {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/quotes.js
Expand Up @@ -302,6 +302,12 @@ ruleTester.run("quotes", rule, {
output: "var foo = \"foo\\\\\\\nbar\";",
parserOptions: { ecmaVersion: 6 },
errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral" }]
},
{
code: "````",
output: "\"\"``",
parserOptions: { ecmaVersion: 6 },
errors: [{ message: "Strings must use doublequote.", type: "TemplateLiteral", line: 1, column: 1 }]
}
]
});

0 comments on commit d89d0b4

Please sign in to comment.