Skip to content

Commit 4f1d091

Browse files
committed
feature: @putout/plugin-remove-duplicate-keys: CallExpression: exclude
1 parent fd3d593 commit 4f1d091

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

packages/plugin-remove-duplicate-keys/lib/remove-duplicate-keys.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const {
1313
isObjectProperty,
1414
isStringLiteral,
1515
isObjectPattern,
16+
isCallExpression,
1617
} = types;
1718

1819
const isSpreadId = (name) => (a) => isSpreadElement(a) && isIdentifier(a.argument, {
@@ -94,6 +95,9 @@ export const traverse = ({push}) => ({
9495
}
9596

9697
if (isObjectProperty(prop) && isMemberExpression(prop.key)) {
98+
if (isCallExpression(prop.key.object))
99+
continue;
100+
97101
const {computed} = prop;
98102
const name = extract(prop.key);
99103

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const a = {
2+
[require('hello').world]: 'x',
3+
};

packages/plugin-remove-duplicate-keys/test/remove-duplicate-keys.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ test('remove duplicate-keys: no report: object-pattern-rename', (t) => {
7272
t.end();
7373
});
7474

75+
test('remove duplicate-keys: no report: call', (t) => {
76+
t.noReport('call');
77+
t.end();
78+
});
79+
7580
test('remove duplicate-keys: no report: object-pattern-nested', (t) => {
7681
t.noReport('object-pattern-nested');
7782
t.end();

0 commit comments

Comments
 (0)