@putout/plugin-putout 29.32.0 → 29.33.1

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
@@ -103,6 +103,7 @@ npm i @putout/plugin-putout -D
103
103
  - ✅ [shorten-imports](#shorten-imports);
104
104
  - ✅ [simplify-replace-template](#simplify-replace-template);
105
105
  - ✅ [convert-replacer-to-includer](#convert-replacer-to-includer);
106
+ - ✅ [remove-useless-match](#remove-useless-match);
106
107
 
107
108
  ## File rules
108
109
 
@@ -202,7 +203,8 @@ npm i @putout/plugin-putout -D
202
203
  "putout/shorten-imports": "on",
203
204
  "putout/simplify-replace-template": "on",
204
205
  "putout/sort-readme-file": "on",
205
- "putout/convert-replacer-to-includer": "on"
206
+ "putout/convert-replacer-to-includer": "on",
207
+ "putout/remove-useless-match": "on"
206
208
  }
207
209
  }
208
210
  ```
@@ -2299,6 +2301,24 @@ export const include = () => [
2299
2301
  ];
2300
2302
  ```
2301
2303
 
2304
+ ## remove-useless-match
2305
+
2306
+ Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a813e8b3da2ccbe949a3156842c3112e/5e21a147247c2451f9f826ba384d62ab37c17a01).
2307
+
2308
+ ### ❌ Example of incorrect code
2309
+
2310
+ ```js
2311
+ export const match = () => ({
2312
+ 'const [__a, {__b}] = __c(__d, __e)': () => true,
2313
+ 'const [__a, {__b = {}} = {}] = __c(__d, __e)': () => true,
2314
+ });
2315
+ ```
2316
+
2317
+ ### ✅ Example of correct code
2318
+
2319
+ ```js
2320
+ ```
2321
+
2302
2322
  ## License
2303
2323
 
2304
2324
  MIT
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as removeUselessMatch from './remove-useless-match/index.js';
1
2
  import * as convertReplacerToIncluder from './convert-replacer-to-includer/index.js';
2
3
  import * as applyTypeCheck from './apply-type-check/index.js';
3
4
  import * as sortReadmeFile from './sort-readme-file/index.js';
@@ -182,4 +183,5 @@ export const rules = {
182
183
  'sort-readme-file': sortReadmeFile,
183
184
  'apply-type-check': applyTypeCheck,
184
185
  'convert-replacer-to-includer': convertReplacerToIncluder,
186
+ 'remove-useless-match': removeUselessMatch,
185
187
  };
@@ -0,0 +1,30 @@
1
+ import {operator, types} from 'putout';
2
+
3
+ const {compare, remove} = operator;
4
+ const {
5
+ booleanLiteral,
6
+ isObjectProperty,
7
+ } = types;
8
+
9
+ export const report = () => `Avoid useless 'match'`;
10
+
11
+ export const fix = (path) => {
12
+ remove(path);
13
+ };
14
+ export const traverse = ({push}) => ({
15
+ 'export const match = () => __object': (path) => {
16
+ const __objectPath = path.get('declaration.declarations.0.init.body');
17
+ const properties = __objectPath.get('properties');
18
+ const boolean = booleanLiteral(true);
19
+
20
+ for (const property of properties.filter(isObjectProperty)) {
21
+ const {body} = property.node.value;
22
+
23
+ if (compare(body, boolean))
24
+ push(property);
25
+ }
26
+
27
+ if (!__objectPath.get('properties').length)
28
+ push(path);
29
+ },
30
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "29.32.0",
3
+ "version": "29.33.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",