@putout/plugin-conditions 6.0.0 → 6.1.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 CHANGED
@@ -22,6 +22,7 @@ npm i @putout/plugin-conditions -D
22
22
  - ✅ [convert-arrow-to-condition](#convert-arrow-to-condition);
23
23
  - ✅ [evaluate](#evaluate);
24
24
  - ✅ [merge-if-statements](#merge-if-statements);
25
+ - ✅ [reverse](#reverse);
25
26
  - ✅ [remove-boolean](#remove-boolean);
26
27
  - ✅ [remove-constant](#remove-constant);
27
28
  - ✅ [remove-same-values-condition](hremove-same-values-condition);
@@ -42,6 +43,7 @@ npm i @putout/plugin-conditions -D
42
43
  "conditions/convert-equal-to-strict-equal": "on",
43
44
  "conditions/convert-arrow-to-condition": "on",
44
45
  "conditions/evaluate": "on",
46
+ "conditions/reverse": "on",
45
47
  "conditions/remove-boolean": "on",
46
48
  "conditions/remove-constant": "on",
47
49
  "conditions/remove-zero": "on",
@@ -245,6 +247,22 @@ const c = a;
245
247
  console.log(a);
246
248
  ```
247
249
 
250
+ ## reverse
251
+
252
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/fabfc16a5a5d1002c721fc2dfc31474b/8d1de98533ef439e56e8784f54a34c3928a074fa).
253
+
254
+ ### ❌ Example of incorrect code
255
+
256
+ ```js
257
+ const check = (references) => !(references > 3);
258
+ ```
259
+
260
+ ### ✅ Example of correct code
261
+
262
+ ```js
263
+ const check = (references) => references <= 3;
264
+ ```
265
+
248
266
  ## remove-boolean
249
267
 
250
268
  ### ❌ Example of incorrect code
package/lib/index.js CHANGED
@@ -14,6 +14,7 @@ const simplify = require('./simplify');
14
14
  const removeSameValuesCondition = require('./remove-same-values-condition');
15
15
  const addReturn = require('./add-return');
16
16
  const convertArrowToCondition = require('./convert-arrow-to-condition');
17
+ const reverseCondition = require('./reverse-condition');
17
18
 
18
19
  module.exports.rules = {
19
20
  'apply-comparison-order': applyComparisonOrder,
@@ -30,4 +31,5 @@ module.exports.rules = {
30
31
  'remove-same-values-condition': removeSameValuesCondition,
31
32
  'add-return': addReturn,
32
33
  'convert-arrow-to-condition': convertArrowToCondition,
34
+ 'reverse-condition': reverseCondition,
33
35
  };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => `Avoid useless '!'`;
4
+
5
+ module.exports.replace = () => ({
6
+ '!(__a > __b)': '__a <= __b',
7
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-conditions",
3
- "version": "6.0.0",
3
+ "version": "6.1.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",