@putout/plugin-putout 25.13.0 → 26.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.
@@ -15,6 +15,7 @@ const NAMES = [
15
15
  'no report',
16
16
  'no transform',
17
17
  'no report after transform',
18
+ 'no report with options',
18
19
  ];
19
20
 
20
21
  export const report = () => `Apply 'fixture' name to 'message'`;
@@ -26,6 +27,7 @@ export const match = () => ({
26
27
  't.transform(__a)': check,
27
28
  't.transform(__a, __b)': check,
28
29
  't.noTransform(__a)': check,
30
+ 't.noReportWithOptions(__a, __b)': check,
29
31
  });
30
32
 
31
33
  export const replace = () => ({
@@ -35,6 +37,7 @@ export const replace = () => ({
35
37
  't.transform(__a, __b)': transform,
36
38
  't.noTransform(__a)': transform,
37
39
  't.noReportAfterTransform(__a)': transform,
40
+ 't.noReportWithOptions(__a, __b)': transform,
38
41
  });
39
42
 
40
43
  const isTest = (path) => compare(path, 'test(__a, (t) => __body)', {
@@ -1,48 +1,16 @@
1
- import {
2
- operator,
3
- template,
4
- types,
5
- } from 'putout';
1
+ import {operator} from 'putout';
6
2
 
7
- const {objectProperty, identifier} = types;
8
- const {replaceWith, insertBefore} = operator;
3
+ const {replaceWith} = operator;
9
4
 
10
5
  export const report = () => {
11
- return `"operate.replaceWithMultiple" should be called instead of "path.replaceWithMultiple"`;
6
+ return `Use 'operator.replaceWithMultiple()' instead of 'path.replaceWithMultiple()'`;
12
7
  };
13
8
 
14
- const replaceWithAST = template.ast(`
15
- const {replaceWithMultiple} = require('putout').operate;
16
- `);
17
-
18
- export const fix = ({path, calleePath, property, object, program}) => {
19
- const first = program.get('body.0');
20
- const {bindings} = program.scope;
21
-
9
+ export const fix = ({path, calleePath, property, object}) => {
22
10
  replaceWith(calleePath, property);
23
11
  path.node.arguments.unshift(object);
24
-
25
- if (bindings.replaceWithMultiple)
26
- return;
27
-
28
- if (!bindings.replaceWith && !bindings.insertAfter)
29
- return insertBefore(first, replaceWithAST);
30
-
31
- const id = identifier('replaceWithMultiple');
32
- const varPath = getVarPath(bindings);
33
-
34
- varPath.node.id.properties.push(objectProperty(id, id, false, true));
35
12
  };
36
13
 
37
- function getVarPath(bindings) {
38
- const {replaceWith, insertAfter} = bindings;
39
-
40
- if (replaceWith)
41
- return replaceWith.path;
42
-
43
- return insertAfter.path;
44
- }
45
-
46
14
  export const traverse = ({push}) => ({
47
15
  CallExpression(path) {
48
16
  const calleePath = path.get('callee');
@@ -18,6 +18,7 @@ const INCORRECT = {
18
18
  REPORT: /: (no report after transform|no report|transform|no transform)/,
19
19
  NO_REPORT: /: (no report after transform|report|transform|no transform)/,
20
20
  NO_REPORT_AFTER_TRANSFORM: /: (report|transform|no transform|no report)/,
21
+ NO_REPORT_WITH_OPTIONS: /: (report|transform|no transform|no report)/,
21
22
  };
22
23
 
23
24
  export const traverse = ({push}) => ({
@@ -56,6 +57,11 @@ export const traverse = ({push}) => ({
56
57
  incorrect: INCORRECT.NO_REPORT_AFTER_TRANSFORM,
57
58
  correct: ': no report after transform',
58
59
  }),
60
+ 't.noReportWithOptions(__a, __b)': convert({
61
+ push,
62
+ incorrect: INCORRECT.NO_REPORT_WITH_OPTIONS,
63
+ correct: ': no report after transform',
64
+ }),
59
65
  });
60
66
 
61
67
  const convert = ({push, correct, incorrect}) => (path) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "25.13.0",
3
+ "version": "26.1.0",
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",
@@ -43,6 +43,8 @@
43
43
  ],
44
44
  "devDependencies": {
45
45
  "@putout/eslint-flat": "^3.0.0",
46
+ "@putout/plugin-esm": "*",
47
+ "@putout/plugin-merge-destructuring-properties": "*",
46
48
  "@putout/plugin-nodejs": "*",
47
49
  "@putout/plugin-tape": "*",
48
50
  "@putout/test": "^13.0.0",