Skip to content

Commit 96bb814

Browse files
committed
feature: @putout/plugin-convert-quotes-to-backticks: add support of ObjectProperty
1 parent fb33806 commit 96bb814

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

packages/plugin-convert-quotes-to-backticks/lib/convert-quotes-to-backticks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module.exports.fix = (path) => {
1616
.replaceAll('\\', '\\\\')
1717
.replaceAll('\n', '\\n');
1818

19+
if (path.parentPath.isObjectProperty())
20+
path.parentPath.node.computed = true;
21+
1922
replaceWith(path, TemplateLiteral([TemplateElement({
2023
raw: value,
2124
})], []));
@@ -25,9 +28,6 @@ const {replaceWith} = operator;
2528

2629
module.exports.traverse = ({push}) => ({
2730
StringLiteral(path) {
28-
if (path.parentPath.isObjectProperty())
29-
return;
30-
3131
const {value} = path.node;
3232

3333
if (value.includes('${'))

packages/plugin-convert-quotes-to-backticks/test/convert-quotes-to-backticks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ test('plugin-convert-quotes-to-backtics: no report: variables', (t) => {
2929
t.end();
3030
});
3131

32-
test('plugin-convert-quotes-to-backtics: no report: object-key', (t) => {
33-
t.noReport('object-key');
32+
test('plugin-convert-quotes-to-backtics: transform: object-key', (t) => {
33+
t.transform('object-key');
3434
t.end();
3535
});
3636

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const replace = () => ({
2+
[`''`]: '"")',
3+
});

0 commit comments

Comments
 (0)