Skip to content

Commit 8070261

Browse files
committed
feature: @putout/plugin-conditions: reverse-conditions: couple
1 parent 3f9b710 commit 8070261

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const x = !a
2+
&& !b
3+
&& !c
4+
&& !d;
5+
const y = !a && !b && !c;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const x = !(a || b || c || d);
2+
const y = !(a || b || c);

packages/plugin-conditions/lib/reverse-condition/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export const replace = () => ({
44
'!(__a > __b)': '__a <= __b',
55
'!(__a !== __b && __c === __d)': '__a === __b || __c !== __d',
66
'!(__a !== __b || __c !== __d)': '__a === __b && __c === __d',
7+
'!(__a || __b || __c || __d)': '!__a && !__b && !__c && !__d',
8+
'!(__a || __b || __c)': '!__a && !__b && !__c',
79
'!(__a || __b)': '!__a && !__b',
810
'!(__a <= __b)': '__a > __b',
911
});

packages/plugin-conditions/lib/reverse-condition/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ test('conditions: reverse-condition: transform: less-equal', (t) => {
3636
t.transform('less-equal');
3737
t.end();
3838
});
39+
40+
test('conditions: reverse-condition: transform: couple', (t) => {
41+
t.transform('couple');
42+
t.end();
43+
});

0 commit comments

Comments
 (0)