Skip to content

Commit cfe3afb

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

File tree

7 files changed

+11
-3
lines changed

7 files changed

+11
-3
lines changed

packages/eslint-plugin-putout/lib/long-properties-destructuring/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module.exports.filter = ({node}, options) => {
7171
maxLength,
7272
});
7373

74-
return !(isLoc || isLength);
74+
return !isLoc && !isLength;
7575
};
7676

7777
function isCorrectPropertiesLength(properties, {maxLength}) {

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+
});

packages/plugin-putout/lib/apply-fixture-name-to-message/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const check = ({__a}, path) => {
5757
const regEnd = RegExp(`: ${name}$`);
5858
const regMiddle = RegExp(`: ${name}: .*`);
5959

60-
return !(regEnd.test(value) || regMiddle.test(value));
60+
return !regEnd.test(value) && !regMiddle.test(value);
6161
};
6262

6363
const transform = ({__a}, path) => {

0 commit comments

Comments
 (0)