Skip to content

Commit d629da0

Browse files
committed
feature: @putout/plugin-package-json: remove-duplicate-keywords: second
1 parent 28d2ae8 commit d629da0

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__putout_processor_json({
2+
"keywords": [
3+
"putout-plugin",
4+
"putout",
5+
"plugin"
6+
]
7+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
__putout_processor_json({
2+
"keywords": [
3+
"putout-plugin",
4+
"putout",
5+
"plugin",
6+
"putout"
7+
],
8+
});
9+

packages/plugin-package-json/lib/remove-duplicate-keywords/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ export const traverse = ({push}) => ({
2525
return;
2626

2727
let first = arrayPath.get('elements.0');
28-
let second = arrayPath.get('elements.1');
29-
3028
do {
29+
let second = arrayPath.get('elements.0');
3130
do {
32-
if (!second)
33-
break;
31+
if (first === second)
32+
continue;
3433

3534
if (first.node.value === second.node.value)
3635
push(second);

packages/plugin-package-json/lib/remove-duplicate-keywords/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ test('package-json: remove-duplicate-keywords: transform', (t) => {
1616
t.transform('remove-duplicate-keywords');
1717
t.end();
1818
});
19+
20+
test('package-json: remove-duplicate-keywords: transform: second', (t) => {
21+
t.transform('second');
22+
t.end();
23+
});

0 commit comments

Comments
 (0)