@putout/plugin-conditions 8.3.0 → 8.4.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
@@ -16,6 +16,7 @@ npm i @putout/plugin-conditions -D
16
16
  - ✅ [add-return](#add-return);
17
17
  - ✅ [apply-comparison-order](#apply-comparison-order);
18
18
  - ✅ [apply-consistent-blocks](#apply-consistent-blocks);
19
+ - ✅ [apply-equal](#apply-equal);
19
20
  - ✅ [apply-if](#apply-if);
20
21
  - ✅ [convert-comparison-to-boolean](#convert-comparison-to-boolean);
21
22
  - ✅ [convert-equal-to-strict-equal](#convert-equal-to-strict-equal);
@@ -40,6 +41,7 @@ npm i @putout/plugin-conditions -D
40
41
  "rules": {
41
42
  "conditions/apply-consistent-blocks": "on",
42
43
  "conditions/apply-comparison-order": "on",
44
+ "conditions/apply-equal": "on",
43
45
  "conditions/apply-if": "on",
44
46
  "conditions/add-return": "on",
45
47
  "conditions/convert-comparison-to-boolean": "on",
@@ -141,6 +143,22 @@ Linter | Rule | Fix
141
143
  🐊 **Putout**| [`conditions/apply-comparison-order`](https://github.com/coderaiser/putout/tree/master/packages/plugin-conditions/#apply-comparison-order)| ✅
142
144
  ⏣ **ESLint** | [`yoda`](https://eslint.org/docs/rules/yoda) | ½
143
145
 
146
+ ## apply-equal
147
+
148
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/7ec940ad79df7e12a1d9111136b4a168/2ccea607e3232721eb950c18195168f8d9b4ef6a).
149
+
150
+ ### ❌ Example of incorrect code
151
+
152
+ ```js
153
+ return a.b = c;
154
+ ```
155
+
156
+ ### ✅ Example of correct code
157
+
158
+ ```js
159
+ return a.b === c;
160
+ ```
161
+
144
162
  ## apply-if
145
163
 
146
164
  ### ❌ Example of incorrect code
@@ -0,0 +1,5 @@
1
+ export const report = () => `Use '===' instead of '=' when return a value`;
2
+
3
+ export const replace = () => ({
4
+ 'return __a = __b': 'return __a === __b',
5
+ });
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as applyEqual from './apply-equal/index.js';
1
2
  import * as applyConsistentBlocks from './apply-consistent-blocks/index.js';
2
3
  import * as applyComparisonOrder from './apply-comparison-order/index.js';
3
4
  import * as applyIf from './apply-if/index.js';
@@ -6,7 +7,7 @@ import * as convertComparisonToBoolean from './convert-comparison-to-boolean/ind
6
7
  import * as convertEqualToStrictEqual from './convert-equal-to-strict-equal/index.js';
7
8
  import * as mergeIfStatements from './merge-if-statements/index.js';
8
9
  import * as removeBoolean from './remove-boolean/index.js';
9
- import removeZero from './remove-zero/index.js';
10
+ import * as removeZero from './remove-zero/index.js';
10
11
  import * as removeUselessElse from './remove-useless-else/index.js';
11
12
  import * as simplify from './simplify/index.js';
12
13
  import * as removeSameValuesCondition from './remove-same-values-condition/index.js';
@@ -36,4 +37,5 @@ export const rules = {
36
37
  'wrap-with-block': wrapWithBlock,
37
38
  'remove-useless-loop-condition': removeUselessLoopCondition,
38
39
  'merge-if-with-else': mergeIfWithElse,
40
+ 'apply-equal': applyEqual,
39
41
  };
@@ -1,3 +1,7 @@
1
1
  import {createAvoidInAssertions} from '../avoid-in-assertions.js';
2
2
 
3
- export default createAvoidInAssertions(0);
3
+ export const {
4
+ report,
5
+ match,
6
+ replace,
7
+ } = createAvoidInAssertions(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-conditions",
3
- "version": "8.3.0",
3
+ "version": "8.4.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds support of conditions transformations",