diff --git a/rules/escape-case.js b/rules/escape-case.js index 6439457e55..cad68a0051 100644 --- a/rules/escape-case.js +++ b/rules/escape-case.js @@ -47,7 +47,7 @@ const create = context => { const templateLiteral = node.parent; if ( templateLiteral.parent.type === 'TaggedTemplateExpression' - && templateLiteral.parent.quasi == templateLiteral + && templateLiteral.parent.quasi === templateLiteral ) { const {tag} = templateLiteral.parent; if (isNodeMatches(tag, ['String.raw'])) { @@ -59,7 +59,7 @@ const create = context => { node, original: node.value.raw, fix: (fixer, fixed) => replaceTemplateElement(fixer, node, fixed), - }) + }); }); }; diff --git a/test/escape-case.mjs b/test/escape-case.mjs index 7ba85ef6d8..e527d11c90 100644 --- a/test/escape-case.mjs +++ b/test/escape-case.mjs @@ -41,7 +41,7 @@ test({ 'const foo = `foo\\\\\\\\xbar`;', 'const foo = `foo\\\\\\\\ubarbaz`;', 'const foo = `\\ca`;', - 'const foo = String.raw`\\xA9`;', + 'const foo = String.raw`\\uAaAa`;', // Literal regex 'const foo = /foo\\xA9/', @@ -192,15 +192,16 @@ test({ output: 'const foo = `foo \\\\\\uD834`;', }, // TODO: This is not safe, it will be broken if `tagged` uses `arguments[0].raw` + // #2341 { - code: 'const foo = tagged`\\xa9`;', + code: 'const foo = tagged`\\uAaAa`;', errors, - output: 'const foo = tagged`\\xA9`;', + output: 'const foo = tagged`\\uAAAA`;', }, { - code: 'const foo = `\\xa9```;', + code: 'const foo = `\\uAaAa```;', errors, - output: 'const foo = `\\xA9```;', + output: 'const foo = `\\uAAAA```;', }, // Mixed cases