Skip to content

Commit 45a2f5a

Browse files
committed
feature: @putout/plugin-conditions: reverse-condition: and: add
1 parent 8814266 commit 45a2f5a

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

packages/plugin-conditions/lib/apply-consistent-blocks/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module.exports.filter = (path) => {
102102
if (coupleCount === paths.length)
103103
return false;
104104

105-
return !(count !== 1 && count === paths.length);
105+
return count === 1 || count !== paths.length;
106106
};
107107

108108
function getAllNodes(path, nodes = []) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
count === 1 || count !== paths.length;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!(count !== 1 && count === paths.length);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ module.exports.report = () => `Avoid useless '!'`;
44

55
module.exports.replace = () => ({
66
'!(__a > __b)': '__a <= __b',
7+
'!(__a !== __b && __c === __d)': '__a === __b || __c !== __d',
78
});

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ test('conditions: reverse-condition: transform', (t) => {
1818
t.transform('reverse-condition');
1919
t.end();
2020
});
21+
22+
test('conditions: reverse-condition: transform: and', (t) => {
23+
t.transform('and');
24+
t.end();
25+
});

0 commit comments

Comments
 (0)