Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 8, 2024
1 parent 8ff1ca2 commit 5977493
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions rules/escape-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand All @@ -59,7 +59,7 @@ const create = context => {
node,
original: node.value.raw,
fix: (fixer, fixed) => replaceTemplateElement(fixer, node, fixed),
})
});
});
};

Expand Down
11 changes: 6 additions & 5 deletions test/escape-case.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5977493

Please sign in to comment.