Skip to content

Commit 19c892c

Browse files
committed
docs: improve code examples
1 parent 5f1cebf commit 19c892c

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

readme.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,47 @@ De Morgan’s laws are a cornerstone of Boolean algebra and have several practic
4242

4343
- **Clarity**: Rewriting complex negations often results in expressions that more clearly communicate the underlying logic.
4444

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:
4654

4755
```js
48-
if (!(a && !b && c >= 10 && d !== e)) {
56+
if (!(a && b)) {
4957
/* ... */
5058
}
5159
```
5260

53-
Becomes:
61+
After:
5462

5563
```js
56-
if (!a || b || c < 10 || d === e) {
64+
if (!a || !b) {
5765
/* ... */
5866
}
5967
```
6068

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**
6270

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+
```
6486

6587
## Installation
6688

@@ -106,10 +128,10 @@ module.exports = {
106128

107129
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/use/command-line-interface#--fix).
108130

109-
| Name | Description | 🔧 |
110-
| :-------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------- | :-- |
111-
| [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 | 🔧 |
131+
| Name | Description | 🔧 |
132+
| :-------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------- | :-- |
133+
| [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 | 🔧 |
113135

114136
## Further Reading
115137

0 commit comments

Comments
 (0)