You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+32-10Lines changed: 32 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,25 +42,47 @@ De Morgan’s laws are a cornerstone of Boolean algebra and have several practic
42
42
43
43
-**Clarity**: Rewriting complex negations often results in expressions that more clearly communicate the underlying logic.
44
44
45
-
For example:
45
+
-**Avoiding Logical Errors**: When dealing with nested logical expressions, small mistakes in the placement of negations can lead to subtle bugs. By enforcing a consistent style based on well-known laws, the plugin helps reduce such errors.
46
+
47
+
-**Simplification**: In some cases, the transformed expression may be simpler to evaluate and optimize, both for human readers and for compilers / interpreters.
48
+
49
+
### Examples
50
+
51
+
**Base example**
52
+
53
+
Before:
46
54
47
55
```js
48
-
if (!(a &&!b && c >=10&& d !== e)) {
56
+
if (!(a &&b)) {
49
57
/* ... */
50
58
}
51
59
```
52
60
53
-
Becomes:
61
+
After:
54
62
55
63
```js
56
-
if (!a ||b || c <10|| d === e) {
64
+
if (!a ||!b) {
57
65
/* ... */
58
66
}
59
67
```
60
68
61
-
-**Avoiding Logical Errors**: When dealing with nested logical expressions, small mistakes in the placement of negations can lead to subtle bugs. By enforcing a consistent style based on well-known laws, the plugin helps reduce such errors.
69
+
**More complex example**
62
70
63
-
-**Simplification**: In some cases, the transformed expression may be simpler to evaluate and optimize, both for human readers and for compilers / interpreters.
71
+
Before:
72
+
73
+
```js
74
+
if (!(a ||!b || c >=10|| d !== e)) {
75
+
/* ... */
76
+
}
77
+
```
78
+
79
+
After:
80
+
81
+
```js
82
+
if (!a && b && c <10&& d === e) {
83
+
/* ... */
84
+
}
85
+
```
64
86
65
87
## Installation
66
88
@@ -106,10 +128,10 @@ module.exports = {
106
128
107
129
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/use/command-line-interface#--fix).
|[no-negated-conjunction](https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-conjunction.md)| Transforms the negation of a conjunction into the equivalent | 🔧 |
112
-
|[no-negated-disjunction](https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-disjunction.md)| Transforms the negation of a disjunction into the equivalent | 🔧 |
|[no-negated-conjunction](https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-conjunction.md)| Transforms the negation of a conjunction into the equivalent disjunction | 🔧 |
134
+
|[no-negated-disjunction](https://github.com/azat-io/eslint-plugin-de-morgan/blob/main/docs/no-negated-disjunction.md)| Transforms the negation of a disjunction into the equivalent conjunction | 🔧 |
0 commit comments