@putout/plugin-conditions 4.1.0 β 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/lib/add-return/index.js +8 -0
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ npm i @putout/plugin-conditions -D
|
|
|
19
19
|
"conditions/apply-consistent-blocks": "on",
|
|
20
20
|
"conditions/apply-comparison-order": "on",
|
|
21
21
|
"conditions/apply-if": "on",
|
|
22
|
+
"conditions/add-return": "on",
|
|
22
23
|
"conditions/convert-comparison-to-boolean": "on",
|
|
23
24
|
"conditions/convert-equal-to-strict-equal": "on",
|
|
24
25
|
"conditions/evaluate": "on",
|
|
@@ -127,6 +128,24 @@ if (2 > 3)
|
|
|
127
128
|
alert();
|
|
128
129
|
```
|
|
129
130
|
|
|
131
|
+
## add-return
|
|
132
|
+
|
|
133
|
+
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/b1c12a29951659bb54b283310027d6ef/b32270ca22a36728c67edf0dc0f0519876b78f16).
|
|
134
|
+
|
|
135
|
+
### β Example of incorrect code
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
if (a)
|
|
139
|
+
false;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### β
Example of correct code
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
if (a)
|
|
146
|
+
return false;
|
|
147
|
+
```
|
|
148
|
+
|
|
130
149
|
## convert-comparison-to-boolean
|
|
131
150
|
|
|
132
151
|
> Strict equality compares two values for equality. Neither value is implicitly converted to some other value before being compared. If the values have different types, the values are considered unequal.
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const removeZero = require('./remove-zero');
|
|
|
12
12
|
const removeUselessElse = require('./remove-useless-else');
|
|
13
13
|
const simplify = require('./simplify');
|
|
14
14
|
const removeSameValuesCondition = require('./remove-same-values-condition');
|
|
15
|
+
const addReturn = require('./add-return');
|
|
15
16
|
|
|
16
17
|
module.exports.rules = {
|
|
17
18
|
'apply-comparison-order': applyComparisonOrder,
|
|
@@ -26,4 +27,5 @@ module.exports.rules = {
|
|
|
26
27
|
'remove-useless-else': removeUselessElse,
|
|
27
28
|
simplify,
|
|
28
29
|
'remove-same-values-condition': removeSameValuesCondition,
|
|
30
|
+
'add-return': addReturn,
|
|
29
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-conditions",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "πPutout plugin adds support of conditions transformations",
|