Skip to content

Commit 2025e29

Browse files
committed
feature: @putout/plugin-conditions: reverse: !(__a || __b) -> !__a && !__b
1 parent 68df6b1 commit 2025e29

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

β€Žpackages/plugin-apply-template-literals/lib/apply-template-literals.jsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const {
88

99
module.exports.report = () => `Use template literals ('\`\`') instead of binary expressions ('+')`;
1010

11-
module.exports.filter = ({parentPath}) => !(isBinaryExpression(parentPath) || isTemplateLiteral(parentPath.parentPath));
11+
module.exports.filter = ({parentPath}) => !isBinaryExpression(parentPath) && !isTemplateLiteral(parentPath.parentPath);
1212

1313
module.exports.replace = () => ({
1414
'"__a" + __identifier__b + "__c"': replaceNewlines('`__a${__identifier__b}__c`', ['__a', '__c']),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports.filter = ({parentPath}) => !isBinaryExpression(parentPath) && !isTemplateLiteral(parentPath.parentPath);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports.filter = ({parentPath}) => !(isBinaryExpression(parentPath) || isTemplateLiteral(parentPath.parentPath));

β€Žpackages/plugin-conditions/lib/reverse-condition/index.jsβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ module.exports.replace = () => ({
66
'!(__a > __b)': '__a <= __b',
77
'!(__a !== __b && __c === __d)': '__a === __b || __c !== __d',
88
'!(__a !== __b || __c !== __d)': '__a === __b && __c === __d',
9+
'!(__a || __b)': '!__a && !__b',
910
});

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ test('conditions: reverse-condition: transform: or', (t) => {
2828
t.transform('or');
2929
t.end();
3030
});
31+
32+
test('conditions: reverse-condition: transform: not-or', (t) => {
33+
t.transform('not-or');
34+
t.end();
35+
});

0 commit comments

Comments
Β (0)