Skip to content

Commit 8aabd6c

Browse files
committed
feature: @putout/plugin-apply-shorthand-properties: string: exclude
1 parent c760aed commit 8aabd6c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

packages/plugin-apply-shorthand-properties/lib/apply-shorthand-properties.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ export const traverse = ({push, options}) => ({
5151
continue;
5252

5353
const keyPath = propPath.get('key');
54+
const valuePath = propPath.get('value');
55+
5456
const keyIsString = keyPath.isStringLiteral();
57+
const valueIsString = valuePath.isStringLiteral();
58+
59+
if (valueIsString)
60+
continue;
5561

5662
if (computed && !keyIsString)
5763
continue;
@@ -60,7 +66,6 @@ export const traverse = ({push, options}) => ({
6066
continue;
6167

6268
const {rename, ignore = []} = options;
63-
const valuePath = propPath.get('value');
6469

6570
const from = getName(valuePath);
6671
const to = getName(keyPath);

packages/plugin-apply-shorthand-properties/test/apply-shorthand-properties.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ test('plugin-apply-shorthand-properties: no report: default', (t) => {
119119
t.end();
120120
});
121121

122+
test('plugin-apply-shorthand-properties: no report: string', (t) => {
123+
t.noReport('string');
124+
t.end();
125+
});
126+
122127
testWithRemove('plugin-apply-shorthand-properties: transform with options: assign', (t) => {
123128
t.transformWithOptions('assign', {
124129
rename: true,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const hello = {
2+
world: 'world',
3+
};

0 commit comments

Comments
 (0)